directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r208763 - /directory/asn1/trunk/stub-compiler/src/antlr/asn1.g
Date Fri, 01 Jul 2005 15:54:24 GMT
Author: elecharny
Date: Fri Jul  1 08:54:22 2005
New Revision: 208763

URL: http://svn.apache.org/viewcvs?rev=208763&view=rev
Log:
Just for Alan. It just have been change to reflect some work done on lexical analysis.
Work in progess (a long way to go ...)

Modified:
    directory/asn1/trunk/stub-compiler/src/antlr/asn1.g

Modified: directory/asn1/trunk/stub-compiler/src/antlr/asn1.g
URL: http://svn.apache.org/viewcvs/directory/asn1/trunk/stub-compiler/src/antlr/asn1.g?rev=208763&r1=208762&r2=208763&view=diff
==============================================================================
--- directory/asn1/trunk/stub-compiler/src/antlr/asn1.g (original)
+++ directory/asn1/trunk/stub-compiler/src/antlr/asn1.g Fri Jul  1 08:54:22 2005
@@ -62,10 +62,11 @@
     DefinitiveIdentifier did;
     id = new ModuleIdentifier();
 }
-    : mr=module_reference { id.setModuleReference(mr); } (did=definative_identifier { id.setDefinitiveIdentifier(did);
} )?
+    : mr=module_reference { id.setModuleReference(mr); } 
+     (did=definitive_identifier { id.setDefinitiveIdentifier(did); } )?
     ;
 
-definative_identifier returns [DefinitiveIdentifier id]
+definitive_identifier returns [DefinitiveIdentifier id]
 { id = new DefinitiveIdentifier(); }
     : LEFT_CURLY (definitive_obj_id_component[id])+ RIGHT_CURLY
     ;
@@ -87,7 +88,16 @@
     ;
 
 module_body[Module module]
-    : (assignment[module])+
+    : (exports[module])? (imports[module])? (assignment[module])+
+    ;
+    
+exports[Module module]
+    : EXPORTS (SymbolsExported)? SEMICOLON
+    | EXPORTS ALL SEMICOLON
+    ;
+
+imports[Module module]
+    : IMPORTS (SymbolsImported)? SEMICOLON
     ;
 
 assignment[Module module]
@@ -422,24 +432,24 @@
 
 modules : ( ABSENT );
 
