Grammar IDLParser ANTLR-generated HTML file from idl.g
Terence Parr, MageLang Institute
|
Definition of parser IDLParser, which is a subclass of LLkParser. specification : ( import_dcl )* ( decorated_definition )+ ; import_dcl : "import" ( anglequoted_scope | imported_scope ) SEMI ; decorated_definition : ( ( decorator )* definition ) ; decorator : ( LBRACK ( decorator_element ) ( COMMA decorator_element )* RBRACK ) ; definition : ( type_dcl SEMI | const_dcl SEMI | except_dcl SEMI | interf SEMI | module SEMI | value SEMI | type_id_dcl SEMI | type_prefix_dcl SEMI | event SEMI | component SEMI | home_dcl SEMI ) ; type_dcl : "typedef" type_declarator | struct_type | union_type | enum_type | "native" simple_declarator | constr_forward_decl ; const_dcl : "const" const_type identifier ASSIGN const_exp ; except_dcl : "exception" identifier LCURLY opt_member_list RCURLY ; interf : ( "abstract" | "local" | ) "interface" identifier ( interface_dcl | ) ; module : "module" identifier LCURLY definition_list RCURLY ; value : ( value_dcl | value_abs_dcl | value_box_dcl | value_custom_dcl | value_forward_dcl ) ; type_id_dcl : "typeid" scoped_name string_literal ; type_prefix_dcl : "typeprefix" scoped_name string_literal ; event : ( event_abs | event_custom | event_dcl ) ; component : "component" identifier ( component_dcl | ) ; home_dcl : home_header home_body ; decorator_element : ( identifier ( LPAREN ( expr_list | ) RPAREN | ) ) ; identifier : IDENT ; expr_list : ( ( const_exp ) ( COMMA ( const_exp ) )* ) ; const_exp : or_expr ; definition_list : ( decorated_definition )+ ; interface_dcl : interface_header LCURLY interface_body RCURLY ; interface_header : ( interface_inheritance_spec | ) ; interface_body : ( export )* ; interface_inheritance_spec : COLON scoped_name_list ; export : ( type_dcl SEMI | const_dcl SEMI | except_dcl SEMI | attr_dcl SEMI | op_dcl SEMI | type_id_dcl SEMI | type_prefix_dcl SEMI ) ; attr_dcl : readonly_attr_spec | attr_spec ; op_dcl : ( decorator | ) ( op_attribute | ) op_type_spec IDENT parameter_dcls ( raises_expr | ) ( context_expr | ) ; scoped_name_list : scoped_name ( COMMA scoped_name )* ; interface_name : scoped_name ; scoped_name : ( SCOPEOP | ) IDENT ( SCOPEOP identifier )* ; value_dcl : value_header LCURLY ( value_element )* RCURLY ; value_abs_dcl : "abstract" "valuetype" identifier ( value_abs_full_dcl | ) ; value_box_dcl : "valuetype" identifier type_spec ; value_custom_dcl : "custom" value_dcl ; value_forward_dcl : "valuetype" identifier ; type_spec : simple_type_spec | constr_type_spec ; value_abs_full_dcl : value_inheritance_spec LCURLY ( export )* RCURLY ; value_inheritance_spec : ( value_value_inheritance_spec | ) ( value_interface_inheritance_spec | ) ; value_header : "valuetype" identifier value_inheritance_spec ; value_element : ( export | state_member | init_dcl ) ; value_value_inheritance_spec : COLON ( "truncatable" | ) value_name ( COMMA value_name )* ; value_interface_inheritance_spec : "supports" interface_name ( COMMA interface_name )* ; value_name : scoped_name ; state_member : ( "public" | "private" ) type_spec declarators SEMI ; init_dcl : "factory" identifier LPAREN ( init_param_decls | ) RPAREN ( raises_expr | ) SEMI ; declarators : declarator ( COMMA declarator )* ; init_param_decls : init_param_decl ( COMMA init_param_decl )* ; raises_expr : "raises" LPAREN scoped_name_list RPAREN ; init_param_decl : init_param_attribute param_type_spec simple_declarator ; init_param_attribute : "in" ; param_type_spec : base_type_spec | string_type | wide_string_type | scoped_name ; simple_declarator : identifier ; const_type : integer_type | char_type | wide_char_type | boolean_type | floating_pt_type | string_type | wide_string_type | fixed_pt_const_type | scoped_name | octet_type ; integer_type : signed_int | unsigned_int ; char_type : "char" ; wide_char_type : "wchar" ; boolean_type : "boolean" ; floating_pt_type : "float" | "double" | "long" "double" ; string_type : "string" ( LT positive_int_const GT | ) ; wide_string_type : "wstring" ( LT positive_int_const GT | ) ; fixed_pt_const_type : "fixed" ; octet_type : "octet" ; or_expr : xor_expr ( OR xor_expr )* ; xor_expr : and_expr ( XOR and_expr )* ; and_expr : shift_expr ( AND shift_expr )* ; shift_expr : add_expr ( ( LSHIFT | RSHIFT ) add_expr )* ; add_expr : mult_expr ( ( PLUS | MINUS ) mult_expr )* ; mult_expr : unary_expr ( ( STAR | DIV | MOD ) unary_expr )* ; unary_expr : ( MINUS | PLUS | TILDE ) primary_expr | primary_expr ; primary_expr : scoped_name | literal | LPAREN const_exp RPAREN ; literal : integer_literal | string_literal | wide_string_literal | character_literal | wide_character_literal | fixed_pt_literal | floating_pt_literal | boolean_literal ; integer_literal : INT | OCTAL | HEX ; string_literal : ( STRING_LITERAL )+ ; wide_string_literal : ( WIDE_STRING_LITERAL )+ ; character_literal : CHAR_LITERAL ; wide_character_literal : WIDE_CHAR_LITERAL ; fixed_pt_literal : FIXED ; floating_pt_literal : FLOAT ; boolean_literal : "TRUE" | "FALSE" ; positive_int_const : const_exp ; type_declarator : type_spec declarators ; struct_type : "struct" identifier LCURLY member_list RCURLY ; union_type : "union" identifier "switch" LPAREN switch_type_spec RPAREN LCURLY switch_body RCURLY ; enum_type : "enum" identifier LCURLY enumerator_list RCURLY ; constr_forward_decl : "struct" identifier | "union" identifier ; simple_type_spec : base_type_spec | template_type_spec | scoped_name ; constr_type_spec : struct_type | union_type | enum_type ; base_type_spec : floating_pt_type | integer_type | char_type | wide_char_type | boolean_type | octet_type | any_type | object_type | value_base_type ; template_type_spec : sequence_type | string_type | wide_string_type | fixed_pt_type ; any_type : "any" ; object_type : "Object" ; value_base_type : "ValueBase" ; sequence_type : "sequence" LT simple_type_spec opt_pos_int GT ; fixed_pt_type : "fixed" LT positive_int_const COMMA positive_int_const GT ; declarator : simple_declarator | complex_declarator ; complex_declarator : array_declarator ; array_declarator : IDENT ( fixed_array_size )+ ; signed_int : signed_short_int | signed_long_int | signed_longlong_int ; unsigned_int : unsigned_short_int | unsigned_long_int | unsigned_longlong_int ; signed_short_int : "short" ; signed_long_int : "long" ; signed_longlong_int : "long" "long" ; unsigned_short_int : "unsigned" "short" ; unsigned_long_int : "unsigned" "long" ; unsigned_longlong_int : "unsigned" "long" "long" ; member_list : ( member )+ ; member : type_spec declarators SEMI ; switch_type_spec : integer_type | char_type | boolean_type | enum_type | scoped_name ; switch_body : case_stmt_list ; case_stmt_list : ( case_stmt )+ ; case_stmt : ( "case" const_exp COLON | "default" COLON )+ element_spec SEMI ; element_spec : type_spec declarator ; enumerator_list : enumerator ( COMMA enumerator )* ; enumerator : identifier ; opt_pos_int : ( COMMA positive_int_const | ) ; fixed_array_size : LBRACK positive_int_const RBRACK ; readonly_attr_spec : "readonly" "attribute" param_type_spec readonly_attr_declarator ; attr_spec : "attribute" param_type_spec attr_declarator ; opt_member_list : ( member )* ; op_attribute : "oneway" ; op_type_spec : param_type_spec | "void" ; parameter_dcls : LPAREN ( param_dcl_list | ) RPAREN ; context_expr : "context" LPAREN string_literal_list RPAREN ; param_dcl_list : ( decorator | ) param_dcl ( COMMA ( decorator | ) param_dcl )* ; param_dcl : ( "in" | "out" | "inout" ) param_type_spec ( allow_indirection | ) simple_declarator ; allow_indirection : ( STAR )+ ; string_literal_list : string_literal ( COMMA string_literal )* ; anglequoted_scope : anglequoted_string_literal ; imported_scope : scoped_name | string_literal ; anglequoted_string_literal : LT identifier GT ; readonly_attr_declarator : simple_declarator ( raises_expr | ( COMMA simple_declarator )* ) ; attr_declarator : simple_declarator ( attr_raises_expr | ( COMMA simple_declarator )* ) ; attr_raises_expr : ( get_excep_expr | ) ( set_excep_expr | ) ; get_excep_expr : "getraises" exception_list ; set_excep_expr : "setraises" exception_list ; exception_list : LPAREN scoped_name ( COMMA scoped_name )* RPAREN ; component_dcl : ( component_inheritance_spec | ) ( supported_interface_spec | ) LCURLY component_body RCURLY ; component_inheritance_spec : COLON scoped_name ; supported_interface_spec : "supports" scoped_name ( COMMA scoped_name )* ; component_body : ( component_export )* ; component_export : ( provides_dcl SEMI | uses_dcl SEMI | emits_dcl SEMI | publishes_dcl SEMI | consumes_dcl SEMI | attr_dcl SEMI ) ; provides_dcl : "provides" interface_type identifier ; uses_dcl : "uses" ( "multiple" | ) interface_type identifier ; emits_dcl : "emits" scoped_name identifier ; publishes_dcl : "publishes" scoped_name identifier ; consumes_dcl : "consumes" scoped_name identifier ; interface_type : ( scoped_name | "Object" ) ; home_header : "home" identifier ( home_inheritance_spec | ) ( supported_interface_spec | ) "manages" scoped_name ( primary_key_spec | ) ; home_body : LCURLY ( home_export )* RCURLY ; home_inheritance_spec : COLON scoped_name ; primary_key_spec : "primarykey" scoped_name ; home_export : ( export | factory_dcl SEMI | finder_dcl SEMI ) ; factory_dcl : "factory" identifier LPAREN init_param_decls RPAREN ( raises_expr | ) ; finder_dcl : "finder" identifier LPAREN init_param_decls RPAREN ( raises_expr | ) ; event_abs : "abstract" event_header ( event_abs_dcl | ) ; event_custom : "custom" event_header event_elem_dcl ; event_dcl : event_header ( event_elem_dcl | ) ; event_header : "eventtype" identifier ; event_abs_dcl : value_inheritance_spec LCURLY ( export )* RCURLY ; event_elem_dcl : value_inheritance_spec LCURLY ( export )* RCURLY ;