register(expr_grammar=""" typeid = TYPEID OPEN_PAR type_id CLOSE_PAR cpp_cast = cast_op INF type_id SUP cast_op = CONST_CAST | DYNAMIC_CAST | STATIC_CAST | REINTERPRET_CAST int_const = int_dec | int_oct | int_hex float_const = number -expr_0 = int_const | float_const | string | char | expr_p1 expr_0 = OPEN_PAR expr_any CLOSE_PAR expr_p1 = expr_p1 SCOPE id | id | SCOPE id id = symbol opt_specialization -expr_p2 = expr_0 expr_p2 = expr_p2 INC | expr_p2 DEC | expr_p2 subscript | expr_p2 call | field_resolution | typeid | cpp_cast call field_resolution = dot_arrow expr_p1 dot_arrow = expr_p2 DOT | expr_p2 ARROW subscript = OPEN_SQ expr CLOSE_SQ | OPEN_SQ CLOSE_SQ call = OPEN_PAR expr_list CLOSE_PAR | OPEN_PAR CLOSE_PAR -expr_p3 = expr_p2 expr_p3 = INC expr_p3 | DEC expr_p3 | PLUS expr_p3 | MINUS expr_p3 | EXCLAMATION expr_p3 | TILDE expr_p3 | OPEN_PAR type_id CLOSE_PAR expr_p3 | STAR expr_p3 | AMPERSAND expr_p3 | SIZEOF OPEN_PAR any_type CLOSE_PAR | NEW expr_p3 | DELETE expr_p3 | DELETE OPEN_SQ CLOSE_SQ expr_p3 -expr_p4 = expr_p3 expr_p4 = expr_p4 DOT_STAR id | expr_p4 ARROW_STAR id -expr_p5 = expr_p4 expr_p5 = expr_p5 STAR expr_p4 | expr_p5 SLASH expr_p4 | expr_p5 PERCENT expr_p4 -expr_p6 = expr_p5 expr_p6 = expr_p6 PLUS expr_p5 | expr_p6 MINUS expr_p5 -expr_p7 = expr_p6 expr_p7 = expr_p7 SHR expr_p6 | expr_p7 SHL expr_p6 -expr_p8 = expr_p7 expr_p8 = expr_p8 INF expr_p7 | expr_p8 LE expr_p7 | expr_p8 SUP expr_p7 | expr_p8 GE expr_p7 -expr_p9 = expr_p8 expr_p9 = expr_p9 EQ expr_p8 | expr_p9 NE expr_p8 -expr_p10 = expr_p9 expr_p10 = expr_p10 AMPERSAND expr_p9 -expr_p11 = expr_p10 expr_p11 = expr_p11 CIRCONFLEX expr_p10 -expr_p12 = expr_p11 expr_p12 = expr_p12 PIPE expr_p11 -expr_p13 = expr_p12 expr_p13 = expr_p13 LOG_AND expr_p12 -expr_p14 = expr_p13 expr_p14 = expr_p14 LOG_OR expr_p13 -expr_p15 = expr_p14 expr_p15 = expr_p14 QUESTION expr_p15 COLON expr_p15 expr_p15 = expr_p14 QUESTION expr_p17 COLON expr_p15 expr_p15 = expr_p14 QUESTION expr_p15 COLON expr_p17 -expr_p16 = expr_p15 expr_p16 = expr_p15 EQUAL expr_p16 | expr_p15 ASS_OP expr_p16 -expr_p17 = expr_p16 expr_p17 = THROW expr_p16 -expr_p18 = expr_p17 -expr_p18 = expr_p16 expr_p18 = expr_p18 COMMA expr_p17 -expr_no_comma = expr_p17 -expr_any = expr_p18 -expr = expr_p16 -expr_list_opt = expr_list | expr_list = expr_list COMMA expr_no_comma | expr_no_comma """)
register(id_grammar=""" _ASSERT_VAR = any_path _ASSERT_TYPE = any_path _ASSERT_CONST = any_path _ASSERT_FUNC = any_path _ASSERT_TEMPLATE_TYPE = INF _SEARCH_FROM_ROOT = SCOPE _SEARCH_FROM_HERE = symbol ID = symbol OPT_ID =| symbol NAMESPACE_NAME = symbol TEMPLATE_TYPE = symbol _ASSERT_TEMPLATE_TYPE template_expr_list SUP TYPE = symbol template_expr_list = template_expr_list COMMA template_expr | template_expr template_expr = any_type | expr -any_type = type_or_pointer_type | ref_to_type ref_to_type = type_id AMPERSAND type_or_pointer_type = type_or_pointer_type STAR -type_or_pointer_type = type_id | builtin_type container = NAMESPACE_NAME | TEMPLATE_TYPE | TYPE var_id = _ASSERT_VAR const_id = _ASSERT_CONST type_id = _ASSERT_TYPE opt_specialization | builtin_type -builtin_type = builtin_Int | builtin_UnsignedInt | builtin_ShortInt | builtin_UnsignedShortInt | builtin_LongInt | builtin_UnsignedLongInt | builtin_LongLongInt | builtin_UnsignedLongLongInt | builtin_Float | builtin_Double | builtin_LongDouble | builtin_Char | builtin_UnsignedChar | builtin_Bool | builtin_Wchar_t builtin_Int = INT | SIGNED | SIGNED INT builtin_UnsignedInt = UNSIGNED | UNSIGNED INT builtin_ShortInt = SHORT | SIGNED SHORT | SHORT SIGNED | SHORT INT | SIGNED SHORT INT | SHORT SIGNED INT builtin_UnsignedShortInt = UNSIGNED SHORT | UNSIGNED SHORT INT builtin_LongInt = LONG | LONG INT | SIGNED LONG | SIGNED LONG INT | LONG SIGNED INT | LONG SIGNED builtin_LongLongInt = LONG LONG | LONG LONG INT | SIGNED LONG LONG | SIGNED LONG LONG INT | LONG SIGNED LONG | LONG SIGNED LONG INT | LONG LONG SIGNED | LONG LONG SIGNED INT builtin_UnsignedLongInt = UNSIGNED LONG | UNSIGNED LONG INT | LONG UNSIGNED | LONG UNSIGNED INT builtin_UnsignedLongLongInt = UNSIGNED LONG LONG | UNSIGNED LONG LONG INT | LONG UNSIGNED LONG | LONG UNSIGNED LONG INT | LONG LONG UNSIGNED | LONG LONG UNSIGNED INT builtin_Float = FLOAT builtin_Double = DOUBLE builtin_LongDouble = LONG DOUBLE builtin_Char = CHAR | SIGNED CHAR builtin_UnsignedChar = UNSIGNED CHAR builtin_Wchar_t = WCHAR_T builtin_Bool = BOOL any_path = expr_p1 path = path SCOPE symbol | symbol """)
register( toplevel=""" _ASSERT_NEW_SYMBOL = symbol NAMESPACE_ENTER = symbol _FUNC_NAME = symbol LEAVE_SCOPE = CLOSE_CURLY _ENTER_STRUC = s_c_u symbol opt_bases OPEN_CURLY | s_c_u OPEN_CURLY _MARK_STRUC = s_c_u symbol | s_c_u -s_c_u = CLASS | STRUCT | UNION opt_bases =| COLON base_list -base_list = base_list base | base base = PUBLIC expr_p1 | PROTECTED expr_p1 | PRIVATE expr_p1 translation_unit =| tl_decl_list -tl_decl_list = tl_decl_list tl_decl | tl_decl -tl_decl = namespace_decl | func_decl | static_func_decl | const_decl | var_decl | static_var_decl | type_decl | extern_linkage | using_decl | preproc using_decl = USING NAMESPACE any_path SEMICOLON | USING any_path SEMICOLON sub_translation_unit = OPEN_CURLY translation_unit LEAVE_SCOPE namespace_decl = NAMESPACE NAMESPACE_ENTER gcc_attribute_opt sub_translation_unit -gcc_attribute_opt =| gcc_attribute extern_linkage = EXTERN string OPEN_CURLY translation_unit LEAVE_SCOPE | EXTERN string var_decl | EXTERN string func_decl """, func_decl=""" static_func_decl = STATIC func_decl func_decl = func_compile_spec func_signature opt_body | func_signature opt_body func_compile_spec = func_compile_spec_list -func_compile_spec_list = func_compile_spec_list func_compile_spec1 | func_compile_spec1 func_compile_spec1 = INLINE | EXTERN func_signature = func_type func_id OPEN_PAR func_param_list_opt CLOSE_PAR opt_cv_qualifier opt_throw_spec gcc_attribute_opt func_type = VOID | any_type opt_cv_qualifier =| CONST | VOLATILE | CONST VOLATILE opt_throw_spec =| THROW OPEN_PAR opt_type_list CLOSE_PAR opt_type_list =| type_list -type_list = type_list COMMA any_type | any_type func_ptr_signature = any_type OPEN_PAR opt_type STAR OPT_ID CLOSE_PAR OPEN_PAR func_param_list_opt CLOSE_PAR opt_type =| type_id func_id = _ASSERT_FUNC | _ASSERT_NEW_SYMBOL -func_param_list_opt =| func_param_list -func_param_list = func_param_list COMMA func_param | func_param func_param = any_type symbol opt_default | any_type | func_ptr_signature opt_default =| expr -opt_body = _FORWARD_DECL | _discard_curly opt_statement_list LEAVE_SCOPE _discard_curly = OPEN_CURLY """, var_const_decl=""" const_decl = CONST type_id symbol EQUAL expr SEMICOLON static_var_decl = STATIC var_decl | STATIC expr_p1 SEMICOLON | STATIC expr_p1 var_init SEMICOLON var_decl = var_type var_decl_list SEMICOLON | func_ptr_signature SEMICOLON var_type = type_id -var_decl_list = var_decl_list COMMA single_var_decl | single_var_decl single_var_decl = single_var | single_var EQUAL var_init -single_var_base = modifier symbol | symbol modifier = AMPERSAND | stars single_var = single_var subscript | single_var_base var_init = expr | OPEN_CURLY var_init_list CLOSE_CURLY -var_init_list = var_init_list COMMA var_init | var_init -stars = stars STAR | STAR """, type_decl=""" _FORWARD_DECL = SEMICOLON -type_decl = typedef | struc_type_decl opt_var_decl_list SEMICOLON | template_type_decl -opt_var_decl_list =| var_decl_list typedef = TYPEDEF struc_type_decl symbol SEMICOLON | TYPEDEF any_type symbol SEMICOLON struc_type_decl = _ENTER_STRUC translation_unit LEAVE_SCOPE | _MARK_STRUC template_type_decl_prefix = template_free_param_list leave_template_free_params template_free_param_list = template_free_param_list COMMA template_param_decl | enter_template_free_params template_param_decl | enter_template_free_params enter_template_free_params = TEMPLATE INF leave_template_free_params = SUP s_c_u symbol | SUP s_c_u specialization_decl = template_type_decl_prefix template_specialization -template_type_decl_base = template_type_decl_prefix | specialization_decl template_type_decl = template_type_decl_base _FORWARD_DECL | template_type_decl_base OPEN_CURLY translation_unit LEAVE_SCOPE -opt_template_param_decl_list =| template_param_decl_list -template_param_decl_list = template_param_decl_list COMMA template_param_decl | template_param_decl -template_param_decl = template_free_type | template_free_const template_free_type = TYPENAME opt_symbol opt_tp_default | CLASS opt_symbol opt_tp_default | STRUCT opt_symbol opt_tp_default | UNION opt_symbol opt_tp_default template_free_const = int_type opt_symbol opt_tp_default | CHAR opt_symbol opt_tp_default | BOOL opt_symbol opt_tp_default -opt_symbol =| symbol -opt_tp_default =| EQUAL template_param_inst -tp_kw = TYPENAME | CLASS | STRUCT | UNION | int_type -opt_specialization =| template_specialization -template_specialization = INF opt_template_param_inst_list SUP -opt_template_param_inst_list =| template_param_inst_list -template_param_inst_list = template_param_inst_list COMMA template_param_inst | template_param_inst template_param_inst = expr | any_type -opt_struc_body =| OPEN_CURLY translation_unit LEAVE_SCOPE """, gcc_attributes=""" gcc_attribute = ATTRIBUTE OPEN_PAR OPEN_PAR gcc_attribute_contents CLOSE_PAR CLOSE_PAR -gcc_attribute_contents = symbol | symbol OPEN_PAR gcc_attr_param_list CLOSE_PAR -gcc_attr_param_list = gcc_attr_param_list COMMA gcc_attr_param | gcc_attr_param gcc_attr_param = string | number preproc = hash int_dec preproc_suf -preproc_suf = preproc_suf int_dec | string """)
register(statements=""" _ENTER_LOCAL_SCOPE = OPEN_CURLY _LEAVE_LOCAL_SCOPE = CLOSE_CURLY condition = OPEN_PAR expr CLOSE_PAR statement = SEMICOLON | BREAK SEMICOLON | CONTINUE SEMICOLON | FOR OPEN_PAR expr_list SEMICOLON expr_list SEMICOLON expr_list CLOSE_PAR statement | IF condition statement | IF condition statement ELSE statement | SWITCH OPEN_PAR expr CLOSE_PAR compound_statement SEMICOLON | label | RETURN expr SEMICOLON | WHILE OPEN_PAR SEMICOLON expr_list CLOSE_PAR statement | compound_statement | var_decl | static_var_decl | expr SEMICOLON label = symbol COLON compound_statement = _ENTER_LOCAL_SCOPE opt_statement_list _LEAVE_LOCAL_SCOPE opt_statement_list =| statement_list statement_list = statement_list statement | statement """)