导航:首页 > 编程语言 > lexyacc外部程序

lexyacc外部程序

发布时间:2023-01-29 21:46:35

① 不知道如何生成flex的C程序

这是我以前写过的一个scanner.l

你试试,应该可以用。

%{
#include <stdio.h>
#include <string.h>
%}

digit [0-9]
number {digit}+
pint ("+")?{number}
mint "-"{number}
realnumber ("+"|"-")?{number}"."?{number}
true "TRUE"
false "FALSE"
letter [a-zA-Z]
identifier {letter}+
newline \n
whitespace [ \t]+
%%

"PROGRAM" {return PROGRAM;}
"BEGIN" {return BEGIN;}
"END" {return END;}
"CONST" {return CONST;}
"INTEGER" {return INTEGER;}
"REAL" {return REAL;}
"BOOLEAN" {return BOOLEAN;}
"ARRAY" {return ARRAY;}
"IF" {return IF;}
"THEN" {return THEN;}
"ELSE" {return ELSE;}
"ENDIF" {return ENDIF;}
"WHILE" {return WHILE;}
"DO" {return DO;}
"REPEAT" {return REPEAT;}
"UNTIL" {return UNTIL;}
"FOR" {return FOR;}
"TO" {return TO;}
"READ" {return READ;}
"WRITE" {return WRITE;}

":=" {strcpy(yylval.cval,yytext);return ASSIGN;}
"=" {strcpy(yylval.cval,yytext);return EQ;}
"<" {strcpy(yylval.cval,yytext);return LT;}
"<=" {strcpy(yylval.cval,yytext);return NMT;}
"<>" {strcpy(yylval.cval,yytext);return NEQ;}
">" {strcpy(yylval.cval,yytext);return MT;}
">=" {strcpy(yylval.cval,yytext);return NLT;}
"+" {strcpy(yylval.cval,yytext);return PLUS;}
"-" {strcpy(yylval.cval,yytext);return MINUS;}
"*" {strcpy(yylval.cval,yytext);return MULTIPLY;}
"/" {strcpy(yylval.cval,yytext);return OVER;}
"AND" {strcpy(yylval.cval,yytext);return AND;}
"OR" {strcpy(yylval.cval,yytext);return OR;}
"NOT" {strcpy(yylval.cval,yytext);return NOT;}
":" {return COLON;}
"#" {return STOP;}
"," {strcpy(yylval.cval,yytext);return COMMA;}
";" {return SEMI;}
"[" {return LSB;}
"]" {return RSB;}
"(" {return LPAREN;}
")" {return RPAREN;}

{pint} {strcpy(yylval.cval,yytext);return PINT;}
{mint} {strcpy(yylval.cval,yytext);return MINT;}
{realnumber} {strcpy(yylval.cval,yytext);return REALNUMBER;}
{true} {strcpy(yylval.cval,yytext);return TRUE;}
{false} {strcpy(yylval.cval,yytext);return FALSE;}
{identifier} {strcpy(yylval.cval,yytext);return ID;}
{newline} {}
{whitespace} {}
. {return ERROR;}
%%

int yywrap()
{
return 1;
}

② Yacc(bison.exe)

将BISON_HAIRY设为F:\LEXYACC\BisonFlex\bison.hairy

BISON_SIMPLE设为F:\LEXYACC\BisonFlex\bison.simple即可

阅读全文

与lexyacc外部程序相关的资料

热点内容
网络怎么校线 浏览:546
会玩app稀有宝箱里面有什么 浏览:718
打开icloud备份文件在哪里看 浏览:602
一个表格多个数据怎么样查找数据 浏览:466
qq飞车微信签到app有哪些 浏览:299
如何制作虚拟货币app 浏览:303
ug50能通过补丁升级到高版本吗 浏览:766
dxf文件cad打不开的原因 浏览:525
2012怎么改域用户密码 浏览:550
dtv网络电视手机版下载 浏览:954
mfc100u放在哪个文件夹 浏览:359
javaweb插件 浏览:58
pto密码忘记 浏览:567
logo竞赛教程 浏览:481
贵阳去哪里学编程比较好 浏览:132
java将string转为json 浏览:291
ppt2013制作exe文件 浏览:80
linux文件只读不能复制 浏览:597
开关代码 浏览:91
word绘图板 浏览:359

友情链接