geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r419491 - in /geronimo/sandbox/gshell/trunk/gshell-core: pom.xml src/main/grammar/SyntaxParser.jtb
Date Thu, 06 Jul 2006 09:00:51 GMT
Author: jdillon
Date: Thu Jul  6 02:00:50 2006
New Revision: 419491

URL: http://svn.apache.org/viewvc?rev=419491&view=rev
Log:
Adding new/experimental JTB-based SyntaxParser.
This requires MJAVACC-18 be applied for sources to be put into the proper location.

Added:
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/grammar/SyntaxParser.jtb
Modified:
    geronimo/sandbox/gshell/trunk/gshell-core/pom.xml

Modified: geronimo/sandbox/gshell/trunk/gshell-core/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/pom.xml?rev=419491&r1=419490&r2=419491&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/pom.xml Thu Jul  6 02:00:50 2006
@@ -47,9 +47,50 @@
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>javacc-maven-plugin</artifactId>
-                <version>2.1</version>
+                <version>2.2-SNAPSHOT</version>
                 <executions>
                     <execution>
+                        <id>jtb</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>jtb</goal>
+                        </goals>
+                        <configuration>
+                            <sourceDirectory>${pom.basedir}/src/main/grammar</sourceDirectory>
+                            <outputDirectory>${pom.basedir}/target/generated-sources/jtb</outputDirectory>
+                            <timestampDirectory>${pom.basedir}/target/generated-sources/jtb</timestampDirectory>
+                            
+                            <packageName>org.apache.geronimo.gshell.syntax</packageName>
+                            <!--
+                            <nodePackageName>org.apache.geronimo.gshell.syntax</nodePackageName>
+                            <visitorPackageName>org.apache.geronimo.gshell.syntax.visitor</visitorPackageName>
+                            -->
+                            
+                            <supressErrorChecking>false</supressErrorChecking>
+                            <javadocFriendlyComments>true</javadocFriendlyComments>
+                            <descriptiveFieldNames>true</descriptiveFieldNames>
+                            <!--
+                            <nodeParentClass>org.apache.geronimo.gshell.syntax.NodeSupport</nodeParentClass>
+                            -->
+                            <parentPointers>true</parentPointers>
+                            <specialTokens>false</specialTokens>
+                            <printer>true</printer>
+                        </configuration>
+                    </execution>
+                    
+                    <execution>
+                        <id>jtb-javacc</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>javacc</goal>
+                        </goals>
+                        <configuration>
+                            <sourceDirectory>${pom.basedir}/target/generated-sources/jtb</sourceDirectory>
+                            <outputDirectory>${pom.basedir}/target/generated-sources/jtb</outputDirectory>
+                        </configuration>
+                    </execution>
+                    
+                    <execution>
                         <id>jjtree</id>
                         <phase>generate-sources</phase>
                         <goals>
@@ -62,7 +103,7 @@
                     </execution>
 
                     <execution>
-                        <id>javacc</id>
+                        <id>jjtree-javacc</id>
                         <phase>generate-sources</phase>
                         <goals>
                             <goal>javacc</goal>
@@ -104,14 +145,21 @@
                         <phase>generate-sources</phase>
                         <configuration>
                             <tasks>
-                                <mkdir dir="${pom.basedir}/target/generated-sources/jjtree/org/apache/geronimo/gshell/commandline/parser"
/>
+                                <mkdir dir="${pom.basedir}/target/generated-sources/jtb/org/apache/geronimo/gshell/syntax/parser"/>
+                                <move todir="${pom.basedir}/target/generated-sources/jtb/org/apache/geronimo/gshell/syntax/parser">
+                                    <fileset dir="${pom.basedir}/target/generated-sources/jtb">
+                                        <include name="*.java" />
+                                    </fileset>
+                                </move>
+                                
+                                <mkdir dir="${pom.basedir}/target/generated-sources/jjtree/org/apache/geronimo/gshell/commandline/parser"/>
                                 <move todir="${pom.basedir}/target/generated-sources/jjtree/org/apache/geronimo/gshell/commandline/parser">
                                     <fileset dir="${pom.basedir}/target/generated-sources/jjtree">
                                         <include name="*.java" />
                                     </fileset>
                                 </move>
 
