%% Tiny -> Outer (FuncDef)+ => "program"; Codeblock -> '{' (Statement)* '}' => "block"; Outer -> -> Outer Var ';' -> Outer Typedef ; Typedef -> TYPEDEF Name Name ';' => "type"; FuncDef -> Name Name '(' ')' Codeblock => "func" -> Name Name '(' NameList ')' (Var ';')* Codeblock => "funcold" -> Name Name '(' DefParam list ',' ')' Codeblock => "func"; DefParam -> Name Name => "var"; NameList -> Name list ',' ; Statement -> Var ';' -> Assign ';' -> Expression ';' -> IF '(' Expression ')' Statement (ELSE Statement)? => "if" -> IF '(' Assign ')' Statement (ELSE Statement)? => "if" -> Codeblock -> PRINTF '(' String (',' Expression)* ')' ';' => "printf" -> SCANF '(' String (',' '&' Name)* ')' ';' => "scanf" -> WHILE '(' Expression ')' Statement => "while" -> DO Statement WHILE '(' Expression ')' ';' => "do" -> FOR '(' Statement Statement Assign ')' Statement => "for" -> FOR '(' Statement Statement Expression ')' Statement => "for" -> FOR '(' Statement Statement Null ')' Statement => "for" -> SWITCH '(' Expression ')' '{' (CaseClause)+ (DefaultClause)? '}' => "switch" -> BREAK ';' => "break" -> CONTINUE ';' => "continue" -> RETURNX ';' => "return" -> RETURNX Expression ';' => "return" -> Null ';' ; FuncCall -> Name '(' ')' => "call" -> Name '(' Params ')' => "call" ; Params -> Param list ',' => "params"; Param -> Assign -> Expression ; CaseClause -> CASE Expression ':' (Statement)* => "case"; DefaultClause-> DEFAULT ':' (Statement)+ => "default"; Assign -> Element '=' Param => "=" -> Element PEQ Param => "+=" -> Element SEQ Param => "-=" -> Element TEQ Param => "*=" -> Element DEQ Param => "/=" -> Element MEQ Param => "%=" -> Element AEQ Param => "&=" -> Element OEQ Param => "|=" -> Element XEQ Param => "^="; Var -> Name VarList => "var" -> CONST Name VarList => "const"; VarList -> Element -> Assign -> VarList ',' Element -> VarList ',' Assign ; Element -> Name '[' Expression ']' => "[]" -> Name ; Expression -> Exp1 '?' Exp1 ':' Exp1 => "?:" -> Exp1 ; Exp1 -> Exp2 LOR Exp1 => "|" -> Exp2 ; Exp2 -> Exp3 LAND Exp2 => "&" -> Exp3 ; Exp3 -> Exp4 '|' Exp3 => "|" -> Exp4 ; Exp4 -> Exp5 '^' Exp4 => "^" -> Exp5 ; Exp5 -> Exp6 '&' Exp5 => "&" -> Exp6 ; Exp6 -> Exp7 EQ Exp6 => "==" -> Exp7 NE Exp6 => "!=" -> Exp7 ; Exp7 -> Exp8 '<' Exp7 => "<" -> Exp8 '>' Exp7 => ">" -> Exp8 LTE Exp7 => "<=" -> Exp8 GTE Exp7 => ">=" -> Exp8 ; Exp8 -> Exp9 '+' Exp8 => "+" -> Exp9 '-' Exp8 => "-" -> Exp9 ; Exp9 -> Exp10 '*' Exp9 => "*" -> Exp10 '/' Exp9 => "/" -> Exp10 '%' Exp9 => "%" -> Exp10 ; Exp10 -> '!' Exp11 => "!" -> Exp11 INC Null => "++" -> Exp11 DEC Null => "--" -> INC Exp11 => "++" -> DEC Exp11 => "--" -> '+' Exp11 -> '-' Exp11 => "-" -> Exp11 ; Exp11 -> '(' Name ')' Exp12 => "" -> Exp12 ; Exp12 -> Integer -> Char -> Element -> Float -> '(' Assign ')' -> '(' Expression ')' -> FuncCall ; Null -> => ""; Integer -> INTEGER_LIT => ""; Char -> CHAR_LIT => ""; Float -> FLOAT_LIT => ""; Name -> IDENTIFIER => ""; String -> STRING => "";