You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2007/08/30 10:41:20 UTC
svn commit: r571073 - in /geronimo/sandbox/gshell/trunk: ./ gshell-core/
gshell-core/src/main/grammar/ gshell-parser/ gshell-parser/src/
gshell-parser/src/main/ gshell-parser/src/main/grammar/
gshell-parser/src/main/java/ gshell-parser/src/main/java/or...
Author: jdillon
Date: Thu Aug 30 01:41:18 2007
New Revision: 571073
URL: http://svn.apache.org/viewvc?rev=571073&view=rev
Log:
Move the new antlr3 cl parser to gshell-parser module
Added:
geronimo/sandbox/gshell/trunk/gshell-parser/
geronimo/sandbox/gshell/trunk/gshell-parser/pom.xml (with props)
geronimo/sandbox/gshell/trunk/gshell-parser/src/
geronimo/sandbox/gshell/trunk/gshell-parser/src/main/
geronimo/sandbox/gshell/trunk/gshell-parser/src/main/grammar/
geronimo/sandbox/gshell/trunk/gshell-parser/src/main/grammar/CommandLine.g
geronimo/sandbox/gshell/trunk/gshell-parser/src/main/java/
geronimo/sandbox/gshell/trunk/gshell-parser/src/main/java/org/
geronimo/sandbox/gshell/trunk/gshell-parser/src/main/java/org/apache/
geronimo/sandbox/gshell/trunk/gshell-parser/src/main/java/org/apache/geronimo/
geronimo/sandbox/gshell/trunk/gshell-parser/src/main/java/org/apache/geronimo/gshell/
geronimo/sandbox/gshell/trunk/gshell-parser/src/main/java/org/apache/geronimo/gshell/parser/
geronimo/sandbox/gshell/trunk/gshell-parser/src/main/resources/
geronimo/sandbox/gshell/trunk/gshell-parser/src/site/
geronimo/sandbox/gshell/trunk/gshell-parser/src/site/apt/
geronimo/sandbox/gshell/trunk/gshell-parser/src/site/site.xml (with props)
geronimo/sandbox/gshell/trunk/gshell-parser/src/test/
geronimo/sandbox/gshell/trunk/gshell-parser/src/test/java/
geronimo/sandbox/gshell/trunk/gshell-parser/src/test/java/org/
geronimo/sandbox/gshell/trunk/gshell-parser/src/test/java/org/apache/
geronimo/sandbox/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/
geronimo/sandbox/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/
geronimo/sandbox/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/
geronimo/sandbox/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserTest.java (with props)
geronimo/sandbox/gshell/trunk/gshell-parser/src/test/resources/
Removed:
geronimo/sandbox/gshell/trunk/gshell-core/src/main/grammar/SyntaxParser.g
Modified:
geronimo/sandbox/gshell/trunk/gshell-core/pom.xml
geronimo/sandbox/gshell/trunk/javacc-maven-plugin/pom.xml
geronimo/sandbox/gshell/trunk/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=571073&r1=571072&r2=571073&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/pom.xml Thu Aug 30 01:41:18 2007
@@ -78,7 +78,7 @@
<plugin>
<groupId>org.apache.geronimo.gshell</groupId>
<artifactId>javacc-maven-plugin</artifactId>
- <version>1.0-alpha-1-SNAPSHOT</version>
+ <version>${pom.version}</version>
<executions>
<execution>
<id>jjtree</id>
Added: geronimo/sandbox/gshell/trunk/gshell-parser/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-parser/pom.xml?rev=571073&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-parser/pom.xml (added)
+++ geronimo/sandbox/gshell/trunk/gshell-parser/pom.xml Thu Aug 30 01:41:18 2007
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.geronimo.gshell</groupId>
+ <artifactId>gshell</artifactId>
+ <version>1.0-alpha-1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>gshell-parser</artifactId>
+ <name>GShell Parser</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr-runtime</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>antlr3-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>antlr</goal>
+ </goals>
+ <configuration>
+ <sourceDirectory>${pom.basedir}/src/main/grammar</sourceDirectory>
+ <inclues>
+ <include>CommandLine.g</include>
+ </inclues>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
Propchange: geronimo/sandbox/gshell/trunk/gshell-parser/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-parser/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-parser/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/sandbox/gshell/trunk/gshell-parser/src/main/grammar/CommandLine.g
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-parser/src/main/grammar/CommandLine.g?rev=571073&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-parser/src/main/grammar/CommandLine.g (added)
+++ geronimo/sandbox/gshell/trunk/gshell-parser/src/main/grammar/CommandLine.g Thu Aug 30 01:41:18 2007
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+
+//
+// $Rev$ $Id$
+//
+
+grammar CommandLine;
+
+options {
+ language=Java;
+ output=AST;
+ // k=2;
+ // backtrack=true;
+ // memoize=true;
+}
+
+@header {
+ package org.apache.geronimo.gshell.parser;
+}
+@lexer::header {
+ package org.apache.geronimo.gshell.parser;
+}
+
+//
+// FIXME: Still need to work out whitespace muck, this isn't always happy... :-(
+//
+
+compilationUnit
+ : ( expression^ ( ';' | NewLine | EOF ) )*
+ ;
+
+expression
+ : ( WhiteSpace )* ( argument^ ( WhiteSpace )* )+
+ ;
+
+argument
+ : literal
+ ;
+
+literal
+ : OpaqueStringLiteral
+ | StringLiteral
+ | PlainStringLiteral
+ ;
+
+//
+// Lexer
+//
+
+//
+// FIXME: Need to figure out how to handle \r\n too
+//
+
+NewLine
+ : ( '\n' )
+ ;
+
+WhiteSpace
+ : ( ' ' | '\t' | '\r' ) // { $channel=HIDDEN; }
+ ;
+
+PlainStringLiteral
+ : ( ~( ';' | '\'' | '"' | WhiteSpace ) )+
+ ;
+
+OpaqueStringLiteral
+ : '\'' ( EscapeSequence | ~( '\\' | '\'' ) )* '\''
+ ;
+
+//
+// TODO: Figure out how to parse out ${foo.bar} and "$foo bar", for variable expansion
+//
+
+StringLiteral
+ : '"' ( EscapeSequence | ~( '\\' | '"' ) )* '"'
+ ;
+
+fragment
+EscapeSequence
+ : '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
+ ;
Added: geronimo/sandbox/gshell/trunk/gshell-parser/src/site/site.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-parser/src/site/site.xml?rev=571073&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-parser/src/site/site.xml (added)
+++ geronimo/sandbox/gshell/trunk/gshell-parser/src/site/site.xml Thu Aug 30 01:41:18 2007
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<project name="${project.name}">
+
+ <body>
+
+ ${parentProject}
+
+ ${modules}
+
+ ${reports}
+
+ </body>
+
+</project>
+
+
Propchange: geronimo/sandbox/gshell/trunk/gshell-parser/src/site/site.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-parser/src/site/site.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-parser/src/site/site.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/sandbox/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserTest.java?rev=571073&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserTest.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserTest.java Thu Aug 30 01:41:18 2007
@@ -0,0 +1,54 @@
+/*
+ * 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.geronimo.gshell.parser;
+
+import junit.framework.TestCase;
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.antlr.runtime.tree.Tree;
+
+/**
+ * Tests for the {@link CommandLineParser} class.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CommandLineParserTest
+ extends TestCase
+{
+ public void test1() throws Exception {
+ String input = "a b 'c'; d";
+ CharStream stream = new ANTLRStringStream(input);
+
+ CommandLineLexer lex = new CommandLineLexer(stream);
+ CommonTokenStream tokens = new CommonTokenStream(lex);
+
+ /*
+ CommonTreeNodeStream nodes = new CommonTreeNodeStream((Tree)r.tree);
+ nodes.setTokenStream(tokens);
+ SimpleCWalker walker = new SimpleCWalker(nodes);
+ walker.program();
+ */
+
+ CommandLineParser parser = new CommandLineParser(tokens);
+ CommandLineParser.compilationUnit_return r = parser.compilationUnit();
+ System.out.println("tree="+((Tree)r.tree).toStringTree());
+ }
+}
\ No newline at end of file
Propchange: geronimo/sandbox/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-parser/src/test/java/org/apache/geronimo/gshell/parser/CommandLineParserTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gshell/trunk/javacc-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/javacc-maven-plugin/pom.xml?rev=571073&r1=571072&r2=571073&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/javacc-maven-plugin/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/javacc-maven-plugin/pom.xml Thu Aug 30 01:41:18 2007
@@ -31,7 +31,6 @@
<artifactId>javacc-maven-plugin</artifactId>
<name>JavaCC Maven Plugin</name>
<packaging>maven-plugin</packaging>
- <version>1.0-alpha-1-SNAPSHOT</version>
<description>
Provides integration with JavaCC.
Modified: geronimo/sandbox/gshell/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/pom.xml?rev=571073&r1=571072&r2=571073&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/pom.xml Thu Aug 30 01:41:18 2007
@@ -140,6 +140,12 @@
</dependency>
<dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr-runtime</artifactId>
+ <version>3.0</version>
+ </dependency>
+
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
@@ -243,6 +249,12 @@
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.0</version>
</plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>antlr3-maven-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </plugin>
</plugins>
</pluginManagement>
@@ -319,6 +331,7 @@
<module>gshell-prefs</module>
<module>gshell-bootstrap</module>
<module>javacc-maven-plugin</module>
+ <module>gshell-parser</module>
<module>gshell-api</module>
<module>gshell-core</module>
<module>gshell-cli</module>