-                                <mkdir dir="${pom.basedir}/target/generated-sources/javacc/org/apache/geronimo/gshell/commandline/parser"
/>
+                                <mkdir dir="${pom.basedir}/target/generated-sources/javacc/org/apache/geronimo/gshell/commandline/parser"/>
                                 <move todir="${pom.basedir}/target/generated-sources/javacc/org/apache/geronimo/gshell/commandline/parser">
                                     <fileset dir="${pom.basedir}/target/generated-sources/javacc">
                                         <include name="*.java" />

Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/grammar/SyntaxParser.jtb
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/grammar/SyntaxParser.jtb?rev=419491&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/grammar/SyntaxParser.jtb (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/grammar/SyntaxParser.jtb Thu Jul  6
02:00:50 2006
@@ -0,0 +1,189 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.
+ */
+
+options {
+    STATIC = false;
+    UNICODE_INPUT = true;
+    ERROR_REPORTING = true;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+PARSER_BEGIN(SyntaxParser)
+
+package org.apache.geronimo.gshell.syntax.parser;
+
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.commons.lang.NullArgumentException;
+
+/**
+ * GShell syntax parser.
+ *
+ * @version $Id: CommandLineParser.jjt 418414 2006-06-30 16:08:00 -0700 (Fri, 30 Jun 2006)
jdillon $
+ */
+public class SyntaxParser
+{
+    private static final Log log = LogFactory.getLog(SyntaxParser.class);
+
+    public SyntaxParser() {
+        this(new StringReader(""));
+    }
+    
+    public CommandLine parse(final Reader reader) throws ParseException {
+        if (reader == null) {
+            throw new NullArgumentException("reader");
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("Parsing from reader: " + reader);
+        }
+
+        this.ReInit(reader);
+
+        CommandLine root = CommandLine();
+        
+        if (log.isDebugEnabled()) {
+            log.debug("Root node: " + node);
+        }
+        
+        return root;
+    }
+}
+
+PARSER_END(SyntaxParser)
+
+///////////////////////////////////////////////////////////////////////////////
+
+//
+// WHITE SPACE
+//
+
+<DEFAULT> SKIP :
+{
+    " "
+|   "\t"
+|   "\n"
+|   "\r"
+|   "\f"
+}
+
+//
+// COMMENTS
+//
+
+<DEFAULT> SPECIAL_TOKEN :
+{
+    < COMMENT: "#" (~["\n", "\r"])* ("\n" | "\r" | "\r\n")? >
+}
+
+//
+// STRINGS
+//
+
+<DEFAULT> TOKEN :
+{
+    < STRING:
+      (   (~["\"","\\"," ","\t","\n","\r","\f",";","\"","'"])
+        | ("\\"
+            ( ["n","t","b","r","f","\\","'","\"",";"]
+            | ["0"-"7"] ( ["0"-"7"] )?
+            | ["0"-"3"] ["0"-"7"] ["0"-"7"]
+            )
+          )
+      )+
+    >
+|
+    < OPAQUE_STRING:
+      "'"
+      (   (~["\"","\\","\n","\r"])
+        | ("\\"
+            ( ["n","t","b","r","f","\\","'","\""]
+            | ["0"-"7"] ( ["0"-"7"] )?
+            | ["0"-"3"] ["0"-"7"] ["0"-"7"]
+            )
+          )
+      )*
+      "'"
+    >
+|
+    < QUOTED_STRING:
+      "\""
+      (   (~["\"","\\","\n","\r"])
+        | ("\\"
+            ( ["n","t","b","r","f","\\","'","\""]
+            | ["0"-"7"] ( ["0"-"7"] )?
+            | ["0"-"3"] ["0"-"7"] ["0"-"7"]
+            )
+          )
+      )*
+      "\""
+    >
+}
+
+//
+// SEPARATORS
+//
+
+<DEFAULT> TOKEN :
+{
+    < SEMICOLON: ";" >
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+
+void CommandLine() : {}
+{
+    (
+        Expression() ( ";" [ Expression() ] )* | <EOF>
+    )
+}
+
+void Expression() : {}
+{
+    ( Argument() )+
+}
+
+void Argument() : {}
+{
+    String()
+}
+
+void String() : {}
+{
+    QuotedString() | QpaqueString() | PlainString()
+}
+
+void QuotedString() : {}
+{
+    <QUOTED_STRING>
+}
+
+void QpaqueString() : {}
+{
+    <OPAQUE_STRING>
+}
+
+void PlainString() : {}
+{
+    <STRING>
+}
+



Mime
View raw message