You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by ad...@apache.org on 2007/05/15 17:30:05 UTC
svn commit: r538217 [3/10] - in /labs/dungeon/trunk: ./ asn1-compiler/
asn1-compiler/src/ asn1-compiler/src/main/ asn1-compiler/src/main/antlr/
asn1-compiler/src/main/java/ asn1-compiler/src/main/java/org/
asn1-compiler/src/main/java/org/apache/ asn1-c...
Added: labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/ElementSetSpec.java
URL: http://svn.apache.org/viewvc/labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/ElementSetSpec.java?view=auto&rev=538217
==============================================================================
--- labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/ElementSetSpec.java (added)
+++ labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/ElementSetSpec.java Tue May 15 08:29:41 2007
@@ -0,0 +1,25 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.asn1.compiler.stages.parser.x680.element;
+
+/**
+ * @version $Revision: 531142 $ $Date: $
+ */
+public class ElementSetSpec
+{
+}
Added: labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/Intersection.java
URL: http://svn.apache.org/viewvc/labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/Intersection.java?view=auto&rev=538217
==============================================================================
--- labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/Intersection.java (added)
+++ labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/Intersection.java Tue May 15 08:29:41 2007
@@ -0,0 +1,35 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.asn1.compiler.stages.parser.x680.element;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @version $Revision: 531142 $ $Date: $
+ */
+public class Intersection extends ElementSetSpec
+{
+ private List<Element> elements = new ArrayList<Element>();
+
+ public void addElement( Element element )
+ {
+ elements.add( element );
+ }
+}
Added: labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/LowerEndpoint.java
URL: http://svn.apache.org/viewvc/labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/LowerEndpoint.java?view=auto&rev=538217
==============================================================================
--- labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/LowerEndpoint.java (added)
+++ labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/LowerEndpoint.java Tue May 15 08:29:41 2007
@@ -0,0 +1,61 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.asn1.compiler.stages.parser.x680.element;
+
+import org.apache.asn1.compiler.stages.parser.x680.Value;
+
+
+/**
+ * @version $Revision: 531147 $ $Date: $
+ */
+public class LowerEndpoint
+{
+ private Value value;
+ private boolean min;
+ private boolean open;
+
+ public Value getValue()
+ {
+ return value;
+ }
+
+ public void setValue( Value value )
+ {
+ this.value = value;
+ }
+
+ public boolean isMin()
+ {
+ return min;
+ }
+
+ public void setMin( boolean min )
+ {
+ this.min = min;
+ }
+
+ public boolean isOpen()
+ {
+ return open;
+ }
+
+ public void setOpen( boolean open )
+ {
+ this.open = open;
+ }
+}
Added: labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/Union.java
URL: http://svn.apache.org/viewvc/labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/Union.java?view=auto&rev=538217
==============================================================================
--- labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/Union.java (added)
+++ labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/Union.java Tue May 15 08:29:41 2007
@@ -0,0 +1,35 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.asn1.compiler.stages.parser.x680.element;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @version $Revision: 531142 $ $Date: $
+ */
+public class Union extends ElementSetSpec
+{
+ private List<Intersection> intersections = new ArrayList<Intersection>();
+
+ public void addIntersection( Intersection intersection )
+ {
+ intersections.add( intersection );
+ }
+}
Added: labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/UpperEndpoint.java
URL: http://svn.apache.org/viewvc/labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/UpperEndpoint.java?view=auto&rev=538217
==============================================================================
--- labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/UpperEndpoint.java (added)
+++ labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/UpperEndpoint.java Tue May 15 08:29:41 2007
@@ -0,0 +1,61 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.asn1.compiler.stages.parser.x680.element;
+
+import org.apache.asn1.compiler.stages.parser.x680.Value;
+
+
+/**
+ * @version $Revision: 531147 $ $Date: $
+ */
+public class UpperEndpoint extends Value
+{
+ private Value value;
+ private boolean max;
+ private boolean open;
+
+ public Value getValue()
+ {
+ return value;
+ }
+
+ public void setValue( Value value )
+ {
+ this.value = value;
+ }
+
+ public boolean isMax()
+ {
+ return max;
+ }
+
+ public void setMax( boolean max )
+ {
+ this.max = max;
+ }
+
+ public boolean isOpen()
+ {
+ return open;
+ }
+
+ public void setOpen( boolean open )
+ {
+ this.open = open;
+ }
+}
Added: labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/ValueRange.java
URL: http://svn.apache.org/viewvc/labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/ValueRange.java?view=auto&rev=538217
==============================================================================
--- labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/ValueRange.java (added)
+++ labs/dungeon/trunk/asn1-compiler/src/main/java/org/apache/asn1/compiler/stages/parser/x680/element/ValueRange.java Tue May 15 08:29:41 2007
@@ -0,0 +1,48 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.asn1.compiler.stages.parser.x680.element;
+
+
+/**
+ * @version $Revision: 531147 $ $Date: $
+ */
+public class ValueRange extends Element
+{
+ private LowerEndpoint lowerEndpoint;
+ private UpperEndpoint upperEndpoint;
+
+ public LowerEndpoint getLowerEndpoint()
+ {
+ return lowerEndpoint;
+ }
+
+ public void setLowerEndpoint( LowerEndpoint lowerEndpoint )
+ {
+ this.lowerEndpoint = lowerEndpoint;
+ }
+
+ public UpperEndpoint getUpperEndpoint()
+ {
+ return upperEndpoint;
+ }
+
+ public void setUpperEndpoint( UpperEndpoint upperEndpoint )
+ {
+ this.upperEndpoint = upperEndpoint;
+ }
+}
Added: labs/dungeon/trunk/asn1-compiler/src/main/resources/vm/class.vm
URL: http://svn.apache.org/viewvc/labs/dungeon/trunk/asn1-compiler/src/main/resources/vm/class.vm?view=auto&rev=538217
==============================================================================
--- labs/dungeon/trunk/asn1-compiler/src/main/resources/vm/class.vm (added)
+++ labs/dungeon/trunk/asn1-compiler/src/main/resources/vm/class.vm Tue May 15 08:29:41 2007
@@ -0,0 +1,16 @@
+package $package;
+
+import org.apache.asn1.compiler.runtime.*;
+
+public class $class extends Type
+{
+#foreach( $field in $fieldList )
+ int $field.getName();
+#end
+
+ public $class() { }
+
+ public $class($class other)
+ {
+ }
+}
Added: labs/dungeon/trunk/asn1-compiler/src/main/resources/vm/copyright.vm
URL: http://svn.apache.org/viewvc/labs/dungeon/trunk/asn1-compiler/src/main/resources/vm/copyright.vm?view=auto&rev=538217
==============================================================================
--- labs/dungeon/trunk/asn1-compiler/src/main/resources/vm/copyright.vm (added)
+++ labs/dungeon/trunk/asn1-compiler/src/main/resources/vm/copyright.vm Tue May 15 08:29:41 2007
@@ -0,0 +1,17 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
Added: labs/dungeon/trunk/asn1-compiler/src/test/java/org/apache/asn1/compiler/CompilerTest.java
URL: http://svn.apache.org/viewvc/labs/dungeon/trunk/asn1-compiler/src/test/java/org/apache/asn1/compiler/CompilerTest.java?view=auto&rev=538217
==============================================================================
--- labs/dungeon/trunk/asn1-compiler/src/test/java/org/apache/asn1/compiler/CompilerTest.java (added)
+++ labs/dungeon/trunk/asn1-compiler/src/test/java/org/apache/asn1/compiler/CompilerTest.java Tue May 15 08:29:41 2007
@@ -0,0 +1,79 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.asn1.compiler;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import junit.framework.TestCase;
+
+import org.apache.asn1.compiler.stages.codegen.CodeGeneratorStage;
+import org.apache.asn1.compiler.stages.parser.ParseStage;
+
+
+/**
+ * @version $Revision: 531147 $ $Date: $
+ */
+public class CompilerTest extends TestCase
+{
+ private String basedir;
+
+ public void testLDAP() throws Exception
+ {
+ Compiler compiler = new Compiler();
+ Map environment = new HashMap();
+
+ System.err.println( basedir );
+ environment.put( ParseStage.SRC_URI, Thread.currentThread().getContextClassLoader().getResource( "./ldap.asn1" ).toString() );
+ environment.put( CodeGeneratorStage.ROOT_PACKAGE, "org.apache.ldap.asn1" );
+ environment.put( CodeGeneratorStage.DESTINATION_PATH, basedir );
+
+ compiler.compile( environment );
+ }
+
+ public void testSPNEGO() throws Exception
+ {
+ Compiler compiler = new Compiler();
+ Map environment = new HashMap();
+
+ environment.put( ParseStage.SRC_URI, Thread.currentThread().getContextClassLoader().getResource( "./SPNEGO.asn1" ).toString() );
+ environment.put( CodeGeneratorStage.ROOT_PACKAGE, "org.apache.SPNEGO.asn1" );
+ environment.put( CodeGeneratorStage.DESTINATION_PATH, basedir );
+
+ compiler.compile( environment );
+ }
+
+ public void testNBAP() throws Exception
+ {
+ Compiler compiler = new Compiler();
+ Map environment = new HashMap();
+
+ environment.put( ParseStage.SRC_URI, Thread.currentThread().getContextClassLoader().getResource( "./NBAP-25433-530.asn1" ).toString() );
+ environment.put( CodeGeneratorStage.ROOT_PACKAGE, "org.apache.NBAP.asn1" );
+ environment.put( CodeGeneratorStage.DESTINATION_PATH, basedir );
+
+ compiler.compile( environment );
+ }
+
+ public void setUp() throws Exception
+ {
+ File file = new File( System.getProperty( "basedir" ), "./target/test-code" );
+ file.mkdirs();
+ basedir = file.getCanonicalPath();
+ }
+}
\ No newline at end of file
Added: labs/dungeon/trunk/asn1-compiler/src/test/java/org/apache/asn1/compiler/stages/parser/ASN1SyntaxTest.java
URL: http://svn.apache.org/viewvc/labs/dungeon/trunk/asn1-compiler/src/test/java/org/apache/asn1/compiler/stages/parser/ASN1SyntaxTest.java?view=auto&rev=538217
==============================================================================
--- labs/dungeon/trunk/asn1-compiler/src/test/java/org/apache/asn1/compiler/stages/parser/ASN1SyntaxTest.java (added)
+++ labs/dungeon/trunk/asn1-compiler/src/test/java/org/apache/asn1/compiler/stages/parser/ASN1SyntaxTest.java Tue May 15 08:29:41 2007
@@ -0,0 +1,88 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.asn1.compiler.stages.parser;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.StringReader;
+import junit.framework.TestCase;
+
+import org.apache.asn1.compiler.parser.ASN1Lexer;
+import org.apache.asn1.compiler.parser.ASN1Parser;
+
+
+/**
+ * @version $Revision: 531142 $ $Date: $
+ */
+public class ASN1SyntaxTest extends TestCase
+{
+
+ public void testModules() throws Exception
+ {
+ Environment env = getParser( "FOOBAR DEFINITIONS ::= BEGIN BSTRING ::= BIT STRING END" ).compile();
+ getParser( "FOOBAR { dOOBAR dd(2) 2 } DEFINITIONS ::= BEGIN BSTRING ::= BIT STRING END" ).module_definition();
+ getParser( "FOOBAR { dOOBAR dd(2) 2 } DEFINITIONS AUTOMATIC TAGS ::= BEGIN BSTRING ::= BIT STRING END" ).module_definition();
+ getParser( "FOOBAR { dOOBAR dd(2) 2 } DEFINITIONS AUTOMATIC TAGS EXTENSIBILITY IMPLIED ::= BEGIN BSTRING ::= BIT STRING END" ).module_definition();
+
+
+ env = getParser( new File( Thread.currentThread().getContextClassLoader().getResource( "./ldap.asn1" ).getFile() ) ).compile();
+ }
+
+ public void testTypeAssignment() throws Exception
+ {
+ getParser( "BSTRING ::= BIT STRING" ).type_assignment_test();
+ getParser( "BSTRING ::= BIT STRING {a(1), b(2)}" ).type_assignment_test();
+ getParser( "BSTRING ::= BOOLEAN" ).type_assignment_test();
+ }
+
+ public void testModuleReference() throws Exception
+ {
+ getParser( "FOOBAR" ).module_reference();
+ getParser( "D" ).module_reference();
+ getParser( "D-C" ).module_reference();
+ }
+
+ public void testNumber() throws Exception
+ {
+ getParser( "1.0" ).number();
+ getParser( "1" ).number();
+ getParser( "0" ).number();
+ getParser( "0.123" ).number();
+ getParser( "0.123e-123" ).number();
+ getParser( "0.123e123" ).number();
+ getParser( "0.123E123" ).number();
+ getParser( "''B" ).number();
+ getParser( "'101010'B" ).number();
+ getParser( "'1010 1011 1101 0001'B" ).number();
+ getParser( "''H" ).number();
+ getParser( "'CAFEBABE'H" ).number();
+ getParser( "'CAFE BABE'H" ).number();
+ }
+
+ private ASN1Parser getParser( String src )
+ {
+ ASN1Lexer lexer = new ASN1Lexer( new StringReader( src ) );
+ return new ASN1Parser( lexer );
+ }
+
+ private ASN1Parser getParser( File src ) throws Exception
+ {
+ ASN1Lexer lexer = new ASN1Lexer( new FileReader( src ) );
+ return new ASN1Parser( lexer );
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org