?? gram.y
字號:
| continue semi { yypopulate_tree("jump_statement",2); }
| break semi { yypopulate_tree("jump_statement",2); }
| return semi { yypopulate_tree("jump_statement",2); }
| return expr semi { yypopulate_tree("jump_statement",3); }
;
identifier
: IDENTIFIER {
yypopulate_tree(*($1), 0);
if (in_struct) {
in_struct = 0;
} else if (yytypedef_flag && !in_braces) {
yytypedef_table_add(*($1));
yytypedef_flag = 0;
} else {
// yypopulate_db (NEW_VAR, *($1));
}
}
;
string
: string STRING_LITERAL { yypopulate_tree("part_of_string", 1); }
| STRING_LITERAL { yypopulate_tree(*($1), 0); }
;
primary_expr
: identifier { yypopulate_tree("primary_expr", 1); }
| CONSTANT { yypopulate_tree(*($1), 0); }
| string { yypopulate_tree("string", 1); }
| lparen expr rparen { yypopulate_tree("primary_expr", 3); }
;
postfix_expr
: primary_expr //KSV{ yypopulate_tree("postfix_expr", 1); }
| postfix_expr lbracket expr rbracket { yypopulate_tree("postfix_expr", 4); }
| postfix_expr lparen rparen { yypopulate_tree("function_call", 3); }
| postfix_expr lparen argument_expr_list rparen { yypopulate_tree("function_call", 4); }
| postfix_expr period identifier { yypopulate_tree("postfix_expr", 3); }
| postfix_expr ptr_op identifier { yypopulate_tree("postfix_expr", 3); }
| postfix_expr inc_op { yypopulate_tree("short_assign_op", 2); }
| postfix_expr dec_op { yypopulate_tree("short_assign_op", 2); }
;
unary_expr
: postfix_expr //KSV{ yypopulate_tree("unary_expr", 1); }
| inc_op unary_expr { yypopulate_tree("short_assign_op", 2); }
| dec_op unary_expr { yypopulate_tree("short_assign_op", 2); }
| unary_operator cast_expr { yypopulate_tree("unary_expr", 2); }
| sizeof unary_expr { yypopulate_tree("unary_expr", 2); }
| sizeof lparen type_name rparen { yypopulate_tree("unary_expr", 4); }
;
unary_operator
: amperstand { yypopulate_tree("unary_operator",1 ); }
| star { yypopulate_tree("unary_operator",1 ); }
| plus { yypopulate_tree("unary_operator",1 ); }
| minus { yypopulate_tree("unary_operator",1 ); }
| tilda { yypopulate_tree("unary_operator",1 ); }
| emark { yypopulate_tree("unary_operator",1 ); }
;
cast_expr
: unary_expr //KSV{ yypopulate_tree("cast_expr", 1); }
| lparen type_name rparen cast_expr { yypopulate_tree("cast_expr", 4); }
;
multiplicative_expr
: cast_expr //KSV{ yypopulate_tree("multiplicative_expr", 1); }
| multiplicative_expr star cast_expr { yypopulate_tree("multiplicative_expr", 3); }
| multiplicative_expr slash cast_expr { yypopulate_tree("multiplicative_expr", 3); }
| multiplicative_expr percent cast_expr { yypopulate_tree("multiplicative_expr", 3); }
;
additive_expr
: multiplicative_expr //KSV{ yypopulate_tree("additive_expr", 1); }
| additive_expr plus multiplicative_expr { yypopulate_tree("additive_expr", 3); }
| additive_expr minus multiplicative_expr { yypopulate_tree("additive_expr", 3); }
;
shift_expr
: additive_expr //KSV{ yypopulate_tree("shift_expr", 1); }
| shift_expr left_op additive_expr { yypopulate_tree("shift_expr", 3); }
| shift_expr right_op additive_expr { yypopulate_tree("shift_expr", 3); }
;
relational_expr
: shift_expr //KSV{ yypopulate_tree("relational_expr", 1); }
| relational_expr langle shift_expr { yypopulate_tree("relational_expr", 3); }
| relational_expr rangle shift_expr { yypopulate_tree("relational_expr", 3); }
| relational_expr le_op shift_expr { yypopulate_tree("relational_expr", 3); }
| relational_expr ge_op shift_expr { yypopulate_tree("relational_expr", 3); }
;
equality_expr
: relational_expr //KSV{ yypopulate_tree("equality_expr", 1); }
| equality_expr eq_op relational_expr { yypopulate_tree("equality_expr", 3); }
| equality_expr ne_op relational_expr { yypopulate_tree("equality_expr", 3); }
;
and_expr
: equality_expr //KSV{ yypopulate_tree("and_expr", 1); }
| and_expr amperstand equality_expr { yypopulate_tree("and_expr", 3); }
;
exclusive_or_expr
: and_expr //KSV{ yypopulate_tree("exclusive_or_expr", 1); }
| exclusive_or_expr carot and_expr { yypopulate_tree("exclusive_or_expr", 3); }
;
inclusive_or_expr
: exclusive_or_expr //KSV{ yypopulate_tree("inclusive_or_expr", 1); }
| inclusive_or_expr single_bar exclusive_or_expr { yypopulate_tree("inclusive_or_expr", 3); }
;
logical_and_expr
: inclusive_or_expr //KSV{ yypopulate_tree("logical_and_expr", 1); }
| logical_and_expr and_op inclusive_or_expr { yypopulate_tree("logical_and_expr", 3); }
;
logical_or_expr
: logical_and_expr //KSV{ yypopulate_tree("logical_or_expr", 1); }
| logical_or_expr or_op logical_and_expr { yypopulate_tree("logical_or_expr", 3); }
;
conditional_expr
: logical_or_expr //KSV{ yypopulate_tree("conditional_expr", 1); }
| logical_or_expr qmark logical_or_expr colon conditional_expr { yypopulate_tree("conditional_expr", 5); }
;
assignment_operator
: equal { yypopulate_tree("assignment_operator", 1); }
| MUL_ASSIGN { yypopulate_tree(*($1), 0); }
| DIV_ASSIGN { yypopulate_tree(*($1), 0); }
| MOD_ASSIGN { yypopulate_tree(*($1), 0); }
| ADD_ASSIGN { yypopulate_tree(*($1), 0); }
| SUB_ASSIGN { yypopulate_tree(*($1), 0); }
| LEFT_ASSIGN { yypopulate_tree(*($1), 0); }
| RIGHT_ASSIGN { yypopulate_tree(*($1), 0); }
| AND_ASSIGN { yypopulate_tree(*($1), 0); }
| XOR_ASSIGN { yypopulate_tree(*($1), 0); }
| OR_ASSIGN { yypopulate_tree(*($1), 0); }
;
assignment_expr
: conditional_expr //KSV{ yypopulate_tree("assignment_expr", 1); }
| unary_expr assignment_operator assignment_expr { yypopulate_tree("assignment_expr", 3); }
;
constant_expr
: conditional_expr { yypopulate_tree("constant_expr", 1); }
;
comma
: ',' { yypopulate_tree(*($1), 0); }
;
period
: '.' { yypopulate_tree(*($1), 0); }
;
emark
: '!' { yypopulate_tree(*($1), 0); }
;
qmark
: '?' { yypopulate_tree(*($1), 0); }
;
semi
: ';' { yypopulate_tree(*($1), 0); }
;
colon
: ':' { yypopulate_tree(*($1), 0); }
;
lparen
: '(' { yypopulate_tree(*($1), 0); }
;
rparen
: ')' { yypopulate_tree(*($1), 0); }
;
lbracket
: '[' { yypopulate_tree(*($1), 0); }
;
rbracket
: ']' { yypopulate_tree(*($1), 0); }
;
lbrace
: '{' { yypopulate_tree(*($1), 0); in_braces++; }
;
rbrace
: '}' { yypopulate_tree(*($1), 0); in_braces--; }
;
equal
: '=' { yypopulate_tree(*($1), 0); }
;
star
: '*' { yypopulate_tree(*($1), 0); }
;
plus
: '+' { yypopulate_tree(*($1), 0); }
;
minus
: '-' { yypopulate_tree(*($1), 0); }
;
slash
: '/' { yypopulate_tree(*($1), 0); }
;
carot
: '^' { yypopulate_tree(*($1), 0); }
;
amperstand
: '&' { yypopulate_tree(*($1), 0); }
;
single_bar
: '|' { yypopulate_tree(*($1), 0); }
;
tilda
: '~' { yypopulate_tree(*($1), 0); }
;
percent
: '%' { yypopulate_tree(*($1), 0); }
;
langle
: '<' { yypopulate_tree(*($1), 0); }
;
rangle
: '>' { yypopulate_tree(*($1), 0); }
;
sizeof
: SIZEOF { yypopulate_tree(*($1), 0); }
;
ptr_op
: PTR_OP { yypopulate_tree(*($1), 0); }
;
inc_op
: INC_OP { yypopulate_tree(*($1), 0); }
;
dec_op
: DEC_OP { yypopulate_tree(*($1), 0); }
;
left_op
: LEFT_OP { yypopulate_tree(*($1), 0); }
;
right_op
: RIGHT_OP { yypopulate_tree(*($1), 0); }
;
le_op
: LE_OP { yypopulate_tree(*($1), 0); }
;
ge_op
: GE_OP { yypopulate_tree(*($1), 0); }
;
eq_op
: EQ_OP { yypopulate_tree(*($1), 0); }
;
ne_op
: NE_OP { yypopulate_tree(*($1), 0); }
;
and_op
: AND_OP { yypopulate_tree(*($1), 0); }
;
or_op
: OR_OP { yypopulate_tree(*($1), 0); }
;
enum
: ENUM { yypopulate_tree(*($1), 0); in_struct++;}
;
elipsis
: ELIPSIS { yypopulate_tree(*($1), 0); }
;
case
: CASE { yypopulate_tree(*($1), 0); }
;
default
: DEFAULT { yypopulate_tree(*($1), 0); }
;
if
: IF { yypopulate_tree(*($1), 0); }
;
else
: ELSE { yypopulate_tree(*($1), 0); }
;
switch
: SWITCH { yypopulate_tree(*($1), 0); }
;
while
: WHILE { yypopulate_tree(*($1), 0); }
;
do
: DO { yypopulate_tree(*($1), 0); }
;
for
: FOR { yypopulate_tree(*($1), 0); }
;
goto
: GOTO { yypopulate_tree(*($1), 0); }
;
continue
: CONTINUE { yypopulate_tree(*($1), 0); }
;
break
: BREAK { yypopulate_tree(*($1), 0); }
;
return
: RETURN { yypopulate_tree(*($1), 0); }
;
%%
void yyerror(char *s)
{
fflush(stdout);
printf("\n%*s\n%*s\n", column, "^", column, s);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -