(C) Eskil Heyn Olsen 1995-2008. void SequenceDefinition(Vector contents) : { Token a; Integer b=null; String t; ASN1Type contentElement; } { a= [b=FieldId()] contentElement=Type() [] { contentElement.fieldId=b; contentElement.nameId = a.toString(); contents.addElement(contentElement); } } Integer FieldId(): { Token b; } { "[" b= "]" { return new Integer(b.toString()); } } void SequenceDefinitions(Vector defs) : {} { SequenceDefinition(defs) ( "," SequenceDefinition(defs) )* } ASN1Type ASN1_Type_Def() : { Token t=null,t2=null; ASN1Type aT = new ASN1Type(); ASN1Sequence seq; ASN1Choice cho; } { aT.sequence=Sequence() { aT.typeId = "Jasn_temporary_variable_FOOBAR"; return aT; } | aT.choice = Choice() { aT.typeId = "Jasn_temporary_variable_FOOBAR_choice"; return aT; } | t= [t2=] { aT.typeId = t.toString(); if(t2!=null) aT.optional = true; return aT; } | [aT.enums=IntegerEnumerations()] [t2=] { aT.builtIn = true; if(t2!=null) { aT.typeId = "Integer"; aT.optional = true; } else aT.typeId = "int"; return aT; } | [t2=] { aT.builtIn = true; if(t2!=null) { aT.typeId = "Boolean"; aT.optional = true; } else aT.typeId = "boolean"; return aT; } | [t2=] { aT.typeId = "String"; aT.builtIn = true; if(t2!=null) aT.optional = true; return aT; } | [t2=] { aT.typeId = "Object"; aT.builtIn = true; if(t2!=null) aT.optional = true; return aT; } | [t2=] { aT.typeId = "Object"; aT.builtIn = true; if(t2!=null) aT.optional = true; return aT; } | [t2=] { aT.typeId = "String"; aT.builtIn = true; if(t2!=null) aT.optional = true; return aT; } | [t2=] { aT.typeId = "java.util.Date"; aT.builtIn = true; if(t2!=null) aT.optional = true; return aT; } | [t2=] { aT.typeId = "byte[]"; aT.builtIn = true; if(t2!=null) aT.optional = true; return aT; } | [aT.enums=IntegerEnumerations()] [t2=] { aT.typeId = "java.util.BitSet"; aT.builtIn = true; if(t2!=null) aT.optional = true; return aT; } | [t2=] { aT.typeId = "boolean"; aT.builtIn = true; aT.nullType = true; if(t2!=null) aT.optional = true; return aT; } } ASN1Type ASN1_Type() : { ASN1Type at; } { at=ASN1_Type_Def() { at.sequenceOf = true; return at; } | at=ASN1_Type_Def() { return at; } } ASN1Type Type() : { ASN1Type at; Token t=null; } { at=ASN1_Type() { at.implicit = true; return at; } | at=ASN1_Type() { return at; } } Vector IntegerEnumerations() : { Vector enums = new Vector(); } { "{" IntegerEnumeration(enums) ("," IntegerEnumeration(enums))* "}" { return enums; } } void IntegerEnumeration(Vector enums) : { Token id,e; } { id = "(" e= ")" { enums.addElement(new ASN1Enum(id.toString(),Integer.parseInt(e.toString()))); } } ASN1Choice Choice() : { ASN1Choice choice = new ASN1Choice(); } { "CHOICE" "{" ChoiceDefinition(choice) [("," ChoiceDefinition(choice))+] "}" { return choice; } } void ChoiceDefinition(ASN1Choice choice) : {} { [FieldId()] Type() | Type() } void Definition(DefinitionTree tree) : { String classid; Integer fid=null; Token imp=null; ASN1Sequence seq; ASN1Type at; ASN1Choice choice; } { classid = SequenceId() [fid=FieldId()] [imp=] at=ASN1_Type() { at.fieldId = fid; if(at.sequence!=null) { seq = new ASN1Sequence(); seq.name = classid; seq.contents = at.sequence.contents; seq.sequenceOf = at.sequenceOf; seq.fieldId = fid; tree.sequence.put(classid,seq); } else if(at.choice!=null) { choice = at.choice; choice.name = classid; choice.fieldId = fid; tree.choice.put(classid,choice); } else tree.oneliners.put(classid,at); } }