⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test2.txt

📁 编译原理中的First集与 Follow集生成程序
💻 TXT
字号:
%token ID NUM ASC MARK PREC
  /* 关键字  */
%token START TOKEN UNION LCURL RCURL LEFT RIGHT NONASSOC TYPE

%%
spec  : defines MARK rules tail
   ;
  
tail  : MARK eat_up_rest
    | // empty 
;

defines: // empty
    |   START    ID                 defines
    |   UNION    eat_up_union       defines
    |   LCURL    eat_up_defs RCURL  defines
    |   TOKEN    symtype            nlist
    |   LEFT     symtype            nlist
    |   RIGHT    symtype            nlist
    |   NONASSOC symtype            nlist
    |   TYPE     symtype            nlist2
;

eat_up_defs:
      /* Call the function eat_up_def() to copy
         the C declare to output file.*/
    ;

eat_up_union:
      /* Call the function eat_up_union()to copy
         the union declear to output file.*/
    ;

eat_up_symtype:
      /* Call the function eat_up_symtype() to
         copy between '<' to '>' into symbol's
         symtype field.*/
    ;

eat_up_rest:
      /* Call function eat_up_rest() to copy the
         rest of the Grammar file into output file.
       */
    ;
     
symtype:  /* empty */
    |   '<' eat_up_symtype '>'
    ;

nlist : factor
    |   factor nlist
    |   factor ',' nlist
    ;
    
factor: ID
    |   ID NUM
    |   ASC
    |   ASC NUM
    ;

nlist2 : factor2
    |    factor2 nlist2
    |    factor2 ',' nlist2
    ;
factor2: ID
    |    ASC
    ;

rules : ID ':' rbodys ';' rules
    | /* empty */
    ;

rbodys: '|' rbody prec rbodys
    |   ID  rbody prec rbodys
    |   ASC rbody prec rbodys
    |   '{' rbody prec rbodys
    |   PREC      prec rbodys /* 处理由 %prec 指定优先级的空产生式.*/
    |   ';'                   /* 处理分号前边可能产生的空产生式*/
    ;

rbody : /* empty */
    |   ID  rbody
    |   ASC rbody
    |   '{' eat_act '}'           /* common action*/
    |   '{' eat_act '}' ID  rbody /* panel action */
    |   '{' eat_act '}' ASC rbody /* panel action */
    |   '{' eat_act '}' '{' rbody /* panel action */
    ;

prec  : /* empty */
    |   PREC ID
    |   PREC ID '{' eat_act '}'
    ;

eat_act: 
    // empty
    ;
    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -