Nearly CC
An educational compiler skeleton
grammar_symbols.h
Go to the documentation of this file.
1 #ifndef GRAMMAR_SYMBOLS_H
2 #define GRAMMAR_SYMBOLS_H
3 
4 #include "treeprint.h"
5 
13 
16  NODE_TOK_LPAREN = 258,
17  NODE_TOK_RPAREN,
18  NODE_TOK_LBRACKET,
19  NODE_TOK_RBRACKET,
20  NODE_TOK_LBRACE,
21  NODE_TOK_RBRACE,
22  NODE_TOK_SEMICOLON,
23  NODE_TOK_COLON,
24  NODE_TOK_COMMA,
25  NODE_TOK_DOT,
26  NODE_TOK_QUESTION,
27  NODE_TOK_NOT,
28  NODE_TOK_ARROW,
29  NODE_TOK_PLUS,
30  NODE_TOK_INCREMENT,
31  NODE_TOK_MINUS,
32  NODE_TOK_DECREMENT,
33  NODE_TOK_ASTERISK,
34  NODE_TOK_DIVIDE,
35  NODE_TOK_MOD,
36  NODE_TOK_AMPERSAND,
37  NODE_TOK_BITWISE_OR,
38  NODE_TOK_BITWISE_XOR,
39  NODE_TOK_BITWISE_COMPL,
40  NODE_TOK_LEFT_SHIFT,
41  NODE_TOK_RIGHT_SHIFT,
42  NODE_TOK_LOGICAL_AND,
43  NODE_TOK_LOGICAL_OR,
44  NODE_TOK_EQUALITY,
45  NODE_TOK_INEQUALITY,
46  NODE_TOK_LT,
47  NODE_TOK_LTE,
48  NODE_TOK_GT,
49  NODE_TOK_GTE,
50  NODE_TOK_ASSIGN,
51  NODE_TOK_MUL_ASSIGN,
52  NODE_TOK_DIV_ASSIGN,
53  NODE_TOK_MOD_ASSIGN,
54  NODE_TOK_ADD_ASSIGN,
55  NODE_TOK_SUB_ASSIGN,
56  NODE_TOK_LEFT_ASSIGN,
57  NODE_TOK_RIGHT_ASSIGN,
58  NODE_TOK_AND_ASSIGN,
59  NODE_TOK_XOR_ASSIGN,
60  NODE_TOK_OR_ASSIGN,
61  NODE_TOK_IF,
62  NODE_TOK_ELSE,
63  NODE_TOK_WHILE,
64  NODE_TOK_FOR,
65  NODE_TOK_DO,
66  NODE_TOK_SWITCH,
67  NODE_TOK_CASE,
68  NODE_TOK_CHAR,
69  NODE_TOK_SHORT,
70  NODE_TOK_INT,
71  NODE_TOK_LONG,
72  NODE_TOK_UNSIGNED,
73  NODE_TOK_SIGNED,
74  NODE_TOK_FLOAT,
75  NODE_TOK_DOUBLE,
76  NODE_TOK_VOID,
77  NODE_TOK_RETURN,
78  NODE_TOK_BREAK,
79  NODE_TOK_CONTINUE,
80  NODE_TOK_CONST,
81  NODE_TOK_VOLATILE,
82  NODE_TOK_STRUCT,
83  NODE_TOK_UNION,
84  NODE_TOK_UNSPECIFIED_STORAGE,
85  NODE_TOK_STATIC,
86  NODE_TOK_EXTERN,
87  NODE_TOK_AUTO,
88  NODE_TOK_IDENT,
89  NODE_TOK_STR_LIT,
90  NODE_TOK_CHAR_LIT,
91  NODE_TOK_INT_LIT,
92  NODE_TOK_FP_LIT,
93  NODE_unit = 1000,
94  NODE_top_level_declaration,
95  NODE_function_or_variable_declaration_or_definition,
96  NODE_simple_variable_declaration,
97  NODE_declarator_list,
98  NODE_declarator,
99  NODE_non_pointer_declarator,
100  NODE_function_definition_or_declaration,
101  NODE_function_parameter_list,
102  NODE_opt_parameter_list,
103  NODE_parameter_list,
104  NODE_parameter,
105  NODE_type,
106  NODE_basic_type,
107  NODE_basic_type_keyword,
108  NODE_opt_statement_list,
109  NODE_statement_list,
110  NODE_statement,
111  NODE_struct_type_definition,
112  NODE_union_type_definition,
113  NODE_opt_simple_variable_declaration_list,
114  NODE_simple_variable_declaration_list,
115  NODE_assignment_expression,
116  NODE_assignment_op,
117  NODE_conditional_expression,
118  NODE_logical_or_expression,
119  NODE_logical_and_expression,
120  NODE_bitwise_or_expression,
121  NODE_bitwise_xor_expression,
122  NODE_bitwise_and_expression,
123  NODE_equality_expression,
124  NODE_relational_expression,
125  NODE_relational_op,
126  NODE_shift_expression,
127  NODE_additive_expression,
128  NODE_multiplicative_expression,
129  NODE_cast_expression,
130  NODE_unary_expression,
131  NODE_postfix_expression,
132  NODE_argument_expression_list,
133  NODE_primary_expression,
134 };
135 
143 const char *get_grammar_symbol_name(int tag);
144 
146 class ParseTreePrint : public TreePrint {
147 public:
148  ParseTreePrint();
149  ~ParseTreePrint();
150 
155  virtual std::string node_tag_to_string(int tag) const;
156 };
157 
158 #endif // GRAMMAR_SYMBOLS_H
Print a parse tree.
Definition: grammar_symbols.h:146
virtual std::string node_tag_to_string(int tag) const
Override to convert a parse node's tag to a string.
Definition: grammar_symbols.cpp:154
Definition: treeprint.h:27
GrammarSymbol
Grammar symbol enumeration.
Definition: grammar_symbols.h:15
const char * get_grammar_symbol_name(int tag)
Get grammar symbol name corresponding to tag (enumeration value).
Definition: grammar_symbols.cpp:126