+/* The ASN.1 2002 lexer (X.680) */
 class ASN1Lexer extends Lexer;
 options {
     k=3;
+    
+    // RULE 11.14 ?
     charVocabulary = '\3'..'\377' | '\u1000'..'\u1fff';
 }
 
 /*
- * X.680-0207
+ * X.680-0207 Rule 11.27
  */
 tokens {
     ABSENT = "ABSENT";
     ABSTRACT_SYNTAX = "ABSTRACT-SYNTAX";
     ALL = "ALL";
-    ANY = "ANY";
-    ARGUMENT = "ARGUMENT";
     APPLICATION = "APPLICATION";
     AUTOMATIC = "AUTOMATIC";
-    BASEDNUM = "BASEDNUM";
     BEGIN = "BEGIN";
     BIT = "BIT";
     BMPSTRING = "BMPString";
@@ -448,17 +458,16 @@
     CHARACTER = "CHARACTER";
     CHOICE = "CHOICE";
     CLASS = "CLASS";
-    COMPONENTS = "COMPONENTS";
     COMPONENT = "COMPONENT";
+    COMPONENTS = "COMPONENTS";
     CONSTRAINED = "CONSTRAINED";
+    CONTAINING = "CONTAINING";
     DEFAULT = "DEFAULT";
-    DEFINED= "DEFINED";
     DEFINITIONS = "DEFINITIONS";
     EMBEDDED = "EMBEDDED";
+    ENCODED = "ENCODED";
     END = "END";
     ENUMERATED  = "ENUMERATED";
-    ERROR  = "ERROR";
-    ERRORS = "ERRORS";
     EXCEPT = "EXCEPT";
     EXPLICIT = "EXPLICIT";
     EXPORTS = "EXPORTS";
@@ -479,32 +488,29 @@
     INTEGER = "INTEGER";
     INTERSECTION = "INTERSECTION";
     ISO646_STRING = "ISO646String";
-    LINKED = "LINKED";
     MAX = "MAX";
-    MINUS_INFINITY = "MINUSINFINITY";
     MIN = "MIN";
+    MINUS_INFINITY = "MINUSINFINITY";
     NULL = "NULL";
     NUMERIC_STRING = "NumericString";
-    OBJECT_DESCRIPTOR = "ObjectDescriptor";
     OBJECT = "OBJECT";
+    OBJECT_DESCRIPTOR = "ObjectDescriptor";
     OCTET = "OCTET";
-    OPERATION = "OPERATION";
     OF = "OF";
-    OID = "OID";
     OPTIONAL = "OPTIONAL";
-    PARAMETER = "PARAMETER";
+    PATTERN = "PATTERN";
     PDV = "PDV";
-    PLUS_INFINITY = "PLUSINFINITY";
+    PLUS_INFINITY = "PLUS-INFINITY";
     PRESENT = "PRESENT";
     PRINTABLE_STRING = "PrintableString";
     PRIVATE = "PRIVATE";
     REAL = "REAL";
-    RELATIVE = "RELATIVE";
-    RESULT = "RESULT";
+    RELATIVE_OID = "RELATIVE-OID";
     SEQUENCE = "SEQUENCE";
     SET = "SET";
     SIZE = "SIZE";
     STRING = "STRING";
+    SYNTAX = "SYNTAX";
     T61_STRING = "T61String";
     TAGS = "TAGS";
     TELETEX_STRING = "TeletexString";
@@ -524,41 +530,10 @@
  * X.680-0207
  */
 
-    REFERENCE = "Reference";
+    //REFERENCE = "Reference";
 }
 
-NEWLINE
-    : ((('\r''\n') => '\r''\n') | '\r' | '\n')
-        { newline(); $setType(Token.SKIP); }
-    ;
-
-WS : ( ' ' | '\t' | '\f' ) { $setType(Token.SKIP); } ;
-
-COMMENT : "--" ;
-
-SL_COMMENT
-	: COMMENT
-	  ({ LA(2)!='-' }? '-' | ~('-'|'\n'|'\r'))*
-	  (((('\r''\n') => '\r''\n') | '\r' | '\n') {newline();} | COMMENT)
-        { $setType(Token.SKIP); }
-	;
-
-ASSIGNMENT : "::=";
-
-IDENTIFIER : SMALL_LETTER ( (HYPHEN)? (SMALL_LETTER | CAPITAL_LETTER | DIGIT) )* ;
-TYPEREFERENCE : CAPITAL_LETTER ( (HYPHEN)? (SMALL_LETTER | CAPITAL_LETTER | DIGIT) )* ;
-
-NUMBER : DIGITS (DOT (DIGIT)* (EXPONENT)? { $setType(REAL_NUMBER); } | { $setType(INTEGER_NUMBER);
} ) ;
-
-
-protected DIGITS : ( ('1'..'9') (DIGIT)* | '0' );
-
-protected EXPONENT
-    : ('e'|'E') ('+'|'-')? (DIGIT)+
-    ;
-
-NUMBER_STRING : "'" (HEX_DIGIT | WS)* ("'B" {$setType(BINARY_STRING);} | "'H" {$setType(HEXADECIMAL_STRING);}
);
-
+// Rule 10.1
 protected CAPITAL_LETTER : 'A'..'Z';
 protected SMALL_LETTER : 'a'..'z';
 protected DIGIT : '0'..'9';
