Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 69798 invoked from network); 29 Aug 2007 13:17:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Aug 2007 13:17:32 -0000 Received: (qmail 25460 invoked by uid 500); 29 Aug 2007 13:17:28 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 25417 invoked by uid 500); 29 Aug 2007 13:17:28 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 25406 invoked by uid 99); 29 Aug 2007 13:17:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Aug 2007 06:17:28 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Aug 2007 13:18:28 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id AD75C1A9832; Wed, 29 Aug 2007 06:17:09 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r570801 - /geronimo/sandbox/gshell/trunk/gshell-core/src/main/grammar/SyntaxParser.g Date: Wed, 29 Aug 2007 13:17:09 -0000 To: scm@geronimo.apache.org From: jdillon@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070829131709.AD75C1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 - ;