NorKen Technologies, Inc.


Home Page of NorKen Technologies, Inc. Information About NorKen Technologies, Inc. Information About NorKen Technologies' Products Information About NorKen Technologies' Services Information About Ordering NorKen Technologies' Products How to Contact NorKen Technologies


FAQs



Free Trial

Order



Downloads

Grammars






























































































































































































































































CORBA IDL Parser Example

// =================================================================
// ProGrammar Grammar Definition File
// -----------------------------------------------------------------
//  
//  IDL.GDL - Parses CORBA Interface Definition Language (IDL).
//
//  This example is intended for demonstration purposes only.
//
//  (c) Copyright 1999, 2000 NorKen Technologies, Inc.
//
// ==================================================================

grammar IDL 
{
	specification  ::= 
		{ definition };

	definition  ::=  
		( type_dcl  
		  | const_dcl 
		  | except_dcl 
		  | interface 
		  | module )  
		";" ; 

	module ::=  
		"module" identifier "{" [{ definition }] "}" ; 

	interface ::= 
		interface_dcl
		| forward_dcl  
		; 

	interface_dcl ::= 
		interface_header "{" interface_body "}" ; 

	forward_dcl ::=  
		"interface" identifier  ; 

	interface_header 
		::=  "interface" identifier  [ inheritance_spec  ]  ; 

	interface_body ::=  
		[{ export }]  ; 

	export ::=  
		( type_dcl  | const_dcl  | except_dcl  | attr_dcl  | op_dcl  )  ";"  ; 

	inheritance_spec ::=  
		":" { scoped_name, "," } ;

	scoped_name ::= 
		["::"] { identifier, "::" } ;
 
	const_dcl ::=  
		"const" const_type identifier  "=" const_exp  ; 

	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  ; 
 
	const_exp ::= 
		or_expr  ; 

	or_expr ::= 
		xor_expr [{ "|", xor_expr }];

	xor_expr ::= 
		and_expr [{ "^", and_expr }];

	and_expr ::= 
		shift_expr [{ "ampersand_char" shift_expr }] ; 

	shift_expr ::= 
		add_expr [{ (">>"|"<<") add_expr }];
 
	add_expr ::= 
		mult_expr [{ ("+" | "-") mult_expr }];
 
	mult_expr ::= 
		unary_expr [{ ("*"|"/"|"%") unary_expr }];
 
	unary_expr ::= 
		[unary_operator] primary_expr  ; 

	unary_operator ::=  
		"-"  |  "+"  |  "~"  ; 

	primary_expr ::= 
		scoped_name  
		| literal  
		|  "(" const_exp  ")"  ; 

	literal ::= 
		integer_literal 
		| string_literal 
		| wide_string_literal
		| character_literal 
		| wide_character_literal
		| fixed_pt_literal
		| floating_pt_literal 
		| boolean_literal  
		; 
 
	boolean_literal ::=  
		"TRUE"  |  "FALSE"  ; 

	positive_int_const ::= 
		const_exp  ; 

	string_literal ::= 
		quotedstring;

	character_literal ::= 
		"\'" ["\\"] (numeric|'.') "\'";

	floating_pt_literal ::= 
		numeric ["." numeric];

	integer_literal ::= 
		numeric;

	type_dcl  ::=  
		"typedef" type_declarator 
		| struct_type 
 		| union_type 
		| enum_type  
		; 
	
	type_declarator ::= 
		type_spec declarators  ; 

	type_spec ::= 
		simple_type_spec 
		| constr_type_spec  ; 

	simple_type_spec ::= 
		base_type_spec 
 		| template_type_spec 
 		| scoped_name  
 		; 
 
	base_type_spec ::= 
		floating_pt_type 
 		| integer_type 
 		| char_type 
 		| wide_char_type
 		| boolean_type 
		| octet_type 
		| any_type 
		| object_type 
		; 
 
	template_type_spec ::= 
		sequence_type  
		| string_type  
		| wide_string_type
		| fixed_pt_type
		; 

	constr_type_spec ::= 
		struct_type 
		| union_type 
		| enum_type  
		; 

	declarators ::= 
		{ declarator, "," } ; 

	declarator ::= 
		complex_declarator 
		| simple_declarator 
		; 

	simple_declarator ::= 
		identifier ; 

	complex_declarator ::= 
		array_declarator ;

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

	integer_type ::= 
		signed_int 
		| unsigned_int
		;

	signed_int ::= 
		signed_long_int  
		| signed_short_int  
		| signed_longlong_int
		; 

	signed_long_int ::=  
		"long" ; 

	signed_short_int ::=  
		"short" ; 

	signed_longlong_int ::= 
		"long" "long" ;

	unsigned_int ::= 
		unsigned_long_int  
		| unsigned_short_int  
		| unsigned_longlong_int
		; 

	unsigned_long_int ::=  
		"unsigned" "long" ; 

	unsigned_short_int ::=  
		"unsigned" "short" ; 

	unsigned_longlong_int ::= 
		"unsigned" "long" "long" ;

	char_type ::= 
		"char" ;

	wide_char_type ::= 
		"wchar" ;

	boolean_type ::= 
		"boolean" ; 

	octet_type ::= 
		"octet" ; 

	any_type ::= 
		"any" ;

	object_type ::= 
		"Object" ;

	struct_type ::=  
		"struct" identifier  "{" member_list  "}" ; 

	member_list ::= 
		{ member } ;

	member ::= 
		type_spec declarators  ";" ; 

	union_type ::=  
		"union" identifier  "switch"  "(" switch_type_spec  ")" 
		"{" switch_body  "}" ; 
		 
	switch_type_spec ::= 
		integer_type 
		| char_type 
		| boolean_type 
		| enum_type 
		| scoped_name  
		; 
 
	switch_body ::= 
		{ case } ; 

	case ::= 
		{ case_label  } element_spec  ";"  ; 

	case_label ::= 
		"case" const_exp  ":"  
		|  "default"  ":" ; 

	element_spec ::= 
		type_spec declarator ; 

	enum_type ::= 
		"enum" identifier  "{" { enumerator, "," } "}" ; 

	enumerator ::= 
		identifier ;

	sequence_type ::= 
		"sequence" "<" simple_type_spec 
		["," positive_int_const] ">" ; 
 
	string_type ::= 
		"string" ["<" positive_int_const  ">" ];

	wide_string_type ::= 
		"wstring"  ["<" positive_int_const  ">"] ; 

	array_declarator ::= 
		identifier { fixed_array_size } ; 

	fixed_array_size ::= 
		"[" positive_int_const "]" ; 

	attr_dcl ::= 
		[ "readonly" ] "attribute" param_type_spec 
		{ simple_declarator, "," } ; 

	except_dcl ::=  
		"exception" identifier  "{"  [{ member }] "}"  ; 

	op_dcl ::= 
		[ op_attribute  ] op_type_spec identifier parameter_dcls 
 		[ raises_expr  ]  [ context_expr  ]  ; 
 
	op_attribute ::= 
		"oneway" ; 

	op_type_spec ::= 
		param_type_spec
		| "void" ; 

	parameter_dcls ::= 
		"(" [{ param_dcl, "," }]  ")" ;

	param_dcl ::= 
		param_attribute param_type_spec simple_declarator ; 

	param_attribute ::= 
		"in" 
		| "out"
		| "inout" 
		; 

	raises_expr ::= 
		"raises" "(" { scoped_name, "," } ")" ; 

	context_expr ::= 
		"context" "(" { string_literal, "," } ")" ; 

	param_type_spec  ::= 	
		base_type_spec  
		| string_type  
		| wide_string_type
		| fixed_pt_type
		| scoped_name  
		; 
			
	fixed_pt_type ::= 
		"fixed" "<" positive_int_const "," integer_literal ">" ;

	fixed_pt_const_type ::= 
		"fixed" ;

	wide_string_literal ::= 
		quotedstring;
	
	wide_character_literal ::= 
		character_literal;
	
	fixed_pt_literal ::=
		floating_pt_literal;

	space_symbol  ::= 
			{ ( "\32" | "\r" |"\n"|"\t")
			  | "//" *("\n") 
			  |  "/*" *("*/") "*/",,0 };

}; // grammar IDL



For comments or questions about this site, please contact
webmaster@programmar.com
Copyright © 1998-2008 NorKen Technologies, Inc. All rights reserved.