小编bbg*_*bbg的帖子

为什么这个野牛代码会产生意想不到的输出?

flex代码:

  1 %option noyywrap nodefault yylineno case-insensitive
  2 %{
  3 #include "stdio.h"
  4 #include "tp.tab.h"
  5 %}
  6 
  7 %%
  8 "{"             {return '{';}
  9 "}"             {return '}';}
 10 ";"             {return ';';}
 11 "create"        {return CREATE;}
 12 "cmd"           {return CMD;}
 13 "int"           {yylval.intval = 20;return INT;}
 14 [a-zA-Z]+       {yylval.strval = yytext;printf("id:%s\n" , yylval.strval);return ID;}
 15 [ \t\n]
 16 <<EOF>>         {return 0;}
 17 .               {printf("mistery char\n");}
 18 
Run Code Online (Sandbox Code Playgroud)

野牛代码:

  1 %{
  2 #include "stdlib.h"
  3 #include "stdio.h"
  4 #include "stdarg.h"
  5 void …
Run Code Online (Sandbox Code Playgroud)

c bison flex-lexer

2
推荐指数
1
解决办法
262
查看次数

标签 统计

bison ×1

c ×1

flex-lexer ×1