From: <fwi...@us...> - 2008-07-31 20:13:15
|
Revision: 5031 http://jython.svn.sourceforge.net/jython/?rev=5031&view=rev Author: fwierzbicki Date: 2008-07-31 20:13:12 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Fixed generator args check (antlr3.1b2 broke this, fixed it again). Modified Paths: -------------- branches/asm/grammar/Python.g Modified: branches/asm/grammar/Python.g =================================================================== --- branches/asm/grammar/Python.g 2008-07-31 19:50:45 UTC (rev 5030) +++ branches/asm/grammar/Python.g 2008-07-31 20:13:12 UTC (rev 5031) @@ -1051,17 +1051,14 @@ | DOUBLESTAR kwargs=test[expr_contextType.Load] )? )? { if ($a2 != null) { - if ($a1.gen) { + if ($a1.tree.getType() == GenFor) { throwGenExpNotSoleArg($a1.tree); } - //FIXME: not working in 3.1b2 - /* for (int i=0;i<$a2.size();i++) { - if (((argument_return)$a2.get(i)).gen) { + if (((PythonTree)$a2.get(i)).getType() == GenFor) { throwGenExpNotSoleArg(((argument_return)$a2.get(i)).tree); } } - */ } } -> ^(Args argument+) ^(StarArgs $starargs)? ^(KWArgs $kwargs)? @@ -1072,13 +1069,12 @@ ; //argument: test [gen_for] | test '=' test # Really [keyword '='] test -argument[boolean first] returns [boolean gen] +argument[boolean first] : t1=test[expr_contextType.Load] ( (ASSIGN t2=test[expr_contextType.Load]) -> ^(Keyword ^(Arg $t1) ^(Value $t2)?) | gen_for { if (!first) { throwGenExpNotSoleArg($gen_for.tree); } - $gen = true; } -> ^(GenFor $t1 gen_for) | -> ^(Arg $t1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-03 20:17:42
|
Revision: 5071 http://jython.svn.sourceforge.net/jython/?rev=5071&view=rev Author: fwierzbicki Date: 2008-08-03 20:17:40 +0000 (Sun, 03 Aug 2008) Log Message: ----------- Partial fix for #1092 (just a comment no newline). Modified Paths: -------------- branches/asm/grammar/Python.g Modified: branches/asm/grammar/Python.g =================================================================== --- branches/asm/grammar/Python.g 2008-08-03 18:18:34 UTC (rev 5070) +++ branches/asm/grammar/Python.g 2008-08-03 20:17:40 UTC (rev 5071) @@ -1418,6 +1418,6 @@ $channel=HIDDEN; } : {startPos==0}?=> (' '|'\t')* '#' (~'\n')* '\n'+ - | {startPos>0}?=> '#' (~'\n')* // let NEWLINE handle \n unless char pos==0 for '#' + | '#' (~'\n')* // let NEWLINE handle \n unless char pos==0 for '#' ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-03 21:45:51
|
Revision: 5072 http://jython.svn.sourceforge.net/jython/?rev=5072&view=rev Author: fwierzbicki Date: 2008-08-03 21:45:49 +0000 (Sun, 03 Aug 2008) Log Message: ----------- whitespace Modified Paths: -------------- branches/asm/grammar/Python.g Modified: branches/asm/grammar/Python.g =================================================================== --- branches/asm/grammar/Python.g 2008-08-03 20:17:40 UTC (rev 5071) +++ branches/asm/grammar/Python.g 2008-08-03 21:45:49 UTC (rev 5072) @@ -408,9 +408,9 @@ } } - protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) - throws RecognitionException - { + protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) + throws RecognitionException + { if (errorHandler.isRecoverable()) { return super.recoverFromMismatchedToken(input, ttype, follow); } @@ -424,7 +424,7 @@ catch (RecognitionException re) { errorHandler.reportError(this, re); errorHandler.recover(this, input,re); - retval.tree = (PythonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + retval.tree = (PythonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); } } @@ -452,42 +452,40 @@ this.errorHandler = eh; } - /** - * Taken directly from antlr's Lexer.java -- needs to be re-integrated every time + /** + * Taken directly from antlr's Lexer.java -- needs to be re-integrated every time * we upgrade from Antlr (need to consider a Lexer subclass, though the issue would * remain). - */ - public Token nextToken() { - while (true) { - state.token = null; - state.channel = Token.DEFAULT_CHANNEL; - state.tokenStartCharIndex = input.index(); - state.tokenStartCharPositionInLine = input.getCharPositionInLine(); - state.tokenStartLine = input.getLine(); - state.text = null; - if ( input.LA(1)==CharStream.EOF ) { - return Token.EOF_TOKEN; - } - try { - mTokens(); - if ( state.token==null ) { - emit(); - } - else if ( state.token==Token.SKIP_TOKEN ) { - continue; - } - return state.token; - } - catch (NoViableAltException nva) { - errorHandler.reportError(this, nva); - errorHandler.recover(this, nva); // throw out current char and try again - } - catch (RecognitionException re) { - errorHandler.reportError(this, re); - // match() routine has already called recover() - } - } - } + */ + public Token nextToken() { + while (true) { + state.token = null; + state.channel = Token.DEFAULT_CHANNEL; + state.tokenStartCharIndex = input.index(); + state.tokenStartCharPositionInLine = input.getCharPositionInLine(); + state.tokenStartLine = input.getLine(); + state.text = null; + if ( input.LA(1)==CharStream.EOF ) { + return Token.EOF_TOKEN; + } + try { + mTokens(); + if ( state.token==null ) { + emit(); + } + else if ( state.token==Token.SKIP_TOKEN ) { + continue; + } + return state.token; + } catch (NoViableAltException nva) { + errorHandler.reportError(this, nva); + errorHandler.recover(this, nva); // throw out current char and try again + } catch (RecognitionException re) { + errorHandler.reportError(this, re); + // match() routine has already called recover() + } + } + } } //single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE @@ -1376,20 +1374,20 @@ } : {startPos==0}?=> ( {implicitLineJoiningLevel>0}? ( ' ' | '\t' )+ {$channel=HIDDEN;} - | ( ' ' { spaces++; } - | '\t' { spaces += 8; spaces -= (spaces \% 8); } - )+ + | ( ' ' { spaces++; } + | '\t' { spaces += 8; spaces -= (spaces \% 8); } + )+ { - // make a string of n spaces where n is column number - 1 - char[] indentation = new char[spaces]; - for (int i=0; i<spaces; i++) { - indentation[i] = ' '; + // make a string of n spaces where n is column number - 1 + char[] indentation = new char[spaces]; + for (int i=0; i<spaces; i++) { + indentation[i] = ' '; + } + ClassicToken c = new ClassicToken(LEADING_WS,new String(indentation)); + c.setLine(input.getLine()); + c.setCharPositionInLine(input.getCharPositionInLine()); + emit(c); } - ClassicToken c = new ClassicToken(LEADING_WS,new String(indentation)); - c.setLine(input.getLine()); - c.setCharPositionInLine(input.getCharPositionInLine()); - emit(c); - } // kill trailing newline if present and then ignore ( ('\r')? '\n' {if (state.token!=null) state.token.setChannel(HIDDEN); else $channel=HIDDEN;})* // {state.token.setChannel(99); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-06 02:27:52
|
Revision: 5089 http://jython.svn.sourceforge.net/jython/?rev=5089&view=rev Author: fwierzbicki Date: 2008-08-06 02:27:45 +0000 (Wed, 06 Aug 2008) Log Message: ----------- Extra comment as a reminder about keywords. Modified Paths: -------------- branches/asm/grammar/Python.g Modified: branches/asm/grammar/Python.g =================================================================== --- branches/asm/grammar/Python.g 2008-08-06 02:19:54 UTC (rev 5088) +++ branches/asm/grammar/Python.g 2008-08-06 02:27:45 UTC (rev 5089) @@ -1118,7 +1118,9 @@ //These are all Python keywords that are not Java keywords //This means that Jython needs to support these as NAMEs //unlike CPython. For now I have only done this for 'as' -//and 'exec'. +//and 'exec'. A chat with Leo Soto on #jython has made me +//realize I may need to do this for *all* keywords, since +//a Java foo.getIf() can be called from Jython as foo.if //keyAND : {input.LT(1).getText().equals("and")}? NAME ; keyAS : {input.LT(1).getText().equals("as")}? NAME ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-12 18:40:40
|
Revision: 5160 http://jython.svn.sourceforge.net/jython/?rev=5160&view=rev Author: fwierzbicki Date: 2008-08-12 18:40:38 +0000 (Tue, 12 Aug 2008) Log Message: ----------- Trailing commas not allowed outside of parens. Modified Paths: -------------- branches/asm/grammar/Python.g Modified: branches/asm/grammar/Python.g =================================================================== --- branches/asm/grammar/Python.g 2008-08-12 18:24:24 UTC (rev 5159) +++ branches/asm/grammar/Python.g 2008-08-12 18:40:38 UTC (rev 5160) @@ -582,13 +582,13 @@ -> ^(FROM ^(Level DOT*)? ^(Value dotted_name)? ^(IMPORT STAR)) | import_as_names -> ^(FROM ^(Level DOT*)? ^(Value dotted_name)? ^(IMPORT import_as_names)) - | LPAREN import_as_names RPAREN + | LPAREN import_as_names COMMA? RPAREN -> ^(FROM ^(Level DOT*)? ^(Value dotted_name)? ^(IMPORT import_as_names)) ) ; //import_as_names: import_as_name (',' import_as_name)* [','] -import_as_names : import_as_name (COMMA! import_as_name)* (COMMA!)? +import_as_names : import_as_name (COMMA! import_as_name)* ; //import_as_name: NAME [('as' | NAME) NAME] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-14 00:07:35
|
Revision: 5173 http://jython.svn.sourceforge.net/jython/?rev=5173&view=rev Author: fwierzbicki Date: 2008-08-14 00:07:31 +0000 (Thu, 14 Aug 2008) Log Message: ----------- Add EOF check for file_input. Modified Paths: -------------- branches/asm/grammar/Python.g Modified: branches/asm/grammar/Python.g =================================================================== --- branches/asm/grammar/Python.g 2008-08-13 23:35:12 UTC (rev 5172) +++ branches/asm/grammar/Python.g 2008-08-14 00:07:31 UTC (rev 5173) @@ -293,7 +293,7 @@ ; //file_input: (NEWLINE | stmt)* ENDMARKER -file_input : (NEWLINE | stmt)* {debug("parsed file_input");} +file_input : (NEWLINE | stmt)* EOF -> ^(Module stmt*) ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-14 02:00:03
|
Revision: 5175 http://jython.svn.sourceforge.net/jython/?rev=5175&view=rev Author: fwierzbicki Date: 2008-08-14 02:00:01 +0000 (Thu, 14 Aug 2008) Log Message: ----------- Add EOF to single_input. Modified Paths: -------------- branches/asm/grammar/Python.g Modified: branches/asm/grammar/Python.g =================================================================== --- branches/asm/grammar/Python.g 2008-08-14 00:35:01 UTC (rev 5174) +++ branches/asm/grammar/Python.g 2008-08-14 02:00:01 UTC (rev 5175) @@ -287,9 +287,9 @@ } //single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE -single_input : NEWLINE? -> ^(Interactive) - | simple_stmt -> ^(Interactive simple_stmt) - | compound_stmt NEWLINE -> ^(Interactive compound_stmt) +single_input : NEWLINE* EOF -> ^(Interactive) + | simple_stmt NEWLINE* EOF -> ^(Interactive simple_stmt) + | compound_stmt NEWLINE+ EOF -> ^(Interactive compound_stmt) ; //file_input: (NEWLINE | stmt)* ENDMARKER This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-08-14 17:51:37
|
Revision: 5176 http://jython.svn.sourceforge.net/jython/?rev=5176&view=rev Author: fwierzbicki Date: 2008-08-14 17:51:34 +0000 (Thu, 14 Aug 2008) Log Message: ----------- Updated comment. Modified Paths: -------------- branches/asm/grammar/Python.g Modified: branches/asm/grammar/Python.g =================================================================== --- branches/asm/grammar/Python.g 2008-08-14 02:00:01 UTC (rev 5175) +++ branches/asm/grammar/Python.g 2008-08-14 17:51:34 UTC (rev 5176) @@ -56,16 +56,13 @@ * REQUIRES ANTLR v3 * * - * Baby step towards an antlr based Jython parser. - * Terence's Lexer is intact pretty much unchanged, the parser has - * been altered to produce an AST - the AST work started from tne newcompiler - * grammar from Jim Baker minus post-2.3 features. The current parsing - * and compiling strategy looks like this: + * Updated the original parser for Python 2.5 features. The parser has been + * altered to produce an AST - the AST work started from tne newcompiler + * grammar from Jim Baker. The current parsing and compiling strategy looks + * like this: * * Python source->Python.g->simple antlr AST->PythonWalker.g-> * decorated AST (org/python/parser/ast/*)->CodeCompiler(ASM)->.class - * - * for a very limited set of functionality. */ grammar Python; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |