Grammar CAmkESParser
ANTLR-generated HTML file from adl.g

Terence Parr, MageLang Institute
ANTLR Version 2.7.5 (20050403); 1989-2005


Definition of parser CAmkESParser, which is a subclass of LLkParser.


specification
	:	( include_dcl )* ( import_dcl )* ( definition )+ 
	;


include_dcl
	:	"include" 
		(	anglequoted_scope 
		|	imported_scope 
		) 
		SEMI 
	;


import_dcl
	:	"import" 
		(	anglequoted_scope 
		|	imported_scope 
		) 
		SEMI 
	;


definition
	:	(	component 
		|	assembly 
		|	dataport_dcl 
		|	connector 
		) 
	;


component
	:	"component" identifier 
		(	component_dcl 
		|	
		) 
	;


assembly
	:	( "assembly" LCURLY ( assembly_element )* RCURLY ) 
	;


dataport_dcl
	:	( "dataport" declarator LCURLY ( type_declarator SEMI )* RCURLY ) 
	;


connector
	:	( "connector" identifier LCURLY ( connector_body ) RCURLY ) 
	;


identifier
	:	IDENT 
	;


connector_body
	:	( ( "from" connector_spec ) ( "to" connector_spec ) ) 
	;


connector_spec
	:	( connector_type identifier SEMI ) 
	;


connector_type
	:	(	"Interface" 
		|	"DataPort" 
		) 
	;


assembly_element
	:	(	component_inst SEMI 
		|	component_composition SEMI 
		|	configuration SEMI 
		) 
	;


component_inst
	:	"component" scoped_name declarator 
	;


component_composition
	:	( "composition" LCURLY ( composition_export SEMI )+ RCURLY ) 
	;


configuration
	:	( "configuration" LCURLY ( config_body )* RCURLY ) 
	;


config_body
	:	( (	assignment 
			|	cap_list 
			|	op_dcl 
			) 
			SEMI ) 
	;


assignment
	:	( scoped_name ASSIGN 
			(	"\"" STRING_LITERAL "\"" 
			|	const_exp 
			) ) 
	;


cap_list
	:	( "capabilityList" LCURLY ( cap_element SEMI )* RCURLY ) 
	;


op_dcl
	:	op_type_spec IDENT parameter_dcls 
	;


scoped_name
	:	(	SCOPEOP 
		|	
		) 
		identifier ( (	SCOPEOP 
			|	DOT 
			) 
			identifier )* 
		(	fixed_array_size 
		|	
		) 
	;


const_exp
	:	or_expr 
	;


cap_element
	:	( scoped_name 
			(	STAR 
			|	
			) 
			ASSIGN cap_modifier ) 
	;


cap_modifier
	:	(	MINUS 
		|	"r" 
		|	"w" 
		|	"x" 
		) 
	;


scoped_name_list
	:	scoped_name ( COMMA scoped_name )* 
	;


fixed_array_size
	:	LBRACK 
		(	positive_int_const 
		|	
		) 
		RBRACK 
	;


expr_list
	:	( ( const_exp ) ( COMMA ( const_exp ) )* ) 
	;


definition_list
	:	( definition )+ 
	;


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 
		(	allow_indirection 
		|	
		) 
		declarators 
	;


type_spec
	:	simple_type_spec 
	|	constr_type_spec 
	;


allow_indirection
	:	( STAR )+ 
	;


declarators
	:	declarator ( COMMA declarator )* 
	;


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 
	|	object_type 
	;


template_type_spec
	:	sequence_type 
	|	string_type 
	|	wide_string_type 
	|	fixed_pt_type 
	;


floating_pt_type
	:	"float" 
	|	"double" 
	|	"long" "double" 
	;


integer_type
	:	signed_int 
	|	unsigned_int 
	;


char_type
	:	signed_char 
	|	unsigned_char 
	;


wide_char_type
	:	"wchar" 
	;


boolean_type
	:	"boolean" 
	;


object_type
	:	"Object" 
	;


sequence_type
	:	"sequence" LT simple_type_spec opt_pos_int GT 
	;


string_type
	:	"string" 
		(	LT positive_int_const GT 
		|	
		) 
	;