@@ -587,6 +562,101 @@
 LEFT_CURLY : '{';
 BAR : '|';
 RIGHT_CURLY : '}';
+
+// Rule 11.1.6 (for newline)
+NEWLINE
+    : ((('\r''\n') => '\r''\n') | '\r' | '\n' | '\u000B')   // We have Linux/W$ CR, 
+    													// and also Vertical Tabulation
+        { newline(); $setType(Token.SKIP); }
+    ;
+
+// Rule 11.1.6 (for white-space)
+// "NOTE - Any character or character sequence that is a valid newline is also a valid WS"
+WS : ( NEWLINE | ' ' | '\t' | '\f' ) { $setType(Token.SKIP); } ; 
+
+// Rules 11.2 & 11.5 (Module References and Type references are lexically the same)
+TYPEREFERENCE : CAPITAL_LETTER ( (HYPHEN)? (SMALL_LETTER | CAPITAL_LETTER | DIGIT) )* ;
+
+// Rules 11.3 & 11.4 (Identifiers and Value References are lexically the same)
+IDENTIFIER : SMALL_LETTER ( (HYPHEN)? (SMALL_LETTER | CAPITAL_LETTER | DIGIT) )* ;
+
+// Rule 11.6
+COMMENT : "--" ;
+
+SL_COMMENT
+	: COMMENT
+	  ({ LA(2)!='-' }? '-' | ~('-'|'\n'|'\r'))*
+	  (((('\r''\n') => '\r''\n') | '\r' | '\n') {newline();} | COMMENT)
+        { $setType(Token.SKIP); }
+	;
+	
+// Multi lines comment /* ... */. Actually, we are not dealing with the rule
+// 11.6.4, which states that if a /* is found into a ML comment, then we must
+// match it with a */ :
+//  /* this is a comment /* this is a comment inside a comment */ we are
+//  still in the first comment. This closes the comment ->*/
+ML_COMMENT
+    : "/*" 
+    (
+    	{ LA(2) != '/' }? '*' 
+    | NEWLINE { newline(); } 
+    | .
+    )* 
+    "*/" 
+    { $setType( Token.SKIP ); }
+    ;
+
+// Rule 11.7 EMPTY
+
+// Rule 11.8
+NUMBER : FIRST_DIGIT (DIGIT)* { $setType(INTEGER_NUMBER); } ;
+
+// Rule 11.9
+REAL_NUMBER : (DIGIT)+ DOT (DIGIT)* (EXPONENT)? { $setType(REAL_NUMBER); } ;
+
+protected FIRST_DIGIT : ('1'..'9') ;
+
+protected EXPONENT
+    : ( 'e' | 'E' ) ( '+' | '-' )? ( DIGIT | ( FIRST_DIGIT ( DIGIT )+ ) )
+    ;
+
+// Rule 11.10
+BINARY_STRINGS : '\'' ( '0' | '1' | WS )* "'B" {$setType(BINARY_STRING);};
+
+// Rule 11.11 TO BE DONE 
+
+// Rule 11.12
+HEX_STRINGS : "'" (HEX_DIGIT | WS)* "'H" {$setType(HEXADECIMAL_STRING);} ;
+
+// Rule 11.13 TO BE DONE 
+
+// Rule 11.15 TO BE DONE 
+
+// Rule 11.16
+ASSIGNMENT : "::=";
+
+// Rule 11.17
 RANGE : "..";
+
+// Rule 11.18
 ELLIPSIS : "...";
+
+// Rule 11.19
+LEFT_VERSION_BRACKETS : "[[";
+
+// Rule 11.20
+RIGTH_VERSION_BRACKETS : "]]";
+
+// Rule 11.21 TO BE DONE
+
+// Rule 11.22 TO BE DONE
+
+// Rule 11.23 TO BE DONE
+
+// Rule 11.24 TO BE DONE
+
+// Rule 11.25 TO BE DONE
+
+
+
 



Mime
View raw message