From 2f04c63163d05406b3e3a81bfa87ff5192f9d66f Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Tue, 21 Jul 2020 23:06:54 +0900 Subject: [PATCH] grammar: Add production rules for grammatical structures on pages 297, 298 of "The C Programming Language, 2nd Edition" --- src/grammar.c | 1292 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 1291 insertions(+), 1 deletion(-) diff --git a/src/grammar.c b/src/grammar.c index e0eb852..0722685 100644 --- a/src/grammar.c +++ b/src/grammar.c @@ -1024,6 +1024,1296 @@ static struct rule *_type_qualifier_list_productions[] = { NULL }; +static struct rule _parameter_type_list_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_PARAMETER_LIST, + .name = "parameter-list" + }, { + 0 + } +}; + +static struct rule _parameter_type_list_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_PARAMETER_LIST, + .name = "parameter-list" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_COMMA, + .name = "comma" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_DOTS, + .name = "dots" + }, { + 0 + } +}; + +static struct rule *_parameter_type_list_productions[] = { + _parameter_type_list_production_A, + _parameter_type_list_production_B, + NULL +}; + +static struct rule _parameter_list_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_PARAMETER_DECLARATION, + .name = "parameter-declaration" + }, { + 0 + } +}; + +static struct rule _parameter_list_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_PARAMETER_LIST, + .name = "parameter-list" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_COMMA, + .name = "comma" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_PARAMETER_DECLARATION, + .name = "parameter-declaration" + }, { + 0 + } +}; + +static struct rule *_parameter_list_productions[] = { + _parameter_list_production_A, + _parameter_list_production_B, + NULL +}; + +static struct rule _parameter_declaration_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_DECLARATION_SPECIFIERS, + .name = "declaration-specifiers" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_DECLARATOR, + .name = "declarator" + }, { + 0 + } +}; + +static struct rule _parameter_declaration_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_DECLARATION_SPECIFIERS, + .name = "declaration-specifiers" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_ABSTRACT_DECLARATOR, + .flags = RULE_FLAG_OPTIONAL, + .name = "abstract-declarator" + }, { + 0 + } +}; + +static struct rule *_parameter_declaration_productions[] = { + _parameter_declaration_production_A, + _parameter_declaration_production_B, + NULL +}; + +static struct rule _identifier_production_A[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_IDENTIFIER, + .name = "identifier" + }, { + 0 + } +}; + +static struct rule *_identifier_productions[] = { + _identifier_production_A, + NULL +}; + +static struct rule _identifier_list_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_IDENTIFIER, + .name = "identifier" + }, { + 0 + } +}; + +static struct rule _identifier_list_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_IDENTIFIER_LIST, + .name = "identifier-list" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_COMMA, + .name = "comma" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_IDENTIFIER, + .name = "identifier" + }, { + 0 + } +}; + +static struct rule *_identifier_list_productions[] = { + _identifier_list_production_A, + _identifier_list_production_B, + NULL +}; + +static struct rule _initializer_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_ASSIGNMENT_EXPRESSION, + .name = "assignment-expression" + }, { + 0 + } +}; + +static struct rule _initializer_production_B[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_LBRACE, + .name = "lbrace" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_INITIALIZER_LIST, + .name = "initializer-list" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_RBRACE, + .name = "rbrace" + }, { + 0 + } +}; + +static struct rule _initializer_production_C[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_LBRACE, + .name = "lbrace" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_INITIALIZER_LIST, + .name = "initializer-list" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_COMMA, + .name = "comma" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_RBRACE, + .name = "rbrace" + }, { + 0 + } +}; + +static struct rule *_initializer_productions[] = { + _initializer_production_A, + _initializer_production_B, + _initializer_production_C, + NULL +}; + +static struct rule _initializer_list_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_INITIALIZER, + .name = "initializer" + }, { + 0 + } +}; + +static struct rule _initializer_list_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_INITIALIZER_LIST, + .name = "initializer-list" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_COMMA, + .name = "comma" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_INITIALIZER, + .name = "initializer" + }, { + 0 + } +}; + +static struct rule *_initializer_list_productions[] = { + _initializer_list_production_A, + _initializer_list_production_B, + NULL +}; + +static struct rule _type_name_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_SPECIFIER_QUALIFIER_LIST, + .name = "specifier-qualifier-list" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_ABSTRACT_DECLARATOR, + .flags = RULE_FLAG_OPTIONAL, + .name = "abstract-declarator" + }, { + 0 + } +}; + +static struct rule *_type_name_productions[] = { + _type_name_production_A, + NULL +}; + +static struct rule _abstract_declarator_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_POINTER, + .name = "pointer" + }, { + 0 + } +}; + +static struct rule _abstract_declarator_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_POINTER, + .flags = RULE_FLAG_OPTIONAL, + .name = "pointer" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_DIRECT_ABSTRACT_DECLARATOR, + .name = "direct-abstract-declarator" + }, { + 0 + } +}; + +static struct rule *_abstract_declarator_productions[] = { + _abstract_declarator_production_A, + _abstract_declarator_production_B, + NULL +}; + +static struct rule _direct_abstract_declarator_production_A[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_LPAREN, + .name = "lparen" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_ABSTRACT_DECLARATOR, + .name = "abstract-declarator", + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_RPAREN, + .name = "rparen" + }, { + 0 + } +}; + +static struct rule _direct_abstract_declarator_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_DIRECT_ABSTRACT_DECLARATOR, + .flags = RULE_FLAG_OPTIONAL, + .name = "direct-abstract-declarator" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_LBRACKET, + .name = "lbracket" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_CONSTANT_EXPRESSION, + .flags = RULE_FLAG_OPTIONAL, + .name = "constant-expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_RBRACKET, + .name = "rbracket" + }, { + 0 + } +}; + +static struct rule _direct_abstract_declarator_production_C[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_DIRECT_ABSTRACT_DECLARATOR, + .flags = RULE_FLAG_OPTIONAL, + .name = "direct-abstract-declarator" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_LPAREN, + .name = "lparen" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_PARAMETER_TYPE_LIST, + .flags = RULE_FLAG_OPTIONAL, + .name = "parameter-type-list" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_RPAREN, + .name = "rparen" + }, { + 0 + } +}; + +static struct rule *_direct_abstract_declarator_productions[] = { + _direct_abstract_declarator_production_A, + _direct_abstract_declarator_production_B, + _direct_abstract_declarator_production_C, + NULL +}; + +static struct rule _typedef_name_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_IDENTIFIER, + .name = "identifier" + }, { + 0 + } +}; + +static struct rule *_typedef_name_productions[] = { + _typedef_name_production_A, + NULL +}; + +static struct rule _statement_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_LABELED_STATEMENT, + .name = "labeled-statement" + }, { + 0 + } +}; + +static struct rule _statement_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EXPRESSION_STATEMENT, + .name = "expression-statement" + }, { + 0 + } +}; + +static struct rule _statement_production_C[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_COMPOUND_STATEMENT, + .name = "compound-statement" + }, { + 0 + } +}; + +static struct rule _statement_production_D[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_SELECTION_STATEMENT, + .name = "selection-statement" + }, { + 0 + } +}; + +static struct rule _statement_production_E[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_ITERATION_STATEMENT, + .name = "iteration-statement" + }, { + 0 + } +}; + +static struct rule _statement_production_F[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_JUMP_STATEMENT, + .name = "jump-statement" + }, { + 0 + } +}; + +static struct rule *_statement_productions[] = { + _statement_production_A, + _statement_production_B, + _statement_production_C, + _statement_production_D, + _statement_production_E, + _statement_production_F, + NULL +}; + +static struct rule _labeled_statement_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_IDENTIFIER, + .name = "identifier" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_COLON, + .name = "colon" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_STATEMENT, + .name = "statement" + }, { + 0 + } +}; + +static struct rule _labeled_statement_production_B[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_CASE, + .name = "case" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_CONSTANT_EXPRESSION, + .name = "constant-expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_COLON, + .name = "colon" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_STATEMENT, + .name = "statement" + }, { + 0 + } +}; + +static struct rule _labeled_statement_production_C[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_DEFAULT, + .name = "default" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_COLON, + .name = "colon" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_STATEMENT, + .name = "statement" + }, { + 0 + } +}; + +static struct rule *_labeled_statement_productions[] = { + _labeled_statement_production_A, + _labeled_statement_production_B, + _labeled_statement_production_C, + NULL +}; + +static struct rule _expression_statement_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EXPRESSION, + .flags = RULE_FLAG_OPTIONAL, + .name = "expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_SEMICOLON, + .name = "semicolon" + }, { + 0 + } +}; + +static struct rule *_expression_statement_productions[] = { + _expression_statement_production_A, + NULL +}; + +static struct rule _compound_statement_production_A[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_LBRACE, + .name = "lbrace" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_DECLARATION_LIST, + .flags = RULE_FLAG_OPTIONAL, + .name = "declaration-list" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_STATEMENT_LIST, + .flags = RULE_FLAG_OPTIONAL, + .name = "statement-list" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_RBRACE, + .name = "rbrace" + }, { + 0 + } +}; + +static struct rule *_compound_statement_productions[] = { + _compound_statement_production_A, + NULL +}; + +static struct rule _statement_list_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_STATEMENT, + .name = "statement" + }, { + 0 + } +}; + +static struct rule _statement_list_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_STATEMENT_LIST, + .name = "statement-list" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_STATEMENT, + .name = "statement" + }, { + 0 + } +}; + +static struct rule *_statement_list_productions[] = { + _statement_list_production_A, + _statement_list_production_B, + NULL +}; + +static struct rule _selection_statement_production_A[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_IF, + .name = "if" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_LPAREN, + .name = "lparen" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EXPRESSION, + .name = "expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_RPAREN, + .name = "rparen" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_STATEMENT, + .name = "statement" + }, { + 0 + } +}; + +static struct rule _selection_statement_production_B[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_IF, + .name = "if" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_LPAREN, + .name = "lparen" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EXPRESSION, + .name = "expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_RPAREN, + .name = "rparen" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_STATEMENT, + .name = "true-statement" + },{ + .type = RULE_TERMINAL, + .terminal = TOKEN_ELSE, + .name = "else" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_STATEMENT, + .name = "false-statement" + }, { + 0 + } +}; + +static struct rule _selection_statement_production_C[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_SWITCH, + .name = "switch" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_LPAREN, + .name = "lparen" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EXPRESSION, + .name = "expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_RPAREN, + .name = "rparen" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_STATEMENT, + .name = "statement" + }, { + 0 + } +}; + +static struct rule *_selection_statement_productions[] = { + _selection_statement_production_A, + _selection_statement_production_B, + _selection_statement_production_C, + NULL +}; + +static struct rule _iteration_statement_production_A[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_WHILE, + .name = "while" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_LPAREN, + .name = "lparen" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EXPRESSION, + .name = "expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_RPAREN, + .name = "rparen" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_STATEMENT, + .name = "statement" + }, { + 0 + } +}; + +static struct rule _iteration_statement_production_B[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_DO, + .name = "do" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_STATEMENT, + .name = "statement" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_LPAREN, + .name = "lparen" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EXPRESSION, + .name = "expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_RPAREN, + .name = "rparen" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_SEMICOLON, + .name = "semicolon" + }, { + 0 + } +}; + +static struct rule _iteration_statement_production_C[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_FOR, + .name = "for" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_LPAREN, + .name = "lparen" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EXPRESSION, + .flags = RULE_FLAG_OPTIONAL, + .name = "expression_A" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_SEMICOLON, + .name = "semicolon_A" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EXPRESSION, + .flags = RULE_FLAG_OPTIONAL, + .name = "expression_B" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_SEMICOLON, + .name = "semicolon_B" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EXPRESSION, + .flags = RULE_FLAG_OPTIONAL, + .name = "expression_C" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_RPAREN, + .name = "rparen" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_STATEMENT, + .name = "statement" + }, { + 0 + } +}; + +static struct rule *_iteration_statement_productions[] = { + _iteration_statement_production_A, + _iteration_statement_production_B, + _iteration_statement_production_C, + NULL +}; + +static struct rule _jump_statement_production_A[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_GOTO, + .name = "goto" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_IDENTIFIER, + .name = "identifier" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_SEMICOLON, + .name = "semicolon" + }, { + 0 + } +}; + +static struct rule _jump_statement_production_B[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_CONTINUE, + .name = "continue" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_SEMICOLON, + .name = "semicolon" + }, { + 0 + } +}; + +static struct rule _jump_statement_production_C[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_BREAK, + .name = "break" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_SEMICOLON, + .name = "semicolon" + }, { + 0 + } +}; + +static struct rule _jump_statement_production_D[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_RETURN, + .name = "return" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EXPRESSION, + .flags = RULE_FLAG_OPTIONAL, + .name = "expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_SEMICOLON, + .name = "semicolon" + }, { + 0 + } +}; + +static struct rule *_jump_statement_productions[] = { + _jump_statement_production_A, + _jump_statement_production_B, + _jump_statement_production_C, + _jump_statement_production_D, + NULL +}; + +static struct rule _expression_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_ASSIGNMENT_EXPRESSION, + .name = "assignment-expression" + }, { + 0 + } +}; + +static struct rule _expression_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EXPRESSION, + .name = "expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_COLON, + .name = "colon" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_ASSIGNMENT_EXPRESSION, + .name = "assignment-expression" + }, { + 0 + } +}; + +static struct rule *_expression_productions[] = { + _expression_production_A, + _expression_production_B, + NULL +}; + +static struct rule _assignment_expression_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_CONDITIONAL_EXPRESSION, + .name = "conditional-expression" + }, { + 0 + } +}; + +static struct rule _assignment_expression_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_UNARY_EXPRESSION, + .name = "unary-expression" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_ASSIGNMENT_OPERATOR, + .name = "assignment-operator" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_ASSIGNMENT_EXPRESSION, + .name = "assignment-expression" + }, { + 0 + } +}; + +static struct rule *_assignment_expression_productions[] = { + _assignment_expression_production_A, + _assignment_expression_production_B, + NULL +}; + +static struct rule _assignment_operator_production_A[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_ASSIGN, + .name = "op" + }, { + 0 + } +}; + +static struct rule _assignment_operator_production_B[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_ASSIGN_MUL, + .name = "op" + }, { + 0 + } +}; + +static struct rule _assignment_operator_production_C[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_ASSIGN_DIV, + .name = "op" + }, { + 0 + } +}; + +static struct rule _assignment_operator_production_D[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_ASSIGN_MOD, + .name = "op" + }, { + 0 + } +}; + +static struct rule _assignment_operator_production_E[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_ASSIGN_ADD, + .name = "op" + }, { + 0 + } +}; + +static struct rule _assignment_operator_production_F[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_ASSIGN_SUB, + .name = "op" + }, { + 0 + } +}; + +static struct rule _assignment_operator_production_G[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_ASSIGN_SHL, + .name = "op" + }, { + 0 + } +}; + +static struct rule _assignment_operator_production_H[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_ASSIGN_SHR, + .name = "op" + }, { + 0 + } +}; + +static struct rule _assignment_operator_production_I[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_ASSIGN_AND, + .name = "op" + }, { + 0 + } +}; + +static struct rule _assignment_operator_production_J[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_ASSIGN_XOR, + .name = "op" + }, { + 0 + } +}; + +static struct rule _assignment_operator_production_K[] = { + { + .type = RULE_TERMINAL, + .terminal = TOKEN_ASSIGN_OR, + .name = "op" + }, { + 0 + } +}; + +static struct rule *_assignment_operator_productions[] = { + _assignment_operator_production_A, + _assignment_operator_production_B, + _assignment_operator_production_C, + _assignment_operator_production_D, + _assignment_operator_production_E, + _assignment_operator_production_F, + _assignment_operator_production_G, + _assignment_operator_production_H, + _assignment_operator_production_I, + _assignment_operator_production_J, + _assignment_operator_production_K, + NULL +}; + +static struct rule _conditional_expression_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_LOGICAL_OR_EXPRESSION, + .name = "logical-or-expression" + }, { + 0 + } +}; + +static struct rule _conditional_expression_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_LOGICAL_OR_EXPRESSION, + .name = "logical-or-expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_QMARK, + .name = "qmark" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EXPRESSION, + .name = "expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_COLON, + .name = "colon" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_CONDITIONAL_EXPRESSION, + .name = "conditional-expression" + }, { + 0 + } +}; + +static struct rule *_conditional_expression_productions[] = { + _conditional_expression_production_A, + _conditional_expression_production_B, + NULL +}; + +static struct rule _constant_expression_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_CONDITIONAL_EXPRESSION, + .name = "conditional-expression" + }, { + 0 + } +}; + +static struct rule *_constant_expression_productions[] = { + _constant_expression_production_A, + NULL +}; + +static struct rule _logical_or_expression_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_LOGICAL_AND_EXPRESSION, + .name = "logical-and-expression" + }, { + 0 + } +}; + +static struct rule _logical_or_expression_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_LOGICAL_OR_EXPRESSION, + .name = "logical-or-expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_LOR, + .name = "op" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_LOGICAL_AND_EXPRESSION, + .name = "logical-and-expression" + }, { + 0 + } +}; + +static struct rule *_logical_or_expression_productions[] = { + _logical_or_expression_production_A, + _logical_or_expression_production_B, + NULL +}; + +static struct rule _logical_and_expression_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_INCLUSIVE_OR_EXPRESSION, + .name = "inclusive-or-expression" + }, { + 0 + } +}; + +static struct rule _logical_and_expression_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_LOGICAL_AND_EXPRESSION, + .name = "logical-and-expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_LAND, + .name = "op" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_INCLUSIVE_OR_EXPRESSION, + .name = "inclusive-or-expression" + }, { + 0 + } +}; + +static struct rule *_logical_and_expression_productions[] = { + _logical_and_expression_production_A, + _logical_and_expression_production_B, + NULL +}; + +static struct rule _inclusive_or_expression_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EXCLUSIVE_OR_EXPRESSION, + .name = "exclusive-or-expression" + }, { + 0 + } +}; + +static struct rule _inclusive_or_expression_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_INCLUSIVE_OR_EXPRESSION, + .name = "inclusive-or-expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_OR, + .name = "op" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EXCLUSIVE_OR_EXPRESSION, + .name = "exclusive-or-expression" + }, { + 0 + } +}; + +static struct rule *_inclusive_or_expression_productions[] = { + _inclusive_or_expression_production_A, + _inclusive_or_expression_production_B, + NULL +}; + +static struct rule _exclusive_or_expression_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_AND_EXPRESSION, + .name = "and-expression" + }, { + 0 + } +}; + +static struct rule _exclusive_or_expression_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EXCLUSIVE_OR_EXPRESSION, + .name = "exclusive-or-expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_XOR, + .name = "op" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_AND_EXPRESSION, + .name = "and-expression" + }, { + 0 + } +}; + +static struct rule *_exclusive_or_expression_productions[] = { + _exclusive_or_expression_production_A, + _exclusive_or_expression_production_B, + NULL +}; + +static struct rule _and_expression_production_A[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EQUALITY_EXPRESSION, + .name = "equality-expression" + }, { + 0 + } +}; + +static struct rule _and_expression_production_B[] = { + { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_AND_EXPRESSION, + .name = "and-expression" + }, { + .type = RULE_TERMINAL, + .terminal = TOKEN_AND, + .name = "op" + }, { + .type = RULE_NONTERMINAL, + .nonterminal = SYNTAX_NODE_EQUALITY_EXPRESSION, + .name = "equality-expression" + }, { + 0 + } +}; + +static struct rule *_and_expression_productions[] = { + _and_expression_production_A, + _and_expression_production_B, + NULL +}; + static struct syntax_node_descriptor _node_descriptors[] = { /* order needs to be in sync with syntax_node_type_t */ { @@ -1116,7 +2406,7 @@ static struct syntax_node_descriptor _node_descriptors[] = { .productions = _parameter_declaration_productions }, { .type = SYNTAX_NODE_IDENTIFIER, - .parse = identifier_parse + .productions = _identifier_productions }, { .type = SYNTAX_NODE_IDENTIFIER_LIST, .productions = _identifier_list_productions -- 2.47.3