wide_string_type
	:	"wstring" 
		(	LT positive_int_const GT 
		|	
		) 
	;


fixed_pt_type
	:	"fixed" LT positive_int_const COMMA positive_int_const GT 
	;


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 
	;


declarator
	:	simple_declarator 
	|	complex_declarator 
	;


simple_declarator
	:	identifier 
	;


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" 
	;


signed_char
	:	"char" 
	;


unsigned_char
	:	"unsigned" "char" 
	;


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 
		|	
		) 
	;


attr_dcl
	:	readonly_attr_spec 
	|	attr_spec 
	;


readonly_attr_spec
	:	"readonly" "attribute" param_type_spec readonly_attr_declarator 
	;


attr_spec
	:	"attribute" param_type_spec attr_declarator 
	;


except_dcl
	:	"exception" identifier LCURLY opt_member_list RCURLY 
	;


opt_member_list
	:	( member )* 
	;


op_type_spec
	:	param_type_spec 
		(	allow_indirection 
		|	
		) 
	;


parameter_dcls
	:	LPAREN 
		(	param_dcl_list 
		|	
		) 
		RPAREN 
	;


param_type_spec
	:	base_type_spec 
	|	string_type 
	|	wide_string_type 
	|	scoped_name 
	;


param_dcl_list
	:	param_dcl ( COMMA param_dcl )* 
	;


param_dcl
	:	(	"in" 
		|	"out" 
		|	"inout" 
		) 
		param_type_spec 
		(	allow_indirection 
		|	
		) 
		simple_declarator 
	;


string_literal_list
	:	string_literal ( COMMA string_literal )* 
	;


fixed_pt_const_type
	:	"fixed" 
	;


constr_forward_decl
	:	"struct" identifier 
	|	"union" identifier 
	;


anglequoted_scope
	:	anglequoted_string_literal 
	;


imported_scope
	:	scoped_name 
	|	string_literal 
	;


anglequoted_string_literal
	:	LT identifier GT 
	;


readonly_attr_declarator
	:	simple_declarator 
	;


attr_declarator
	:	simple_declarator 
	;


get_excep_expr
	:	"getraises" exception_list 
	;


exception_list
	:	LPAREN scoped_name ( COMMA scoped_name )* RPAREN 
	;


set_excep_expr
	:	"setraises" exception_list 
	;


component_dcl
	:	(	component_inheritance_spec 
		|	
		) 
		LCURLY component_body RCURLY 
	;


component_inheritance_spec
	:	COLON scoped_name 
	;


component_body
	:	( component_export )* 
		(	component_composition 
		|	
		) 
	;


component_export
	:	(	component_modifiers SEMI 
		|	provides_dcl SEMI 
		|	uses_dcl SEMI 
		|	emits_dcl SEMI 
		|	publishes_dcl SEMI 
		|	consumes_dcl SEMI 
		|	attr_dcl SEMI 
		|	component_fcn SEMI 
		|	dataport_spec SEMI 
		) 
	;


component_modifiers
	:	(	"active" 
			(	"multithread" 
				(	"control" 
				|	
				) 
			|	
			) 
		|	"passive" 
		) 
	;


provides_dcl
	:	(	"optional" 
		|	
		) 
		"provides" interface_type declarator 
	;


uses_dcl
	:	(	"optional" 
		|	
		) 
		"uses" interface_type declarator 
	;


emits_dcl
	:	"emits" scoped_name declarator 
	;


publishes_dcl
	:	"publishes" scoped_name declarator 
	;


consumes_dcl
	:	"consumes" scoped_name declarator 
	;


component_fcn
	:	( (	"optional" 
			|	
			) 
			op_dcl ) 
	;


dataport_spec
	:	( "dataport" scoped_name declarator ) 
	;


interface_type
	:	(	scoped_name 
		|	"Object" 
		) 
	;


composition_export
	:	(	component_inst 
		|	connection_dcl 
		) 
	;


connection_dcl
	:	( connection_head connection_body ) 
	;


connection_head
	:	"connection" scoped_name identifier 
	;


connection_body
	:	LPAREN ( "from" scoped_name_list COMMA "to" scoped_name_list ) RPAREN 
	;