geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r570779 - /geronimo/sandbox/gshell/trunk/gshell-core/src/main/grammar/SyntaxParser.g
Date Wed, 29 Aug 2007 12:28:11 GMT
Author: jdillon
Date: Wed Aug 29 05:28:10 2007
New Revision: 570779

URL: http://svn.apache.org/viewvc?rev=570779&view=rev
Log:
An almost functional replacement for the javacc grammar ala antlr3

Added:
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/grammar/SyntaxParser.g

Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/grammar/SyntaxParser.g
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/grammar/SyntaxParser.g?rev=570779&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/grammar/SyntaxParser.g (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/grammar/SyntaxParser.g Wed Aug 29 05:28:10
2007
@@ -0,0 +1,103 @@
+/*
+ * 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 SyntaxParser;
+
+options {
+	output=AST;
+}
+
+@header {
+	package org.apache.geronimo.gshell.commandline.parser;
+}
+@lexer::header {
+  	package org.apache.geronimo.gshell.commandline.parser;
+}
+
+//
+// FIXME: How can we allow EOF to terminate and expression?
+//
+
+compilationUnit
+	:	( expression ( ';' | NewLine ) | expression EOF )+
+	;
+
+expression
+	:	( ( WhiteSpace )* argument ( WhiteSpace )* )+
+	;
+
+argument
+	:	literal
+	;
+
+literal
+	:	OpaqueStringLiteral | StringLiteral | PlainStringLiteral
+	;	
+
+//
+// Lexer
+//
+
+NewLine
+	:	( '\r\n' | '\n' )
+	;
+
+WhiteSpace
+	:	( ' ' | '\t' | '\r' ) // { $channel=HIDDEN; }
+	;
+
+PlainStringLiteral
+	: 	( ~( ';'| '\'' | '"' | WhiteSpace | NewLine ) )+
+	;
+
+OpaqueStringLiteral
+	:  	'\'' ( EscapeSequence | ~('\'') )* '\''
+    ;
+
+StringLiteral
+    :  	'"' ( EscapeSequence | ~('"') )* '"'
+    ;
+
+fragment
+EscapeSequence
+    :   '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
+    |   UnicodeEscape
+    |   OctalEscape
+	;
+
+fragment
+OctalEscape
+    :   '\\' ('0'..'3') ('0'..'7') ('0'..'7')
+    |   '\\' ('0'..'7') ('0'..'7')
+    |   '\\' ('0'..'7')
+    ;
+
+fragment
+HexDigit
+	:	('0'..'9'|'a'..'f'|'A'..'F')
+	;
+
+fragment
+UnicodeEscape
+    :   '\\' 'u' HexDigit HexDigit HexDigit HexDigit
+    ;



Mime
View raw message