geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r570801 - /geronimo/sandbox/gshell/trunk/gshell-core/src/main/grammar/SyntaxParser.g
Date Wed, 29 Aug 2007 13:17:09 GMT
Author: jdillon
Date: Wed Aug 29 06:17:08 2007
New Revision: 570801

URL: http://svn.apache.org/viewvc?rev=570801&view=rev
Log:
Simplify thigns some, still have some work to get the whitespace handling correct

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

Modified: 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=570801&r1=570800&r2=570801&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/grammar/SyntaxParser.g (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/grammar/SyntaxParser.g Wed Aug 29 06:17:08
2007
@@ -25,6 +25,9 @@
 
 options {
 	output=AST;
+	// k=2;
+	// backtrack=true;
+	// memoize=true;
 }
 
 @header {
@@ -34,12 +37,16 @@
   	package org.apache.geronimo.gshell.commandline.parser;
 }
 
+//
+// FIXME: Still need to work out whitespace muck, this isn't always happy... :-(
+//
+
 compilationUnit
-	:	( expression ( ';' | NewLine ) | expression EOF )+
+	:	( expression ( ';' | NewLine ) | expression EOF )*
 	;
 
 expression
-	:	( ( WhiteSpace )* argument ( WhiteSpace )* )+
+	:	( WhiteSpace )* ( argument ( WhiteSpace )* )+
 	;
 
 argument
@@ -47,15 +54,21 @@
 	;
 
 literal
-	:	OpaqueStringLiteral | StringLiteral | PlainStringLiteral
+	:	OpaqueStringLiteral
+	| 	StringLiteral
+	| 	PlainStringLiteral
 	;	
 
 //
 // Lexer
 //
 
+//
+// FIXME: Need to figure out how to handle \r\n too
+//
+
 NewLine
-	:	( '\r\n' | '\n' )
+	:	( '\n' )
 	;
 
 WhiteSpace
@@ -63,11 +76,11 @@
 	;
 
 PlainStringLiteral
-	: 	( ~( ';'| '\'' | '"' | WhiteSpace | NewLine ) )+
+	: 	( ~( ';' | '\'' | '"' | WhiteSpace | NewLine ) )+
 	;
 
 OpaqueStringLiteral
-	:  	'\'' ( EscapeSequence | ~('\'') )* '\''
+	:  	'\'' ( EscapeSequence | ~( '\\' | '\'' ) )* '\''
     ;
 
 //
@@ -75,29 +88,10 @@
 //
 
 StringLiteral
-    :  	'"' ( EscapeSequence | ~('"') )* '"'
+    :  	'"' ( 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