Code

for IDL parsing
authorishmal <ishmal@users.sourceforge.net>
Wed, 18 Jun 2008 22:05:17 +0000 (22:05 +0000)
committerishmal <ishmal@users.sourceforge.net>
Wed, 18 Jun 2008 22:05:17 +0000 (22:05 +0000)
src/dom/work/idl.g [new file with mode: 0644]

diff --git a/src/dom/work/idl.g b/src/dom/work/idl.g
new file mode 100644 (file)
index 0000000..ff70026
--- /dev/null
@@ -0,0 +1,1386 @@
+header {\r
+  package org.apache.yoko.tools.processors.idl;\r
+\r
+  import java.io.*;\r
+  import java.util.Vector;\r
+  import java.util.Hashtable;\r
+ }\r
+\r
+/**\r
+ *  This is a complete parser for the IDL language as defined\r
+ *  by the CORBA 3.0.2 specification.  It will allow those who\r
+ *  need an IDL parser to get up-and-running very quickly.\r
+ *  Though IDL's syntax is very similar to C++, it is also\r
+ *  much simpler, due in large part to the fact that it is\r
+ *  a declarative-only language.\r
+ *\r
+ *  Some things that are not included are: Symbol table construction\r
+ *  (it is not necessary for parsing, btw) and preprocessing (for\r
+ *  IDL compiler #pragma directives). You can use just about any\r
+ *  C or C++ preprocessor, but there is an interesting semantic\r
+ *  issue if you are going to generate code: In C, #include is\r
+ *  a literal include, in IDL, #include is more like Java's import:\r
+ *  It adds definitions to the scope of the parse, but included\r
+ *  definitions are not generated.\r
+ *\r
+ *  Jim Coker, jcoker@magelang.com\r
+ *  Gary Duzan, gduzan@bbn.com\r
+ *  Modified by Edell Nolan May 3, 2007:\r
+ *    We originally used the corba grammar supplied on your site\r
+ *    but it doesn't support forward declaration support for interfaces\r
+ *    we have actually modified the grammar and fixed it. \r
+ */\r
+class IDLParser extends Parser;\r
+options {\r
+       exportVocab=IDL;\r
+       buildAST=true;\r
+       k=4;\r
+}\r
+\r
+specification\r
+       :   (import_dcl)* (definition)+\r
+       ;\r
+\r
+\r
+definition\r
+       :   (   type_dcl SEMI!\r
+           |   const_dcl SEMI!\r
+           |   except_dcl SEMI!\r
+           |   (("abstract" | "local")? "interface") => interf SEMI!\r
+           |   module SEMI!\r
+           |   (("abstract" | "custom")? "valuetype") => value SEMI!\r
+           |   type_id_dcl SEMI!\r
+           |   type_prefix_dcl SEMI!\r
+           |   (("abstract" | "custom")? "eventtype") => event SEMI!\r
+           |   component SEMI!\r
+           |   home_dcl SEMI!\r
+           )\r
+       ;\r
+\r
+module\r
+       :    "module"^\r
+            identifier     \r
+            LCURLY! d:definition_list RCURLY!\r
+       ;\r
+\r
+definition_list\r
+       :   (definition)+\r
+       ;\r
+\r
+interf\r
+    : ( interface_dcl\r
+      | forward_dcl\r
+      )\r
+    ;\r
\r
+// Grammar changed to differentiate between \r
+// forward declared interfaces and empty interfaces\r
+interface_dcl\r
+       :   (( "abstract" | "local" )?\r
+           "interface"^\r
+           identifier\r
+           ( interface_inheritance_spec )?        \r
+           LCURLY interface_body RCURLY) \r
+       ;\r
+       \r
+forward_dcl\r
+       :    ( "abstract" | "local" )?\r
+           "interface"^\r
+           identifier\r
+       ;\r
+\r
+\r
+interface_body\r
+       :   ( export )*\r
+       ;\r
+\r
+export\r
+       :   (   type_dcl SEMI!\r
+           |   const_dcl SEMI!\r
+           |   except_dcl SEMI!\r
+           |   attr_dcl SEMI!\r
+           |   op_dcl SEMI!\r
+           |   type_id_dcl SEMI!\r
+           |   type_prefix_dcl SEMI!\r
+           )\r
+       ;\r
+\r
+\r
+interface_inheritance_spec\r
+       :   COLON^ scoped_name_list\r
+       ;\r
+\r
+interface_name\r
+       :   scoped_name\r
+       ;\r
+\r
+scoped_name_list\r
+       :    scoped_name (COMMA! scoped_name)*\r
+       ;\r
+\r
+\r
+scoped_name\r
+       :   ( SCOPEOP^ )? IDENT^ /* identifier */ (SCOPEOP! identifier)*\r
+       ;\r
+\r
+value\r
+       :   ( value_dcl\r
+           | value_abs_dcl\r
+           | value_box_dcl\r
+           | value_custom_dcl\r
+           | value_forward_dcl\r
+           )\r
+       ;\r
+\r
+value_forward_dcl\r
+       :   "valuetype"^\r
+           identifier\r
+       ;\r
+\r
+value_box_dcl\r
+       :   "valuetype"^\r
+           identifier\r
+           type_spec\r
+       ;\r
+\r
+value_abs_dcl\r
+       :   "abstract"\r
+           "valuetype"^\r
+           identifier\r
+           ( value_abs_full_dcl\r
+           | // value_abs_forward_dcl\r
+           )\r
+       ;\r
+\r
+value_abs_full_dcl\r
+       :   value_inheritance_spec\r
+           LCURLY! ( export )* RCURLY!\r
+       ;\r
+\r
+// value_abs_forward_dcl\r
+//     :\r
+//     ;\r
+\r
+value_dcl\r
+       :   value_header\r
+           LCURLY! ( value_element )* RCURLY!\r
+       ;\r
+\r
+value_custom_dcl\r
+       :   "custom"^\r
+           value_dcl\r
+       ;\r
+\r
+value_header\r
+       :   "valuetype"^\r
+           identifier\r
+           value_inheritance_spec\r
+       ;\r
+\r
+value_inheritance_spec\r
+/*\r
+       :   ( COLON ( "truncatable" )?\r
+             value_name ( COMMA! value_name )*\r
+           )?\r
+           ( "supports" interface_name ( COMMA! interface_name )* )?\r
+       ;\r
+*/\r
+       :   ( value_value_inheritance_spec )?\r
+           ( value_interface_inheritance_spec )?\r
+       ;\r
+\r
+value_value_inheritance_spec\r
+       :   COLON^ ( "truncatable" )?\r
+           value_name ( COMMA! value_name )*\r
+       ;\r
+\r
+value_interface_inheritance_spec\r
+       :   "supports"^ interface_name ( COMMA! interface_name )*\r
+       ;\r
+\r
+value_name\r
+       :   scoped_name\r
+       ;\r
+\r
+value_element\r
+       :   ( export\r
+           | state_member\r
+           | init_dcl\r
+           )\r
+       ;\r
+\r
+state_member\r
+       :   ( "public" | "private" )\r
+           type_spec declarators SEMI!\r
+       ;\r
+\r
+init_dcl\r
+       :   "factory"^ identifier\r
+           LPAREN! (init_param_decls)? RPAREN!\r
+           (raises_expr)?\r
+           SEMI!\r
+       ;\r
+\r
+init_param_decls\r
+       :   init_param_decl ( COMMA! init_param_decl )*\r
+       ;\r
+\r
+init_param_decl\r
+       :   init_param_attribute\r
+           param_type_spec\r
+           simple_declarator\r
+       ;\r
+\r
+init_param_attribute\r
+       :   "in"\r
+       ;\r
+\r
+const_dcl\r
+       :   "const"^ const_type identifier ASSIGN! const_exp\r
+       ;\r
+\r
+const_type\r
+       :   (integer_type) => integer_type\r
+       |   char_type\r
+       |   wide_char_type\r
+       |   boolean_type\r
+       |   floating_pt_type\r
+       |   string_type\r
+       |   wide_string_type\r
+       |   fixed_pt_const_type\r
+       |   scoped_name\r
+       |   octet_type\r
+       ;\r
+\r
+\r
+/*   EXPRESSIONS   */\r
+\r
+const_exp\r
+       :   or_expr\r
+       ;\r
+\r
+or_expr\r
+       :   xor_expr\r
+           ( OR^ // or_op\r
+             xor_expr\r
+           )*\r
+       ;\r
+\r
+// or_op\r
+//     :    OR\r
+//     ;\r
+\r
+\r
+xor_expr\r
+       :   and_expr\r
+           ( XOR^ // xor_op\r
+             and_expr\r
+           )*\r
+       ;\r
+\r
+// xor_op\r
+//     :    XOR\r
+//     ;\r
+\r
+and_expr\r
+       :   shift_expr\r
+           ( AND^ // and_op\r
+             shift_expr\r
+           )*\r
+       ;\r
+\r
+// and_op\r
+//     :    AND\r
+//     ;\r
+\r
+\r
+shift_expr\r
+       :   add_expr\r
+           ( ( LSHIFT^\r
+             | RSHIFT^\r
+             ) // shift_op\r
+           add_expr\r
+           )*\r
+       ;\r
+\r
+// shift_op\r
+//     :    LSHIFT\r
+//     |    RSHIFT\r
+//     ;\r
+\r
+\r
+add_expr\r
+       :   mult_expr\r
+           ( ( PLUS^\r
+             | MINUS^\r
+             ) // add_op\r
+             mult_expr\r
+           )*\r
+       ;\r
+\r
+// add_op\r
+//     :    PLUS\r
+//     |    MINUS\r
+//     ;\r
+\r
+mult_expr\r
+       :   unary_expr\r
+           ( ( STAR^\r
+             | DIV^\r
+             | MOD^\r
+             ) // mult_op\r
+             unary_expr\r
+           )*\r
+       ;\r
+\r
+// mult_op\r
+//     :    STAR\r
+//     |    DIV\r
+//     |    MOD\r
+//     ;\r
+\r
+unary_expr\r
+       :   ( MINUS^\r
+           | PLUS^\r
+           | TILDE^\r
+           ) // unary_operator\r
+           primary_expr\r
+       |   primary_expr\r
+       ;\r
+\r
+// unary_operator\r
+//     :   MINUS\r
+//     |   PLUS\r
+//     |   TILDE\r
+//     ;\r
+\r
+// Node of type TPrimaryExp serves to avoid inf. recursion on tree parse\r
+primary_expr\r
+       :   scoped_name\r
+       |   literal\r
+       |   LPAREN^ const_exp RPAREN\r
+       ;\r
+\r
+literal\r
+       :   integer_literal\r
+       |   string_literal\r
+       |   wide_string_literal\r
+       |   character_literal\r
+       |   wide_character_literal\r
+       |   fixed_pt_literal\r
+       |   floating_pt_literal\r
+       |   boolean_literal\r
+       ;\r
+\r
+boolean_literal\r
+       :   "TRUE"\r
+       |   "FALSE"\r
+       ;\r
+\r
+positive_int_const\r
+       :    const_exp\r
+       ;\r
+\r
+\r
+type_dcl\r
+       :   "typedef"^ type_declarator\r
+       |   (struct_type) => struct_type\r
+       |   (union_type) => union_type\r
+       |   enum_type\r
+       |   "native"^ simple_declarator\r
+       |   constr_forward_decl\r
+       ;\r
+\r
+type_declarator\r
+       :   type_spec declarators\r
+       ;\r
+\r
+type_spec\r
+       :   simple_type_spec\r
+       |   constr_type_spec\r
+       ;\r
+\r
+simple_type_spec\r
+       :   base_type_spec\r
+       |   template_type_spec\r
+       |   scoped_name\r
+       ;\r
+\r
+base_type_spec\r
+       :   (floating_pt_type) => floating_pt_type      \r
+       |   integer_type        \r
+       |   char_type           \r
+       |   wide_char_type              \r
+       |   boolean_type        \r
+       |   octet_type\r
+       |   any_type\r
+       |   object_type\r
+       |   value_base_type\r
+       ;\r
+\r
+template_type_spec\r
+       :   sequence_type\r
+       |   string_type\r
+       |   wide_string_type\r
+       |   fixed_pt_type\r
+       ;\r
+\r
+constr_type_spec\r
+       :   struct_type\r
+       |   union_type\r
+       |   enum_type\r
+       ;\r
+\r
+declarators\r
+       :   declarator (COMMA! declarator)*\r
+       ;\r
+\r
+declarator\r
+       :   simple_declarator\r
+       |   complex_declarator\r
+       ;\r
+\r
+simple_declarator\r
+       :   identifier\r
+       ;\r
+\r
+complex_declarator\r
+       :   array_declarator\r
+       ;\r
+\r
+floating_pt_type\r
+       :   "float"\r
+       |   "double"\r
+       |   "long"^ "double"\r
+       ;\r
+\r
+integer_type\r
+       :  signed_int\r
+       |  unsigned_int\r
+       ;\r
+\r
+signed_int\r
+       :  signed_short_int\r
+       |  signed_long_int\r
+       |  signed_longlong_int\r
+       ;\r
+\r
+signed_short_int\r
+       :  "short"\r
+       ;\r
+\r
+signed_long_int\r
+       :  "long"\r
+       ;\r
+\r
+signed_longlong_int\r
+       :  "long" "long"\r
+       ;\r
+\r
+unsigned_int\r
+       :  unsigned_short_int\r
+       |  unsigned_long_int\r
+       |  unsigned_longlong_int\r
+       ;\r
+\r
+unsigned_short_int\r
+       :  "unsigned" "short"\r
+       ;\r
+\r
+unsigned_long_int\r
+       :  "unsigned" "long"\r
+       ;\r
+\r
+unsigned_longlong_int\r
+       :  "unsigned" "long" "long"\r
+       ;\r
+\r
+char_type\r
+       :   "char"\r
+       ;\r
+\r
+wide_char_type\r
+       :   "wchar"\r
+       ;\r
+\r
+boolean_type\r
+       :   "boolean"\r
+       ;\r
+\r
+octet_type\r
+       :   "octet"\r
+       ;\r
+\r
+any_type\r
+       :   "any"\r
+       ;\r
+\r
+object_type\r
+       :   "Object"\r
+       ;\r
+\r
+struct_type\r
+       :   "struct"^\r
+           identifier\r
+           LCURLY! member_list RCURLY!\r
+       ;\r
+\r
+member_list\r
+       :   (member)+\r
+       ;\r
+\r
+member\r
+       :   type_spec declarators SEMI!\r
+       ;\r
+\r
+union_type\r
+       :   "union"^\r
+           identifier\r
+           "switch"! LPAREN! switch_type_spec RPAREN!\r
+           LCURLY! switch_body RCURLY!\r
+       ;\r
+\r
+switch_type_spec\r
+       :   integer_type\r
+       |   char_type\r
+       |   boolean_type\r
+       |   enum_type\r
+       |   scoped_name\r
+       ;\r
+\r
+switch_body\r
+       :   case_stmt_list\r
+       ;\r
+\r
+case_stmt_list\r
+       :  (case_stmt)+\r
+       ;\r
+\r
+case_stmt\r
+       :   // case_label_list\r
+           ( "case"^ const_exp COLON!\r
+           | "default"^ COLON!\r
+           )+\r
+           element_spec SEMI!\r
+       ;\r
+\r
+// case_label_list\r
+//     :   (case_label)+\r
+//     ;\r
+\r
+\r
+// case_label\r
+//     :   "case"^ const_exp COLON!\r
+//     |   "default"^ COLON!\r
+//     ;\r
+\r
+element_spec\r
+       :   type_spec declarator\r
+       ;\r
+\r
+enum_type\r
+       :   "enum"^ identifier LCURLY! enumerator_list RCURLY!\r
+       ;\r
+\r
+enumerator_list\r
+       :    enumerator (COMMA! enumerator)*\r
+       ;\r
+\r
+enumerator\r
+       :   identifier\r
+       ;\r
+\r
+sequence_type\r
+       :   "sequence"^\r
+            LT! simple_type_spec opt_pos_int GT!\r
+       ;\r
+\r
+opt_pos_int\r
+       :    (COMMA! positive_int_const)?\r
+       ;\r
+\r
+string_type\r
+       :   "string"^ (LT! positive_int_const GT!)?\r
+       ;\r
+\r
+wide_string_type\r
+       :   "wstring"^ (LT! positive_int_const GT!)?\r
+       ;\r
+\r
+array_declarator\r
+       :   IDENT^                                      // identifier\r
+           (fixed_array_size)+\r
+       ;\r
+\r
+fixed_array_size\r
+       :   LBRACK! positive_int_const RBRACK!\r
+       ;\r
+\r
+attr_dcl\r
+       :   readonly_attr_spec\r
+       |   attr_spec\r
+       ;\r
+\r
+except_dcl\r
+       :   "exception"^\r
+           identifier\r
+           LCURLY! opt_member_list RCURLY!\r
+       ;\r
+\r
+\r
+opt_member_list\r
+       :    (member)*\r
+       ;\r
+\r
+op_dcl\r
+       :   (op_attribute)?\r
+           op_type_spec\r
+           IDENT^                              // identifier\r
+           parameter_dcls\r
+           (raises_expr)?\r
+           (context_expr)?\r
+       ;\r
+\r
+op_attribute\r
+       :   "oneway"\r
+       ;\r
+\r
+op_type_spec\r
+       :   param_type_spec\r
+       |   "void"\r
+       ;\r
+\r
+parameter_dcls\r
+       :   LPAREN! (param_dcl_list)? RPAREN!\r
+       ;\r
+\r
+param_dcl_list\r
+       :   param_dcl (COMMA! param_dcl)*\r
+       ;\r
+\r
+param_dcl\r
+       :   ("in"^ | "out"^ | "inout"^)         // param_attribute\r
+           param_type_spec simple_declarator\r
+       ;\r
+\r
+// param_attribute\r
+//     :   "in"\r
+//     |   "out"\r
+//     |   "inout"\r
+//     ;\r
+\r
+raises_expr\r
+       :   "raises"^ LPAREN! scoped_name_list RPAREN!\r
+       ;\r
+\r
+context_expr\r
+       :   "context"^ LPAREN! string_literal_list RPAREN!\r
+       ;\r
+\r
+string_literal_list\r
+       :    string_literal (COMMA! string_literal)*\r
+       ;\r
+\r
+param_type_spec\r
+       :   base_type_spec\r
+       |   string_type\r
+       |   wide_string_type\r
+       |   scoped_name\r
+       ;\r
+\r
+fixed_pt_type\r
+       :   "fixed"^ LT! positive_int_const COMMA! positive_int_const GT!\r
+       ;\r
+\r
+fixed_pt_const_type\r
+       :   "fixed"\r
+       ;\r
+\r
+value_base_type\r
+       :   "ValueBase"\r
+       ;\r
+\r
+constr_forward_decl\r
+       :   "struct"^ identifier\r
+       |   "union"^ identifier\r
+       ;\r
+\r
+import_dcl\r
+       :   "import"^ imported_scope SEMI!\r
+       ;\r
+\r
+imported_scope\r
+       :   scoped_name\r
+       |   string_literal\r
+       ;\r
+\r
+type_id_dcl\r
+       :   "typeid"^\r
+           scoped_name\r
+           string_literal\r
+       ;\r
+\r
+type_prefix_dcl\r
+       :   "typeprefix"^\r
+           scoped_name\r
+           string_literal\r
+       ;\r
+\r
+readonly_attr_spec\r
+       :   "readonly" "attribute"^\r
+           param_type_spec\r
+           readonly_attr_declarator\r
+       ;\r
+\r
+readonly_attr_declarator\r
+       :   simple_declarator\r
+           ( raises_expr\r
+           | (COMMA! simple_declarator)*\r
+           )\r
+       ;\r
+\r
+attr_spec\r
+       :   "attribute"^ param_type_spec attr_declarator\r
+       ;\r
+\r
+attr_declarator\r
+       :   simple_declarator\r
+           ( ("getraises" | "setraises") => attr_raises_expr\r
+           | (COMMA! simple_declarator)*\r
+           )\r
+       ;\r
+\r
+attr_raises_expr\r
+       :   (get_excep_expr)?\r
+           (set_excep_expr)?\r
+       ;\r
+\r
+get_excep_expr\r
+       :   "getraises"^ exception_list\r
+       ;\r
+\r
+set_excep_expr\r
+       :   "setraises"^ exception_list\r
+       ;\r
+\r
+exception_list\r
+       :   LPAREN! scoped_name (COMMA! scoped_name)* RPAREN!\r
+       ;\r
+\r
+// Component Stuff\r
+\r
+component\r
+       :   "component"^\r
+           identifier\r
+           (component_dcl)?\r
+       ;\r
+\r
+component_dcl\r
+       :   (component_inheritance_spec)?\r
+           (supported_interface_spec)?\r
+           LCURLY! component_body RCURLY!\r
+       ;\r
+\r
+supported_interface_spec\r
+       :   "supports"^ scoped_name ( COMMA! scoped_name )*\r
+       ;\r
+\r
+component_inheritance_spec\r
+       :   COLON^ scoped_name\r
+       ;\r
+\r
+component_body\r
+       :   (component_export)*\r
+       ;\r
+\r
+component_export\r
+       :   ( provides_dcl SEMI!\r
+           | uses_dcl SEMI!\r
+           | emits_dcl SEMI!\r
+           | publishes_dcl SEMI!\r
+           | consumes_dcl SEMI!\r
+           | attr_dcl SEMI!\r
+           )\r
+       ;\r
+\r
+provides_dcl\r
+       :   "provides"^ interface_type identifier\r
+       ;\r
+\r
+interface_type\r
+       :   ( scoped_name\r
+           | "Object"\r
+           )\r
+       ;\r
+\r
+uses_dcl\r
+       :   "uses"^ ("multiple")? interface_type identifier\r
+       ;\r
+\r
+emits_dcl\r
+       :   "emits"^ scoped_name identifier\r
+       ;\r
+\r
+publishes_dcl\r
+       :   "publishes"^ scoped_name identifier\r
+       ;\r
+\r
+consumes_dcl\r
+       :   "consumes"^ scoped_name identifier\r
+       ;\r
+\r
+home_dcl\r
+       :   home_header home_body\r
+       ;\r
+\r
+home_header\r
+       :   "home"^ identifier\r
+           (home_inheritance_spec)?\r
+           (supported_interface_spec)?\r
+           "manages"! scoped_name\r
+           (primary_key_spec)?\r
+       ;\r
+\r
+home_inheritance_spec\r
+       :   COLON^ scoped_name\r
+       ;\r
+\r
+primary_key_spec\r
+       :   "primarykey"^ scoped_name\r
+       ;\r
+\r
+home_body\r
+       :   LCURLY! (home_export)* RCURLY!\r
+       ;\r
+\r
+home_export\r
+       :   ( export\r
+           | factory_dcl SEMI!\r
+           | finder_dcl SEMI!\r
+           )\r
+       ;\r
+\r
+factory_dcl\r
+       :   "factory"^ identifier\r
+           LPAREN! init_param_decls RPAREN!\r
+           (raises_expr)?\r
+       ;\r
+\r
+finder_dcl\r
+       :   "finder"^ identifier\r
+           LPAREN! init_param_decls RPAREN!\r
+           (raises_expr)?\r
+       ;\r
+\r
+event\r
+       :   ( event_abs\r
+           | event_custom\r
+           | event_dcl\r
+           )\r
+       ;\r
+\r
+event_header\r
+       :   "eventtype"^\r
+           identifier\r
+       ;\r
+\r
+event_abs\r
+       :   "abstract"^\r
+           event_header\r
+           (event_abs_dcl)?\r
+       ;\r
+\r
+event_abs_dcl\r
+       :   value_inheritance_spec\r
+           LCURLY! (export)* RCURLY!\r
+       ;\r
+\r
+event_custom\r
+       :   "custom"^\r
+           event_header\r
+           event_elem_dcl\r
+       ;\r
+\r
+event_dcl\r
+       :   event_header\r
+           ( event_elem_dcl\r
+           | // event_forward_dcl\r
+           )\r
+       ;\r
+\r
+event_elem_dcl\r
+       :   value_inheritance_spec\r
+           LCURLY! (export)* RCURLY!\r
+       ;\r
+\r
+// event_forward_dcl\r
+//     :\r
+//     ;\r
+\r
+/* literals */\r
+integer_literal\r
+       :   INT\r
+       |   OCTAL\r
+       |   HEX\r
+       ;\r
+\r
+string_literal\r
+       :  (STRING_LITERAL)+\r
+       ;\r
+\r
+wide_string_literal\r
+       :  (WIDE_STRING_LITERAL)+\r
+       ;\r
+\r
+character_literal\r
+       :  CHAR_LITERAL\r
+       ;\r
+\r
+wide_character_literal\r
+       :  WIDE_CHAR_LITERAL\r
+       ;\r
+\r
+fixed_pt_literal\r
+       :  FIXED\r
+       ;\r
+\r
+floating_pt_literal\r
+       :   f:FLOAT\r
+       ;\r
+\r
+identifier\r
+       :   IDENT\r
+       ;\r
+\r
+/* IDL LEXICAL RULES  */\r
+class IDLLexer extends Lexer;\r
+options {\r
+       exportVocab=IDL;\r
+       charVocabulary='\u0000'..'\uFFFE';\r
+       k=4;\r
+}\r
+\r
+SEMI\r
+options {\r
+  paraphrase = ";";\r
+}\r
+       :       ';'\r
+       ;\r
+\r
+QUESTION\r
+options {\r
+  paraphrase = "?";\r
+}\r
+       :       '?'\r
+       ;\r
+\r
+LPAREN\r
+options {\r
+  paraphrase = "(";\r
+}\r
+       :       '('\r
+       ;\r
+\r
+RPAREN\r
+options {\r
+  paraphrase = ")";\r
+}\r
+       :       ')'\r
+       ;\r
+\r
+LBRACK\r
+options {\r
+  paraphrase = "[";\r
+}\r
+       :       '['\r
+       ;\r
+\r
+RBRACK\r
+options {\r
+  paraphrase = "]";\r
+}\r
+       :       ']'\r
+       ;\r
+\r
+LCURLY\r
+options {\r
+  paraphrase = "{";\r
+}\r
+       :       '{'\r
+       ;\r
+\r
+RCURLY\r
+options {\r
+  paraphrase = "}";\r
+}\r
+       :       '}'\r
+       ;\r
+\r
+OR\r
+options {\r
+  paraphrase = "|";\r
+}\r
+       :       '|'\r
+       ;\r
+\r
+XOR\r
+options {\r
+  paraphrase = "^";\r
+}\r
+       :       '^'\r
+       ;\r
+\r
+AND\r
+options {\r
+  paraphrase = "&";\r
+}\r
+       :       '&'\r
+       ;\r
+\r
+COLON\r
+options {\r
+  paraphrase = ":";\r
+}\r
+       :       ':'\r
+       ;\r
+\r
+COMMA\r
+options {\r
+  paraphrase = ",";\r
+}\r
+       :       ','\r
+       ;\r
+\r
+DOT\r
+options {\r
+  paraphrase = ".";\r
+}\r
+       :       '.'\r
+       ;\r
+\r
+ASSIGN\r
+options {\r
+  paraphrase = "=";\r
+}\r
+       :       '='\r
+       ;\r
+\r
+NOT\r
+options {\r
+  paraphrase = "!";\r
+}\r
+       :       '!'\r
+       ;\r
+\r
+LT\r
+options {\r
+  paraphrase = "<";\r
+}\r
+       :       '<'\r
+       ;\r
+\r
+LSHIFT\r
+options {\r
+  paraphrase = "<<";\r
+}\r
+       : "<<"\r
+       ;\r
+\r
+GT\r
+options {\r
+  paraphrase = ">";\r
+}\r
+       :       '>'\r
+       ;\r
+\r
+RSHIFT\r
+options {\r
+  paraphrase = ">>";\r
+}\r
+       : ">>"\r
+       ;\r
+\r
+DIV\r
+options {\r
+  paraphrase = "/";\r
+}\r
+       :       '/'\r
+       ;\r
+\r
+PLUS\r
+options {\r
+  paraphrase = "+";\r
+}\r
+       :       '+'\r
+       ;\r
+\r
+MINUS\r
+options {\r
+  paraphrase = "-";\r
+}\r
+       :       '-'\r
+       ;\r
+\r
+TILDE\r
+options {\r
+  paraphrase = "~";\r
+}\r
+       :       '~'\r
+       ;\r
+\r
+STAR\r
+options {\r
+  paraphrase = "*";\r
+}\r
+       :       '*'\r
+       ;\r
+\r
+MOD\r
+options {\r
+  paraphrase = "%";\r
+}\r
+       :       '%'\r
+       ;\r
+\r
+\r
+SCOPEOP\r
+options {\r
+  paraphrase = "::";\r
+}\r
+       :       "::"\r
+       ;\r
+\r
+WS\r
+options {\r
+  paraphrase = "white space";\r
+}\r
+       :       (' '\r
+       |       '\t'\r
+       |       '\n'  { newline(); }\r
+       |       '\r')\r
+               { $setType(Token.SKIP); }\r
+       ;\r
+\r
+\r
+PREPROC_DIRECTIVE\r
+options {\r
+  paraphrase = "a preprocessor directive";\r
+}\r
+\r
+       :\r
+       '#'!\r
+       (~'\n')* '\n'!\r
+       { $setType(Token.SKIP); newline(); }\r
+       ;\r
+\r
+\r
+SL_COMMENT\r
+options {\r
+  paraphrase = "a comment";\r
+}\r
+\r
+       :\r
+       "//"!\r
+       (~'\n')* '\n'\r
+       { $setType(Token.SKIP); newline(); }\r
+       ;\r
+\r
+ML_COMMENT\r
+options {\r
+  paraphrase = "a comment";\r
+}\r
+       :\r
+       "/*"!\r
+       (\r
+                       '\n' { newline(); }\r
+               |       ('*')+\r
+                       (       '\n' { newline(); }\r
+                       |       ~('*' | '/' | '\n')\r
+                       )\r
+               |       ~('*' | '\n')\r
+       )*\r
+       "*/"!\r
+       { $setType(Token.SKIP);  }\r
+       ;\r
+\r
+CHAR_LITERAL\r
+options {\r
+  paraphrase = "a character literal";\r
+}\r
+       :\r
+       '\''!\r
+       ( ESC | ~'\'' )\r
+       '\''!\r
+       ;\r
+\r
+WIDE_CHAR_LITERAL\r
+options {\r
+  paraphrase = "a wide character literal";\r
+}\r
+       : 'L'! CHAR_LITERAL\r
+       ;\r
+\r
+STRING_LITERAL\r
+options {\r
+  paraphrase = "a string literal";\r
+}\r
+       :\r
+       '"'!\r
+       (ESC|~'"')*\r
+       '"'!\r
+       ;\r
+\r
+\r
+WIDE_STRING_LITERAL\r
+options {\r
+  paraphrase = "a wide string literal";\r
+}\r
+       :\r
+       'L'! STRING_LITERAL\r
+       ;\r
+\r
+protected\r
+ESC\r
+options {\r
+  paraphrase = "an escape sequence";\r
+}\r
+       :       '\\'!\r
+               (       'n'             {$setText("\n");}\r
+               |       't'             {$setText("\t");}\r
+               |       'v'             {$setText("\013");}\r
+               |       'b'             {$setText("\b");}\r
+               |       'r'             {$setText("\r");}\r
+               |       'f'             {$setText("\r");}\r
+               |       'a'             {$setText("\007");}\r
+               |       '\\'            {$setText("\\");}\r
+               |       '?'             {$setText("?");}\r
+               |       '\''            {$setText("'");}\r
+               |       '"'             {$setText("\"");}\r
+               |       OCTDIGIT\r
+                       (options {greedy=true;}:OCTDIGIT\r
+                         (options {greedy=true;}:OCTDIGIT)?\r
+                       )?\r
+                       {char realc = (char) Integer.valueOf($getText, 8).intValue(); $setText(realc);}\r
+               |       'x'! HEXDIGIT\r
+                       (options {greedy=true;}:HEXDIGIT)?\r
+                       {char realc = (char) Integer.valueOf($getText, 16).intValue(); $setText(realc);}\r
+               |       'u'!\r
+                       HEXDIGIT\r
+                       (options {greedy=true;}:HEXDIGIT\r
+                         (options {greedy=true;}:HEXDIGIT\r
+                           (options {greedy=true;}:HEXDIGIT)?\r
+                         )?\r
+                       )?\r
+                       {char realc = (char) Integer.valueOf($getText, 16).intValue(); $setText(realc);}\r
+               )\r
+       ;\r
+\r
+protected\r
+VOCAB\r
+options {\r
+  paraphrase = "an escaped character value";\r
+}\r
+       :       '\3'..'\377'\r
+       ;\r
+\r
+protected\r
+DIGIT\r
+options {\r
+  paraphrase = "a digit";\r
+}\r
+       :       '0'..'9'\r
+       ;\r
+\r
+protected\r
+NONZERODIGIT\r
+options {\r
+  paraphrase = "a non-zero digit";\r
+}\r
+       :       '1'..'9'\r
+       ;\r
+\r
+protected\r
+OCTDIGIT\r
+options {\r
+  paraphrase = "an octal digit";\r
+}\r
+       :       '0'..'7'\r
+       ;\r
+\r
+protected\r
+HEXDIGIT\r
+options {\r
+  paraphrase = "a hexadecimal digit";\r
+}\r
+       :       ('0'..'9' | 'a'..'f' | 'A'..'F')\r
+       ;\r
+\r
+HEX\r
+options {\r
+  paraphrase = "a hexadecimal value value";\r
+}\r
+\r
+       :    ("0x" | "0X") (HEXDIGIT)+\r
+       ;\r
+\r
+INT\r
+options {\r
+  paraphrase = "an integer value";\r
+}\r
+       :    NONZERODIGIT (DIGIT)*                  // base-10\r
+            (  '.' (DIGIT)*\r
+                ( (('e' | 'E') ('+' | '-')? (DIGIT)+)  {$setType(FLOAT);}\r
+                | ('d' | 'D')!                         {$setType(FIXED);}\r
+                |                                      {$setType(FLOAT);}\r
+                )\r
+            |   ('e' | 'E') ('+' | '-')? (DIGIT)+      {$setType(FLOAT);}\r
+            |   ('d' | 'D')!                           {$setType(FIXED);}\r
+            )?\r
+       ;\r
+\r
+OCTAL\r
+options {\r
+  paraphrase = "an octal value";\r
+}\r
+       :    '0'\r
+            ( (DIGIT)+\r
+            | FLOAT                                    {$setType(FLOAT);}\r
+            | ('d' | 'D')!                             {$setType(FIXED);}\r
+            |                                          {$setType(INT);}\r
+            )\r
+       ;\r
+\r
+\r
+FLOAT\r
+options {\r
+  paraphrase = "a floating point value";\r
+}\r
+\r
+       :    '.' (DIGIT)+\r
+            ( ('e' | 'E') ('+' | '-')? (DIGIT)+\r
+            | ('d' | 'D')!                             {$setType(FIXED);}\r
+            )?\r
+       ;\r
+\r
+IDENT\r
+options {\r
+  paraphrase = "an identifer";\r
+  testLiterals = true;\r
+}\r
+\r
+       :   ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*\r
+       ;\r
+\r
+ESCAPED_IDENT\r
+options {\r
+  paraphrase = "an escaped identifer";\r
+  testLiterals = false;                        // redundant, but explicit is good.\r
+}\r
+    // NOTE: Adding a ! to the '_' doesn't seem to work,\r
+    //       so we adjust _begin manually.\r
+\r
+       :   '_' ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*\r
+                                                       {_begin++;$setType(IDENT);}\r
+       ;\r
+\r
+\r