comments // /* */ end comments tokens hex "0[xX][\dAaBbCcDdEeFf]+[LUlu]*" dotfloat ".\d+([eE][+-]?\d+)?[FLfl]?" float "\d+.\d*([eE][+-]?\d+)?[FLfl]?" | "\d+(.\d*)?[eE][+-]?\d+[FLfl]?" | "\d+(.\d*)?([eE][+-]?\d+)?[FLfl]" long "\d+[LUlu]+" id | "\#\i+" end tokens keys auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while '#define '#else '#endif '#if '#ifdef '#ifndef '#include '#line '#undef '#indent '#LINK end keys compounds -> ++ -- << >> <= >= == != && || *= /= '%= += -= <<= >>= &= ^= |= end compounds define C_compilation_unit [repeat declaration_or_function_definition] end define define constant [number] | [float] | [hex] | [long] | [SP] [dotfloat] | [charlit] | [string] end define define string [repeat stringlit +] end define define expression [list assignment_expression +] end define define constant_expression [conditional_expression] end define define assignment_expression [conditional_expression] [opt assignment_operation] end define define assignment_operation [assignment_operator] [assignment_expression] end define define assignment_operator = | *= | /= | '%= | += | -= | >>= | <<= | &= | ^= | '|= end define define conditional_expression [binary_expression] [opt conditional_operation] end define define conditional_operation ? [expression] : [conditional_expression] end define define binary_expression [unary_expression] | [binary_expression] [binary_operator] [unary_expression] end define define binary_operator + | - | * | / | '% | == | != | < | > | <= | >= | '|| | && | '| | ^ | & | << | >> end define define unary_expression [postfix_expression] | [unary_operator] [SPOFF] [unary_expression] [SPON] | ( [type_name] ) [unary_expression] | [sizeof_expression] end define define sizeof_expression 'sizeof ( [type_name] ) | 'sizeof [unary_expression] end define define unary_operator * | & | + | - | ! | ~ | ++ | -- end define define postfix_expression [reference] | [nonreference] end define define reference [reference_id] | [reference_expression] end define define reference_id [id] end define define reference_expression [unannotated_reference_base] [repeat postfix_extension] end define define unannotated_reference_base [reference_id] | [nonreferential_primary] end define define nonreference [nonreferential_primary] [repeat postfix_extension] end define define nonreferential_primary [constant] | [string] | '( [expression] ') end define define postfix_extension '[ [expression] '] | '( [opt expression] ') | '. [id] | '-> [id] | '++ | '-- end define define declaration [declaration_body] [semi] | [preprocessor] end define define declaration_body [decl_specifiers] [list init_declarator +] | [enum_specifier] | [struct_or_union_specifier] end define define decl_specifiers [repeat decl_qualifier] [opt type_specifier] [repeat decl_qualifier] end define define struct_or_union_specifier [struct_or_union] [opt tagged_reference_id] { [IN] [NL] [repeat member_declaration] [EX] } | [struct_or_union] [tagged_reference_id] end define define tagged_reference_id [reference_id] end define define member_declaration [decl_specifiers] [list member_declarator +] [semi] | [preprocessor] end define define member_declarator [declarator] [opt bitfieldsize] | [bitfieldsize] end define define bitfieldsize ': [constant_expression] end define define decl_qualifier [sc_specifier] | [cv_qualifier] | [type_qualifier] end define define sc_specifier 'auto | 'register | 'static | 'extern | 'typedef end define define type_specifier [simple_type_name] | [enum_specifier] | [struct_or_union_specifier] end define define type_qualifier 'long | 'short | 'signed | 'unsigned end define define simple_type_name 'char | 'int | 'void | 'float | 'double | [type_id] end define define type_id [reference_id] end define define struct_or_union 'struct | 'union end define define enum_specifier 'enum [opt tagged_reference_id] { [list enumerator] } | 'enum [tagged_reference_id] end define define enumerator [reference_id] [opt enumerator_value] end define define enumerator_value = [constant_expression] end define define init_declarator [declarator] [opt initialization] end define define declarator [repeat ptr_operator] [base_declarator] [SPON] [repeat declarator_extension] end define define base_declarator [reference_id] | ( [declarator] ) end define define declarator_extension [function_declarator_extension] | [array_declarator_extension] end define define function_declarator_extension ( [argument_declaration_list] ) [repeat cv_qualifier] end define define array_declarator_extension '[ [opt constant_expression] '] end define define ptr_operator * [repeat cv_qualifier] [SPOFF] | ^ [repeat cv_qualifier] [SPOFF] end define define cv_qualifier 'const | 'volatile end define define type_name [type_specifiers] [opt abstract_declarator] end define define type_specifiers [repeat type_qualifier +] [opt type_specifier] [repeat type_qualifier] | [type_specifier] [repeat type_qualifier] end define define abstract_declarator [repeat ptr_operator +] [repeat declarator_extension] | ( [abstract_declarator] ) [repeat declarator_extension] end define define argument_declaration_list [list argument_declaration] end define define argument_declaration [decl_specifiers] [opt argument_declarator] | '... end define define argument_declarator [declarator] | [abstract_declarator] end define define initialization = [initializer] | ( [constant_expression] ) end define define initializer [expression] | [NL] { [IN] [list initializer] [opt ',] [EX] } end define define statement [repeat label] [unlabeled_statement] | [preprocessor] end define define label [label_id] ': | [EX] [SP] [SP] 'case [constant_expression] ': [IN] [NL] | [EX] [SP] [SP] 'default ': [IN] [NL] end define define label_id [id] end define define unlabeled_statement [expression_statement] | [if_statement] | [for_statement] | [while_statement] | [switch_statement] | [do_statement] | [null_statement] | [jump_statement] | [compound_statement] end define define null_statement [semi] end define define compound_statement { [IN] [NL] [compound_statement_body] } [opt ';] [NL] end define define compound_statement_body [repeat statement] [EX] | [declaration] [compound_statement_body] end define define expression_statement [expression] [semi] end define define if_statement 'if ( [expression] ) [statement] [opt else_statement] end define define switch_statement 'switch ( [expression] ) [statement] end define define else_statement 'else [statement] end define define while_statement 'while '( [expression] ') [statement] end define define do_statement 'do [statement] 'while ( [expression] ) [semi] end define define for_statement 'for ( [opt expression] '; [opt expression] '; [opt expression] ) [statement] end define define jump_statement 'goto [label_id] [semi] | 'continue [semi] | 'break [semi] | 'return [opt expression] [semi] end define define declaration_or_function_definition [declaration] | [function_definition] end define define function_definition [NL] [decl_specifiers] [declarator] [opt KR_parameter_decls] [compound_statement] [NL] end define define KR_parameter_decls [NL] [IN] [repeat declaration +] [EX] end define define semi '; [NL] end define define program [C_compilation_unit] end define define preprocessor '#define [id] '( [list id +] ') [expression] [NL] | '#define [id] [expression] [NL] | [EX] '#else [IN] [NL] | [EX] '#endif [NL] [NL] | [NL] '#if [expression] [IN] [NL] | [NL] '#ifdef [id] [IN] [NL] | [NL] '#ifndef [id] [IN] [NL] | '#ident [stringlit] [NL] | '#include [stringlit] [NL] | '#include < [SPOFF] [filepath] > [SPON] [NL] | '#line [integernumber] [opt stringlit] [NL] | '#undef [id] [NL] | '#LINK [stringlit] [NL] end define define filepath [file_id] [repeat slash_fileid] end define define file_id [id] | [key] end define define slash_fileid [slash] [file_id] end define define slash '/ | '\ | '. | ': end define keys __asm asm__ asm __asm__ __inline inline__ inline __inline__ __restrict restrict__ restrict __restrict__ __typeof__ __typeof typeof__ typeof __alignof__ __alignof __signed__ __signed __const __const__ const__ __volatile __volatile__ volatile__ __extension__ __attribute__ __label__ _Complex end keys tokens long "\d+[LUlu]+" hex "0[xX][\dAaBbCcDdEeFf]+(.\d*)?p\d+[FLfl]?" | "0[xX][\dAaBbCcDdEeFf]+[LUlu]*" stringlit "\"[(\\\c)#\"]*\"" | "__FUNCTION__" | "__PRETTY_FUNCTION__" | "__func__" float "\d+.\d*([eE][+-]?\d+)?[FLfl]?" | "\d+(.\d*)?[eE][+-]?\d+[FLfl]?" | "\d+(.\d*)?([eE][+-]?\d+)?[FLfl]" id "[\u$][\i$]*" | "\#\i+" end tokens redefine type_specifiers [repeat type_qualifier] [type_specifier] [repeat type_qualifier] | [repeat type_qualifier] end redefine redefine declaration [null_declaration] | [declaration_body] [semi] | [preprocessor] end redefine define null_declaration [semi] end define redefine declaration_body [decl_specifiers] [list init_declarator +] | [repeat decl_qualifier] [struct_or_union_specifier] | [repeat decl_qualifier] [enum_specifier] [repeat attribute_spec] | [local_label] [list declarator +] | [asm_spec] end redefine redefine decl_specifiers [repeat decl_qualifier] [type_specifier] [repeat decl_qualifier] | [repeat decl_qualifier] end redefine redefine init_declarator [declarator] [opt initialization] [repeat attributes_or_asm] end redefine redefine declarator [repeat attribute_spec] [repeat ptr_operator] [base_declarator] [repeat declarator_extension] [repeat attribute_spec] end redefine redefine base_declarator [repeat attribute_spec] [reference_id] | [repeat attribute_spec] ( [declarator] ) end redefine redefine ptr_operator '* [repeat ptr_qualifier] | '^ [repeat ptr_qualifier] end redefine define local_label '__label__ end define define ptr_qualifier [restrict_qualifier] | [cv_qualifier] end define define restrict_qualifier '__restrict | 'restrict__ | 'restrict | '__restrict__ end define redefine initializer [assignment_expression] | [NL] { [IN] [list designated_initializer] [opt ',] [EX] } end redefine redefine assignment_expression [conditional_expression] | [conditional_expression] [assignment_operation] end redefine redefine designated_initializer [assignment_expression] | [repeat designator] [opt designator_assignment] [assignment_expression] | [repeat designator] [opt designator_assignment] [NL] { [IN] [list designated_initializer] [opt ',] [EX] } end redefine define designator [array_designator] | [struct_or_union_designator] end define define array_designator '[ [constant_expression] '] [repeat postfix_extension] | '[ [constant_expression] [SP] '... [SP] [constant_expression] '] [repeat postfix_extension] end define define struct_or_union_designator [opt '.] [id] [repeat postfix_extension] end define define designator_assignment ': | '= end define redefine decl_qualifier [sc_specifier] | [type_qualifier] | [attribute_spec] | [extension_specifier] end redefine define extension_specifier '__extension__ end define redefine cv_qualifier 'const | 'volatile | '__const | '__const__ | 'const__ | '__volatile__ | '__volatile | 'volatile__ end redefine redefine type_qualifier [bit_qualifier] | [inline_qualifier] | [cv_qualifier] | [restrict_qualifier] end redefine define bit_qualifier 'long | 'short | 'signed | 'unsigned | '__signed__ | '__signed end define define inline_qualifier '__inline | '__inline__ | 'inline__ | 'inline end define redefine struct_or_union_specifier [struct_or_union] [repeat attribute_spec] [opt tagged_reference_id] { [IN] [NL] [repeat member_declaration] [EX] } [repeat attribute_spec] | [struct_or_union] [repeat attribute_spec] [tagged_reference_id] end redefine redefine member_declaration [decl_specifiers] [list member_declarator +] [semi] | [repeat decl_qualifier] [struct_or_union_specifier] [semi] | [semi] | [preprocessor] end redefine redefine member_declarator [declarator] [opt bitfieldsize] [repeat attributes_or_asm] | [bitfieldsize] end redefine define attributes_or_asm [attribute_spec] | [asm_spec] end define define attribute_spec '__attribute__ '('( [list attribute_extension] ')') end define define attribute_extension [attribute_alias] '( [string] ') | [attribute_aligned] | [attribute_aligned] '( [tagged_attribute_number] ') | [attribute_aligned] '( [alignof_expression] ') | [attribute_always_inline] | [attribute_cdecl] | [attribute_cleanup] '( [tagged_attribute_id] ') | [attribute_const] | [attribute_constructor] | [attribute_deprecated] | [attribute_destructor] | [attribute_dllexport] | [attribute_dllimport] | [attribute_eightbit] | [attribute_exception] '( [exception_function] [list exception_arg] ') | [attribute_far] | [attribute_funvector] | [attribute_format] '( [format_archetype] ', [tagged_attribute_number] ', [tagged_attribute_number] ') | [attribute_format_arg] '( [tagged_attribute_number] ') | [attribute_interrupt] | [attribute_interrupt] '( [string] ') | [attribute_interrupt_handler] | [attribute_interrupt_handler] '( [string] ') | [attribute_longcall] | [attribute_long_call] | [attribute_malloc] | [attribute_may_alias] | [attribute_mode] '( [tagged_attribute_id] ') | [attribute_model] '( [attribute_model_name] ') | [attribute_naked] | [attribute_near] | [attribute_no_check_mem] | [attribute_no_instrument] | [attribute_nocommon] | [attribute_noinline] | [attribute_nonnull] | [attribute_nonnull] '( [list tagged_attribute_number +] ') | [attribute_noreturn] | [attribute_nothrow] | [attribute_packed] | [attribute_pure] | [attribute_regparm] '( [tagged_attribute_number] ') | [attribute_section] '( [string] ') | [attribute_shared] | [attribute_short_call] | [attribute_signal] '( [string] ') | [attribute_sp_switch] '( [string] ') | [attribute_stdcall] | [attribute_tiny] | [attribute_tls_model] '( [tls_model_type] ') | [attribute_trans_union] | [attribute_trap_exit] '( [tagged_attribute_number] ') | [attribute_used] | [attribute_unused] | [attribute_vector_size] '( [tagged_attribute_number] ') | [attribute_visibility] '( [visibility_type] ') | [attribute_weak] end define define tagged_attribute_id [id] end define define tagged_attribute_number [number] end define define attribute_near '__near__ | '__near | 'near__ | 'near end define define attribute_far '__far__ | '__far | 'far__ | 'far end define define attribute_visibility '__visibility__ | '__visibility | 'visibility__ | 'visibility end define define visibility_type "default" | "hidden" | "protected" | "internal" end define define attribute_nonnull '__nonnull__ | '__nonnull | 'nonnull__ | 'nonnull end define define attribute_nothrow '__nothrow__ | '__nothrow | 'nothrow__ | 'nothrow end define define attribute_may_alias '__may_alias__ | '__may_alias | 'may_alias__ | 'may_alias end define define attribute_tls_model '__tls_model__ | '__tls_model | 'tls_model__ | 'tls_model end define define tls_model_type "global-dynamic" | "local-dynamic" | "initial-exec" | "local-exec" end define define attribute_cleanup '__cleanup__ | '__cleanup | 'cleanup__ | 'cleanup end define define attribute_dllexport '__dllexport__ | '__dllexport | 'dllexport__ | 'dllexport end define define attribute_used '__used__ | '__used | 'used__ | 'used end define define attribute_always_inline '__always_inline__ | '__always_inline | 'always_inline__ | 'always_inline end define define attribute_noinline '__noinline__ | '__noinline | 'noinline__ | 'noinline end define define attribute_vector_size '__vector_size__ | '__vector_size | 'vector_size__ | 'vector_size end define define attribute_deprecated '__deprecated__ | '__deprecated | 'deprecated__ | 'deprecated end define define attribute_mode '__mode__ | '__mode | 'mode__ | 'mode end define define attribute_format '__format__ | '__format | 'format__ | 'format end define define attribute_format_arg '__format_arg__ | '__format_arg | 'format_arg__ | 'format_arg end define define attribute_aligned '__aligned__ | '__aligned | 'aligned__ | 'aligned end define define attribute_weak 'weak | '__weak__ | '__weak | 'weak__ end define define attribute_alias 'alias | '__alias__ | '__alias | 'alias__ end define define attribute_no_check_mem 'no_check_memory_usage | '__no_check_memory_usage__ | '__no_check_memory_usage | 'no_check_memory_usage__ end define define attribute_regparm 'regparm | '__regparm__ | '__regparm | 'regparm__ end define define attribute_stdcall 'stdcall | '__stdcall__ | '__stdcall | 'stdcall__ end define define attribute_cdecl 'cdecl | '__cdecl__ | '__cdecl | 'cdecl__ end define define attribute_longcall 'longcall | '__longcall__ | '__longcall | 'longcall__ end define define attribute_long_call 'long_call | '__long_call__ | '__long_call | 'long_call__ end define define attribute_short_call 'short_call | '__short_call__ | '__short_call | 'short_call__ end define define attribute_dllimport 'dllimport | '__dllimport__ | '__dllimport | 'dllimport__ end define define attribute_exception 'exception | '__exception__ | '__exception | 'exception__ end define define exception_function [repeat stringlit] [stringlit] | [tagged_attribute_id] end define define exception_arg [repeat stringlit] [stringlit] | [tagged_attribute_id] end define define attribute_funvector 'function_vector | '__function_vector__ | '__function_vector | 'function_vector__ end define define attribute_interrupt 'interrupt | '__interrupt__ | '__interrupt | 'interrupt__ end define define attribute_interrupt_handler 'interrupt_handler | '__interrupt_handler__ | '__interrupt_handler | 'interrupt_handler__ end define define attribute_sp_switch 'sp_switch | '__sp_switch__ | '__sp_switch | 'sp_switch__ end define define attribute_trap_exit 'trap_exit | '__trap_exit__ | '__trap_exit | 'trap_exit__ end define define attribute_eightbit 'eightbit_data | '__eightbit_data__ | '__eightbit_data | 'eightbit_data__ end define define attribute_tiny 'tiny_data | '__tiny_data__ | '__tiny_data | 'tiny_data__ end define define attribute_signal 'signal | '__signal__ | '__signal | 'signal__ end define define attribute_naked 'naked | '__naked__ | '__naked | 'naked__ end define define attribute_model 'model | '__model__ | '__model | 'model__ end define define attribute_model_name 'small | '__small__ | '__small | 'small__ | 'medium | '__medium__ | '__medium | 'medium__ | 'large | '__large__ | '__large | 'large__ end define define attribute_nocommon 'nocommon | '__nocommon__ | 'nocommon__ | '__nocommon end define define attribute_shared 'shared | '__shared__ | '__shared | 'shared__ end define define attribute_malloc 'malloc | '__malloc__ | '__malloc | 'malloc__ end define define format_archetype 'printf | '__printf__ | '__printf | 'printf__ | 'scanf | '__scanf__ | '__scanf | 'scanf__ | 'strftime | '__strftime__ | '__strftime | 'strftime__ | 'strfmon | '__strfmon__ | '__strfmon | 'strfmon__ | [id] end define define attribute_noreturn '__noreturn__ | '__noreturn | 'noreturn__ | 'noreturn end define define attribute_const '__const__ | '__const | 'const__ | 'const end define define attribute_pure '__pure__ | '__pure | 'pure__ | 'pure end define define attribute_trans_union '__transparent_union__ | '__transparent_union | 'transparent_union__ | 'transparent_union end define define attribute_unused '__unused__ | '__unused | 'unused__ | 'unused | '__warn_unused_result__ | '__nodebug__ end define define attribute_packed '__packed__ | '__packed | 'packed__ | 'packed end define define attribute_no_instrument 'no_instrument_function | '__no_instrument_function__ | '__no_instrument_function | 'no_instrument_function__ end define define attribute_section 'section | '__section__ | '__section | 'section__ end define define attribute_constructor 'constructor | '__constructor__ | '__constructor | 'constructor__ end define define attribute_destructor 'destructor | '__destructor__ | '__destructor | 'destructor__ end define define asm_statement [asm_spec] [semi] end define define asm_spec [repeat asm_or_cv +] '( [asm_template] [opt asm_output_operands] [opt asm_input_operands] [opt asm_clobbered_registers] ') end define define asm_or_cv '__asm__ | 'asm | 'asm__ | '__asm | [cv_qualifier] end define define asm_template [string] end define define asm_output_operands ': [list asm_operand] end define define asm_input_operands ': [list asm_operand] end define define asm_operand [string] '( [expression] ') end define define asm_clobbered_registers ': [list string] end define redefine nonreferential_primary [constant] | [string] | '( [expression] ') | [compound_statement_expression] | [compound_literal] | [extension_specifier] [compound_statement_expression] | [extension_specifier] '( [expression] ') end redefine redefine unary_expression ... | [alignof_expression] end redefine redefine unary_operator ... | '&& end redefine redefine for_statement ... | 'for ( [declaration_body] '; [opt expression] '; [opt expression] ) [statement] end redefine redefine jump_statement ... | 'goto [ptr_operator] [expression] [semi] end redefine redefine constant_expression ... | [restrict_qualifier] end redefine define compound_statement_expression '( [compound_statement] ') end define redefine compound_statement { [NL] [repeat compound_statement_body] } [opt ';] [NL] end redefine redefine compound_statement_body [IN] [declaration] [EX] | [IN] [function_definition] [EX] | [IN] [statement] [EX] end redefine define compound_literal '( [struct_or_union_specifier] ') { [list designated_initializer] [opt ',] } | '( [compound_literal_array_type] ') { [list designated_initializer] [opt ',] } | '( [compound_literal] ') end define define compound_literal_array_type [type_specifiers] [compound_literal_array_declarator] end define define compound_literal_array_declarator [repeat ptr_operator] [repeat array_declarator_extension] | ( [compound_literal_array_declarator] ) [repeat array_declarator_extension] end define redefine sizeof_expression 'sizeof [unary_expression] | 'sizeof ( [type_name] ) end redefine redefine type_specifier ... | [typeof_expression] | [complex_specifier] end redefine define typeof_expression [typeof_specifier] '( [simple_type_name] ') | [typeof_specifier] '( [expression] ') end define define typeof_specifier '__typeof | 'typeof | '__typeof__ | 'typeof__ end define define complex_specifier '_Complex [repeat simple_type_or_qualifier] end define define simple_type_or_qualifier [simple_type_name] | [type_qualifier] end define redefine constant ... | [gnu_long_int] | [repeat gnu_long_int_string +] | [hexfloat] end redefine define gnu_long_int [gnu_long_int_string] | [gnu_long_int_charlit] end define define gnu_long_int_string 'L [SPOFF] [string] [SPON] end define define gnu_long_int_charlit 'L [SPOFF] [charlit] [SPON] end define define hexfloat [extension_specifier] [hex] end define redefine preprocessor ... | '# [integernumber] [string] [repeat integernumber] [NL] | '#pragma [SPON] [repeat id] '( [list id] ') [NL] end redefine redefine unlabeled_statement ... | [asm_statement] end redefine redefine enum_specifier 'enum [tagged_reference_id] | 'enum [opt tagged_reference_id] { [list enumerator] [opt ',] } end redefine redefine label [label_id] ': [repeat attribute_spec] | [EX] [SP] [SP] 'case [constant_expression] ': [IN] [NL] | [EX] [SP] [SP] 'case [constant_expression] [SP] '... [SP] [constant_expression] ': [IN] [NL] | [EX] [SP] [SP] 'default ': [IN] [NL] end redefine redefine postfix_extension '[ [expression] '] | '( [list argument_expression] ') | '. [id] | '-> [id] | '++ | '-- end redefine define argument_expression [assignment_expression] | [type_name] end define redefine conditional_expression [binary_expression] [repeat conditional_operation] end redefine redefine conditional_operation ? [opt expression] : [binary_expression] end redefine redefine abstract_declarator [repeat ptr_operator +] [repeat declarator_extension] | [repeat array_declarator_extension] | ( [abstract_declarator] ) [repeat declarator_extension] end redefine define alignof_expression '__alignof__ '( [unary_expression] ') | '__alignof '( [unary_expression] ') | '__alignof__ '( [type_name] ') | '__alignof '( [type_name] ') end define redefine statement ... | [label] end redefine redefine statement ... | [comment_NL] end redefine redefine declaration ... | [comment_NL] end redefine redefine member_declaration ... | [comment_NL] end redefine redefine initializer [repeat comment_NL] ... end redefine redefine initialization [repeat comment_NL] ... end redefine redefine argument_declaration [repeat comment_NL] ... end redefine redefine argument_declaration ... [repeat comment_NL] end redefine redefine argument_declaration_list ... [repeat comment_NL] end redefine redefine if_statement 'if ( [expression] ) [repeat comment_NL] [statement] [opt else_statement] end redefine redefine switch_statement 'switch ( [expression] ) [repeat comment_NL] [statement] end redefine redefine compound_statement [repeat comment_NL] ... end redefine redefine preprocessor [EX] '#endif [opt comment_NL] [NL] | ... end redefine redefine preprocessor ... [opt comment_NL] end redefine redefine expression [repeat comment_NL] ... end redefine define comment_NL [comment] [NL] end define keys <<<<<< >>>>>> end keys compounds <<<<<< >>>>>> end compounds define Change [NL] <<<<<< [opt number] [opt stringlit] [NL] | [NL] >>>>>> [opt number] [opt stringlit] [NL] end define rule normalise_id_by3_type_specifiers1 replace [type_specifiers *] P1 [type_specifiers] P2 [type_specifiers *] deconstruct P1 X8 [type_specifier] X9 [repeat type_qualifier] deconstruct * [id] X8 X8_x1 [id] construct X8_d1 [id *] _ [ . ' type_specifiers ] [ . X8_x1 ] [ print ] by P2 end rule function normalise_id_by4_type_specifiers1 replace [program] P1 [ program ] construct Element [type_specifiers *] _ [ ^ P1 ] construct d_Element [type_specifiers *] Element [ normalise_id_by3_type_specifiers1 ] by P1 end function rule normalise_id_by3_declaration_or_function_definition1 replace [declaration_or_function_definition *] P1 [declaration_or_function_definition] P2 [declaration_or_function_definition *] deconstruct P1 X10 [function_definition] deconstruct * [id] X10 X10_x1 [id] construct X10_d1 [id *] _ [ . ' declaration_or_function_definition ] [ . X10_x1 ] [ print ] by P2 end rule function normalise_id_by4_declaration_or_function_definition1 replace [program] P1 [ program ] construct Element [declaration_or_function_definition *] _ [ ^ P1 ] construct d_Element [declaration_or_function_definition *] Element [ normalise_id_by3_declaration_or_function_definition1 ] by P1 end function function program_normalise replace [program] Prg [ program ] by Prg [ normalise_id_by4_type_specifiers1 ] [ normalise_id_by4_declaration_or_function_definition1 ] end function function program_remove_clone replace [program] Prg [ program ] export CloneNumber [number] 0 import TXLargs [repeat stringlit] deconstruct * TXLargs "-diff" Filename [ stringlit ] export CloneNumber 99 construct P2 [program] _ [ read Filename ] [ program_normalise ] export Program_Diff [program] P2 by Prg end function redefine program ... | [empty] | [attr number] end define function print_diff_1 replace [program] Prg [ program ] import TXLinput [stringlit] construct Str_TmpFile [stringlit] TXLinput [ + ".tmp" ] construct Str_RmTmpFile [stringlit] _ [ + "/bin/rm -f " ] [ + Str_TmpFile ] construct P2 [program] Prg [ write Str_TmpFile ] [ read Str_TmpFile ] [ system Str_RmTmpFile ] construct S_Diff [stringlit] _ [ quote P2 ] where not S_Diff [= ""] by Prg end function function print_diff_2 replace [program] Prg [ program ] import TXLinput [stringlit] construct Str_TmpFile [stringlit] TXLinput [ + ".tmp" ] construct Str_RmTmpFile [stringlit] _ [ + "/bin/rm -f " ] [ + Str_TmpFile ] construct P2 [program] Prg [ program_normalise ] [ write Str_TmpFile ] [ read Str_TmpFile ] [ system Str_RmTmpFile ] construct S_Diff [stringlit] _ [ quote P2 ] where S_Diff [= ""] by _ end function function print_diff replace [program] P_diff [ program ] import CloneNumber [number] import Program_Diff [program] where CloneNumber [> 0] construct P_Clone [program] CloneNumber [ - 99 ] construct P_Left [program] P_diff [ print_diff_1 ] [ print_diff_2 ] [ printattr ] construct P_Right [program] Program_Diff [ print_diff_1 ] [ print_diff_2 ] [ printattr ] by P_Clone end function redefine program ... | [id_nl *] end define define id_nl [id] [id] [NL] end define function id2id_nl T [id] replace [id_nl *] V [ id_nl * ] construct V2 [id_nl *] T T by _ [ . V ] [ . V2 ] end function function exportIds replace [program] Prg [ program ] construct I [id *] _ [ ^ Prg ] construct I2 [id_nl *] _ [id2id_nl each I] by I2 end function function main replace [program] Prg [ program ] export Program_Diff [program] _ export Program [program] Prg by Prg [ program_normalise ] [ program_remove_clone ] [ print_diff ] end function