📄 yacc.y
字号:
/* * grammar for the input to Yacc * modified by mhss(http://mhss.nease.net) *//* basic entities */%token IDENTIFIER /* includes identifiers and literals */%token NUMBER /* [0-9]+ */%token C_IDENTIFIER /* IDENTIFIER ':' */%token TYPENAME /* '<' IDENTIFIER '>' *//* * reserved words: * %type => TYPEDEF, %nonassoc %binary => BINARY, %token %term => TERM etc. */%token TERM LEFT RIGHT BINARY PREC TYPEDEF START UNION%token MARK /* the %% mark */%token LCURLY /* the %{ mark *//* ascii character literals stand for themselves */%start spec%%spec : defs MARK rules prog ;prog : /* empty: the second MARK is optional */ | MARK { /*In this action, eat up the rest of the file*/ } ;defs : /* empty */ | defs def semicolons ;def : START IDENTIFIER | UNION { /*Copy union definition to output*/ } | LCURLY { /*Copy C code to output file*/ } | TYPEDEF TYPENAME tlist | rword tag nlist ;rword : TERM | LEFT | RIGHT | BINARY ;tag : /* empty */ | TYPENAME ;tlist : tmno | tlist tmno | tlist ',' tmno ;nlist : nmno | nlist nmno | nlist ',' nmno ;tmno : IDENTIFIER ; nmno : IDENTIFIER num ;num : /* empty */ | NUMBER ;/* * rules section */rules : opt_declare C_IDENTIFIER rbody | rules rule ;opt_declare : /* empty */ | LCURLY { /*Copy C code to output file*/ } ;rule : C_IDENTIFIER rbody | '|' rbody ;rbody : rhs semicolons | rhs act semicolons ; rhs : /* empty */ | rhs prec | rhs IDENTIFIER | rhs act IDENTIFIER /* embedded action */ ;act : '=' /* automatically added on before '{' */ { /*Copy action, translate $$, etc.*/ } ;prec : PREC IDENTIFIER ;semicolons : /* empty */ | semicolons ';' ;%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -