From: <fwi...@us...> - 2007-12-03 03:00:39
|
Revision: 3758 http://jython.svn.sourceforge.net/jython/?rev=3758&view=rev Author: fwierzbicki Date: 2007-12-02 19:00:36 -0800 (Sun, 02 Dec 2007) Log Message: ----------- another pass at useful grammar work. Modified Paths: -------------- trunk/sandbox/ast/asdl_antlr.py Added Paths: ----------- trunk/sandbox/ast/build.xml trunk/sandbox/ast/grammar/ trunk/sandbox/ast/grammar/Python.g trunk/sandbox/ast/lib/ trunk/sandbox/ast/src/ trunk/sandbox/ast/src/org/ trunk/sandbox/ast/src/org/python/ trunk/sandbox/ast/src/org/python/antlr/ trunk/sandbox/ast/src/org/python/antlr/Main.java trunk/sandbox/ast/src/org/python/antlr/PythonTokenSource.java trunk/sandbox/ast/src/org/python/antlr/PythonTree.java Modified: trunk/sandbox/ast/asdl_antlr.py =================================================================== --- trunk/sandbox/ast/asdl_antlr.py 2007-12-03 00:29:46 UTC (rev 3757) +++ trunk/sandbox/ast/asdl_antlr.py 2007-12-03 03:00:36 UTC (rev 3758) @@ -389,7 +389,7 @@ usage = "Usage: python %s [-o outdir] [grammar]" % sys.argv[0] - OUT_DIR = 'src/org/python/antlr/ast/' + OUT_DIR = 'build/gensrc/org/python/antlr/ast/' try: opts, args = getopt.getopt(sys.argv[1:], 'o:') except: Copied: trunk/sandbox/ast/build.xml (from rev 3720, trunk/sandbox/wierzbicki/antlr/build.xml) =================================================================== --- trunk/sandbox/ast/build.xml (rev 0) +++ trunk/sandbox/ast/build.xml 2007-12-03 03:00:36 UTC (rev 3758) @@ -0,0 +1,70 @@ +<project name="grammar" default="all"> + + <path id="main.classpath"> + <fileset dir="lib"> + <include name="**/*.jar"/> + </fileset> + <pathelement path="build" /> + </path> + + <target name="init"> + <mkdir dir="build/gensrc/org/python/antlr/ast"/> + </target> + + <target name="antlr_gen" depends="init"> + <java classname="org.antlr.Tool"> + <arg value="grammar/Python.g"/> + <arg value="-o"/> + <arg value="build/gensrc/org/python/antlr"/> + <classpath refid="main.classpath"/> + </java> + + <copy todir="." preservelastmodified="true"> + <fileset dir="build/gensrc/org/python/antlr/grammar"> + <include name="Python.tokens" /> + </fileset> + </copy> + + <!-- + <java classname="org.antlr.Tool"> + <arg value="grammar/PythonWalker.g"/> + <arg value="-o"/> + <arg value="build/gensrc/org/python/antlr"/> + <classpath refid="main.classpath"/> + </java> + --> + + </target> + + <target name="compile" depends="init"> + <javac destdir="build" debug="true" + deprecation="false" optimize="false" failonerror="true"> + <src path="src"/> + <src path="build/gensrc"/> + <classpath refid="main.classpath"/> + <classpath location="build"/> + </javac> + + </target> + + <target name="asdl_gen" depends="init"> + <!-- + <apply + verbose="true" + executable="./asdl_antlr.py"> + <fileset dir="." includes="Python.asdl"/> + </apply> + --> + </target> + + <target name="clean"> + <delete dir="build"/> + </target> + + <target name="antlr" depends="antlr_gen, compile"/> + <target name="asdl" depends="asdl_gen, compile"/> + + <target name="all" depends="clean, asdl_gen, antlr_gen, compile"/> + +</project> + Added: trunk/sandbox/ast/grammar/Python.g =================================================================== --- trunk/sandbox/ast/grammar/Python.g (rev 0) +++ trunk/sandbox/ast/grammar/Python.g 2007-12-03 03:00:36 UTC (rev 3758) @@ -0,0 +1,902 @@ +/* + [The 'BSD licence'] + Copyright (c) 2004 Terence Parr and Loring Craymer + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/** Python 2.3.3 Grammar + * + * Terence Parr and Loring Craymer + * February 2004 + * + * Converted to ANTLR v3 November 2005 by Terence Parr. + * + * This grammar was derived automatically from the Python 2.3.3 + * parser grammar to get a syntactically correct ANTLR grammar + * for Python. Then Terence hand tweaked it to be semantically + * correct; i.e., removed lookahead issues etc... It is LL(1) + * except for the (sometimes optional) trailing commas and semi-colons. + * It needs two symbols of lookahead in this case. + * + * Starting with Loring's preliminary lexer for Python, I modified it + * to do my version of the whole nasty INDENT/DEDENT issue just so I + * could understand the problem better. This grammar requires + * PythonTokenStream.java to work. Also I used some rules from the + * semi-formal grammar on the web for Python (automatically + * translated to ANTLR format by an ANTLR grammar, naturally <grin>). + * The lexical rules for python are particularly nasty and it took me + * a long time to get it 'right'; i.e., think about it in the proper + * way. Resist changing the lexer unless you've used ANTLR a lot. ;) + * + * I (Terence) tested this by running it on the jython-2.1/Lib + * directory of 40k lines of Python. + * + * 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: + * + * 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; +options { + ASTLabelType=PythonTree; + output=AST; +} + +tokens { + INDENT; + DEDENT; + + Module; + Test; + Msg; + Stmt; + Import; + ImportFrom; + Name; + Body; + ClassDef; + Bases; + FunctionDef; + Args; + StarArgs; + KWArgs; + Arg; + Arguments; + Assign; + Compare; + Expr; + ExprList; + Tuple; + List; + Dict; + If; + Else; + Elif; + While; + Pass; + Print; + TryExcept; + TryFinally; + Except; + For; + Return; + Yield; + Str; + Num; + IsNot; + In; + NotIn; + Raise; + Type; + Inst; + Tback; + Global; + Exec;Globals;Locals; + Assert; + Ellipsis; + ListComp; + Lambda; + Repr; + BinOp; + ArgList; + Subscript; + SubscriptList; + Target; + Value; + Start; + End; + SliceOp; + UnaryPlus; + UnaryMinus; + UnaryTilde; + Delete; + Default; + Parens; + Alias; + Asname; + Decorator; + Decorators; + With; + GenExpFor; + Id; + Ctx; + Store; +} + +@header { +package org.python.antlr; + +import org.python.antlr.PythonTree; +} + +@lexer::header { +package org.python.antlr; +} + +@lexer::members { +/** Handles context-sensitive lexing of implicit line joining such as + * the case where newline is ignored in cases like this: + * a = [3, + * 4] + */ +int implicitLineJoiningLevel = 0; +int startPos=-1; +} + +//single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE +single_input : NEWLINE! + | simple_stmt + | compound_stmt NEWLINE! + ; + +//file_input: (NEWLINE | stmt)* ENDMARKER +file_input : (NEWLINE | stmt)* + -> ^(Module ^(Body stmt*)) + ; + +//eval_input: testlist NEWLINE* ENDMARKER +eval_input : (NEWLINE!)* testlist (NEWLINE!)* + ; + +//decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE +decorator: AT dotted_name (LPAREN arglist? RPAREN)? NEWLINE + -> ^(Decorator dotted_name ^(ArgList arglist?)) + ; + +//decorators: decorator+ +decorators: decorator+ + ; + +//funcdef: [decorators] 'def' NAME parameters ':' suite +funcdef : decorators? 'def' NAME parameters COLON suite + -> ^(FunctionDef ^(Name NAME) ^(Arguments parameters) ^(Body suite) ^(Decorators decorators)?) + ; + +//parameters: '(' [varargslist] ')' +parameters : LPAREN (varargslist)? RPAREN + -> (varargslist)? + ; + +//varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [','] +varargslist : defparameter (options {greedy=true;}:COMMA defparameter)* + (COMMA + ( STAR starargs=NAME (COMMA DOUBLESTAR kwargs=NAME)? + | DOUBLESTAR kwargs=NAME + )? + )? + -> ^(Arguments defparameter+) ^(StarArgs $starargs)? ^(KWArgs $kwargs)? + | STAR starargs=NAME (COMMA DOUBLESTAR kwargs=NAME)? + -> ^(StarArgs $starargs) ^(KWArgs $kwargs)? + | DOUBLESTAR kwargs=NAME + -> ^(KWArgs $kwargs) + ; + +//not in CPython's Grammar file +defparameter : fpdef (ASSIGN test)? + ; + +//fpdef: NAME | '(' fplist ')' +fpdef : NAME + | LPAREN! fplist RPAREN! + ; + +//fplist: fpdef (',' fpdef)* [','] +fplist : fpdef (options {greedy=true;}:COMMA fpdef)* (COMMA)? + -> fpdef+ + ; + +//stmt: simple_stmt | compound_stmt +stmt : simple_stmt + | compound_stmt + ; + +//simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE +simple_stmt : small_stmt (options {greedy=true;}:SEMI small_stmt)* (SEMI)? NEWLINE + -> small_stmt+ + ; + +//small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt +small_stmt : expr_stmt -> ^(Expr expr_stmt) + | print_stmt + | del_stmt + | pass_stmt + | flow_stmt + | import_stmt + | global_stmt + | exec_stmt + | assert_stmt + ; + +//expr_stmt: testlist (augassign testlist | ('=' testlist)*) +expr_stmt : lhs=testlist + ( (augassign yield_expr -> ^(augassign $lhs yield_expr)) + | (augassign rhs=testlist -> ^(augassign $lhs $rhs)) + | ((assigns) -> ^(Assign ^(Target $lhs) assigns)) + | -> $lhs + ) + ; + +//not in CPython's Grammar file +assigns : assign_testlist+ + | assign_yield+ + ; + +//not in CPython's Grammar file +assign_testlist : (ASSIGN testlist ASSIGN) => ASSIGN testlist -> ^(Target testlist) + | ASSIGN testlist -> ^(Value testlist) + ; + +//not in CPython's Grammar file +assign_yield : (ASSIGN yield_expr ASSIGN) => ASSIGN yield_expr -> ^(Target yield_expr) + | ASSIGN yield_expr -> ^(Value yield_expr) + ; + +//augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//=' +augassign : PLUSEQUAL + | MINUSEQUAL + | STAREQUAL + | SLASHEQUAL + | PERCENTEQUAL + | AMPEREQUAL + | VBAREQUAL + | CIRCUMFLEXEQUAL + | LEFTSHIFTEQUAL + | RIGHTSHIFTEQUAL + | DOUBLESTAREQUAL + | DOUBLESLASHEQUAL + ; + +//print_stmt: 'print' ( [ test (',' test)* [','] ] | '>>' test [ (',' test)+ [','] ] ) +print_stmt : 'print' + ( testlist + | RIGHTSHIFT testlist + )? + -> ^(Print RIGHTSHIFT? testlist?) + ; + +//del_stmt: 'del' exprlist +del_stmt : 'del' exprlist + -> ^(Delete exprlist) + ; + +//pass_stmt: 'pass' +pass_stmt : 'pass' + -> Pass + ; + +//flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt +flow_stmt : break_stmt + | continue_stmt + | return_stmt + | raise_stmt + | yield_stmt + ; + +//break_stmt: 'break' +break_stmt : 'break' + ; + +//continue_stmt: 'continue' +continue_stmt : 'continue' + ; + +//return_stmt: 'return' [testlist] +return_stmt : 'return' (testlist)? + -> ^(Return testlist?) + ; + +//yield_stmt: yield_expr +yield_stmt : yield_expr + ; + +//raise_stmt: 'raise' [test [',' test [',' test]]] +raise_stmt: 'raise' (t1=test (COMMA t2=test (COMMA t3=test)?)?)? + -> ^(Raise ^(Type $t1)? ^(Inst $t2)? ^(Tback $t3)?) + ; + +//import_stmt: import_name | import_from +import_stmt : import_name + | import_from + ; + +//import_name: 'import' dotted_as_names +import_name : 'import' dotted_as_names + -> ^(Import dotted_as_names) + ; + +//XXX: needs work? +//import_from: ('from' ('.'* dotted_name | '.'+) +// 'import' ('*' | '(' import_as_names ')' | import_as_names)) +import_from: 'from' (DOT* dotted_name | DOT+) 'import' + (STAR + -> ^(ImportFrom dotted_name ^(Import STAR)) + | import_as_names + -> ^(ImportFrom dotted_name ^(Import import_as_names)) + | LPAREN import_as_names RPAREN + -> ^(ImportFrom dotted_name ^(Import import_as_names)) + ) + ; + +//import_as_name: NAME [('as' | NAME) NAME] +import_as_name : name=NAME ('as' asname=NAME)? + -> ^(Alias $name ^(Asname $asname)?) + ; + +//dotted_as_name: dotted_name [('as' | NAME) NAME] +dotted_as_name : dotted_name ('as' asname=NAME)? + -> ^(Alias dotted_name ^(Asname NAME)?) + ; + +//import_as_names: import_as_name (',' import_as_name)* [','] +import_as_names : import_as_name (COMMA! import_as_name)* (COMMA!)? + ; + +//dotted_as_names: dotted_as_name (',' dotted_as_name)* +dotted_as_names : dotted_as_name (COMMA! dotted_as_name)* + ; +//dotted_name: NAME ('.' NAME)* +dotted_name : NAME (DOT NAME)* + ; + +//global_stmt: 'global' NAME (',' NAME)* +global_stmt : 'global' NAME (COMMA NAME)* + -> ^(Global NAME+) + ; + +//exec_stmt: 'exec' expr ['in' test [',' test]] +exec_stmt : 'exec' expr ('in' t1=test (COMMA t2=test)?)? + -> ^(Exec expr ^(Globals $t1)? ^(Locals $t2)?) + ; + +//assert_stmt: 'assert' test [',' test] +assert_stmt : 'assert' t1=test (COMMA t2=test)? + -> ^(Assert ^(Test $t1) ^(Msg $t2)?) + ; + +//compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef +compound_stmt : if_stmt + | while_stmt + | for_stmt + | try_stmt + | with_stmt + | funcdef + | classdef + ; + +//if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] +if_stmt: 'if' test COLON ifsuite=suite elif_clause* ('else' COLON elsesuite=suite)? + -> ^(If test $ifsuite elif_clause* ^(Else $elsesuite)?) + ; + +//not in CPython's Grammar file +elif_clause : 'elif' test COLON suite + -> ^(Elif test suite) + ; + +//while_stmt: 'while' test ':' suite ['else' ':' suite] +while_stmt : 'while' test COLON s1=suite ('else' COLON s2=suite)? + -> ^(While test ^(Body $s1) ^(Else $s2)?) + ; + +//for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] +for_stmt : 'for' exprlist 'in' testlist COLON s1=suite ('else' COLON s2=suite)? + -> ^(For exprlist ^(In testlist) ^(Body $s1) ^(Else $s2)?) + ; + +//try_stmt: ('try' ':' suite (except_clause ':' suite)+ #diagram:break +// ['else' ':' suite] | 'try' ':' suite 'finally' ':' suite) +try_stmt : 'try' COLON trysuite=suite + ( (except_clause+ ('else' COLON elsesuite=suite)? + -> ^(TryExcept ^(Body $trysuite) except_clause+ ^(Else $elsesuite)?)) + | ('finally' COLON suite + -> ^(TryFinally suite)) + ) + ; + +//with_stmt: 'with' test [ with_var ] ':' suite +with_stmt: 'with' test (with_var)? COLON suite + -> ^(With test with_var? ^(Body suite)) + ; + +//with_var: ('as' | NAME) expr +with_var: ('as' | NAME) expr + ; + +//except_clause: 'except' [test [',' test]] +except_clause : 'except' (t1=test (COMMA t2=test)?)? COLON suite + -> ^(Except ^(Type $t1)? ^(Name $t2)? ^(Body suite)) + ; + +//suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT +suite : simple_stmt -> ^(Stmt simple_stmt) + | NEWLINE! INDENT (stmt)+ DEDENT + ; + +//FIXME: looks like this one is going to be tough. +//test: or_test ['if' or_test 'else' test] | lambdef +test: or_test //('if' test 'else' test)? + | lambdef + ; + +//or_test: and_test ('or' and_test)* +or_test : and_test ('or'^ and_test)* + ; + +//and_test: not_test ('and' not_test)* +and_test : not_test ('and'^ not_test)* + ; + +//not_test: 'not' not_test | comparison +not_test : 'not'^ not_test + | comparison + ; + +//comparison: expr (comp_op expr)* +comparison: expr (comp_op^ expr)* + ; + +//comparison : expr +// ( ((comp_op expr)+ -> ^(Compare expr (comp_op expr)+)) +// | expr +// ) +// ; + +//comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' +comp_op : LESS + | GREATER + | EQUAL + | GREATEREQUAL + | LESSEQUAL + | ALT_NOTEQUAL + | NOTEQUAL + | 'in' + | 'not' 'in' -> NotIn + | 'is' + | 'is' 'not' -> IsNot + ; + +//expr: xor_expr ('|' xor_expr)* +expr : xor_expr (VBAR^ xor_expr)* + ; + +//xor_expr: and_expr ('^' and_expr)* +xor_expr : and_expr (CIRCUMFLEX^ and_expr)* + ; + +//and_expr: shift_expr ('&' shift_expr)* +and_expr : shift_expr (AMPER^ shift_expr)* + ; + +//shift_expr: arith_expr (('<<'|'>>') arith_expr)* +shift_expr : arith_expr ((LEFTSHIFT^|RIGHTSHIFT^) arith_expr)* + ; + +//arith_expr : lhs=term +// ( ((PLUS) term)+ -> ^(PLUS $lhs term+) +// | ((MINUS) term)+ -> ^(MINUS $lhs term+) +// | -> ^(Expr $lhs) +// ) +// ; + + +//arith_expr: term (('+'|'-') term)* +arith_expr: term ((PLUS^|MINUS^) term)* + ; + +//term: factor (('*'|'/'|'%'|'//') factor)* +term : factor ((STAR^ | SLASH^ | PERCENT^ | DOUBLESLASH^ ) factor)* + ; + +//factor: ('+'|'-'|'~') factor | power +factor : PLUS factor -> ^(UnaryPlus factor) + | MINUS factor -> ^(UnaryMinus factor) + | TILDE factor -> ^(UnaryTilde factor) + | power + ; + +//power: atom trailer* ['**' factor] +power : atom (trailer)* (options {greedy=true;}:DOUBLESTAR^ factor)? + ; + +//atom: '(' [testlist] ')' | '[' [listmaker] ']' | '{' [dictmaker] '}' | '`' testlist1 '`' | NAME | NUMBER | STRING+ +atom : LPAREN + ( yield_expr -> ^(Parens yield_expr) + | testlist_gexp -> ^(Parens testlist_gexp?) + | -> ^(Parens) + ) + RPAREN + | LBRACK (listmaker)? RBRACK -> ^(List listmaker?) + | LCURLY (dictmaker)? RCURLY -> ^(Dict dictmaker?) + | BACKQUOTE testlist BACKQUOTE -> ^(Repr testlist) + | NAME -> ^(Name NAME) + | INT -> ^(Num INT) + | LONGINT -> ^(Num LONGINT) + | FLOAT -> ^(Num FLOAT) + | COMPLEX -> ^(Num COMPLEX) + | (STRING)+ -> ^(Str STRING+) + ; + +//listmaker: test ( list_for | (',' test)* [','] ) +listmaker : test + ( list_for -> ^(ListComp list_for) + | (options {greedy=true;}:COMMA test)* -> test+ + ) (COMMA)? + ; + +//testlist_gexp: test ( gen_for | (',' test)* [','] ) +testlist_gexp : test ( gen_for -> ^(GenExpFor gen_for) + | (options {k=2;}: COMMA test)* -> test+ + ) + (COMMA)? + ; + + +//lambdef: 'lambda' [varargslist] ':' test +lambdef: 'lambda' (varargslist)? COLON test + -> ^(Lambda varargslist? ^(Body test)) + ; + +//trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME +trailer : LPAREN (arglist)? RPAREN -> ^(ArgList arglist?) + | LBRACK subscriptlist RBRACK -> ^(SubscriptList subscriptlist) + | DOT NAME + ; + +//subscriptlist: subscript (',' subscript)* [','] +subscriptlist : subscript (options {greedy=true;}:COMMA subscript)* (COMMA)? + -> subscript+ + ; + +//subscript: '.' '.' '.' | test | [test] ':' [test] [sliceop] +subscript : DOT DOT DOT -> Ellipsis + | t1=test (COLON (t2=test)? (sliceop)?)? -> ^(Subscript ^(Start $t1) ^(End $t2)? ^(SliceOp sliceop)?) + | COLON (test)? (sliceop)? -> ^(Subscript ^(End test)? ^(SliceOp sliceop)?) + ; + +//sliceop: ':' [test] +sliceop : COLON (test)? -> test? + ; + +//exprlist: expr (',' expr)* [','] +exprlist : expr (options {k=2;}: COMMA expr)* (COMMA)? + -> ^(ExprList expr+) + ; + +//testlist: test (',' test)* [','] +testlist : test (options {k=2;}: COMMA test)* (COMMA)? + -> test+ + ; + +//XXX: +//testlist_safe: test [(',' test)+ [',']] + +//dictmaker: test ':' test (',' test ':' test)* [','] +dictmaker : test COLON test + (options {k=2;}:COMMA test COLON test)* (COMMA)? + -> test+ + ; + +//classdef: 'class' NAME ['(' testlist ')'] ':' suite +classdef: 'class' NAME (LPAREN testlist RPAREN)? COLON suite + -> ^(ClassDef ^(Name NAME) ^(Bases testlist)? ^(Body suite)) + ; + +//arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**' test) +arglist : argument (COMMA argument)* + ( COMMA + ( STAR starargs=test (COMMA DOUBLESTAR kwargs=test)? + | DOUBLESTAR kwargs=test + )? + )? + -> ^(Arguments argument+) ^(StarArgs $starargs)? ^(KWArgs $kwargs)? + | STAR starargs=test (COMMA DOUBLESTAR kwargs=test)? + -> ^(StarArgs $starargs) ^(KWArgs $kwargs)? + | DOUBLESTAR kwargs=test + -> ^(KWArgs $kwargs) + ; + +//argument: [test '='] test // Really [keyword '='] test +argument : t1=test (ASSIGN t2=test)? + -> ^(Arg $t1 ^(Default $t2)?) + ; + +//list_iter: list_for | list_if +list_iter : list_for + | list_if + ; + +//list_for: 'for' exprlist 'in' testlist_safe [list_iter] +list_for : 'for' exprlist 'in' testlist (list_iter)? + ; + +//list_if: 'if' test [list_iter] +list_if : 'if' test (list_iter)? + ; + +//gen_iter: gen_for | gen_if +gen_iter: gen_for + | gen_if + ; + +//gen_for: 'for' exprlist 'in' or_test [gen_iter] +gen_for: 'for' exprlist 'in' or_test gen_iter? + ; + +//gen_if: 'if' old_test [gen_iter] +gen_if: 'if' test gen_iter? + ; + +//yield_expr: 'yield' [testlist] +yield_expr : 'yield' testlist? + -> ^(Yield testlist?) + ; + +//XXX: +//testlist1: test (',' test)* + + +LPAREN : '(' {implicitLineJoiningLevel++;} ; + +RPAREN : ')' {implicitLineJoiningLevel--;} ; + +LBRACK : '[' {implicitLineJoiningLevel++;} ; + +RBRACK : ']' {implicitLineJoiningLevel--;} ; + +COLON : ':' ; + +COMMA : ',' ; + +SEMI : ';' ; + +PLUS : '+' ; + +MINUS : '-' ; + +STAR : '*' ; + +SLASH : '/' ; + +VBAR : '|' ; + +AMPER : '&' ; + +LESS : '<' ; + +GREATER : '>' ; + +ASSIGN : '=' ; + +PERCENT : '%' ; + +BACKQUOTE : '`' ; + +LCURLY : '{' {implicitLineJoiningLevel++;} ; + +RCURLY : '}' {implicitLineJoiningLevel--;} ; + +CIRCUMFLEX : '^' ; + +TILDE : '~' ; + +EQUAL : '==' ; + +NOTEQUAL : '!=' ; + +ALT_NOTEQUAL: '<>' ; + +LESSEQUAL : '<=' ; + +LEFTSHIFT : '<<' ; + +GREATEREQUAL : '>=' ; + +RIGHTSHIFT : '>>' ; + +PLUSEQUAL : '+=' ; + +MINUSEQUAL : '-=' ; + +DOUBLESTAR : '**' ; + +STAREQUAL : '*=' ; + +DOUBLESLASH : '//' ; + +SLASHEQUAL : '/=' ; + +VBAREQUAL : '|=' ; + +PERCENTEQUAL : '%=' ; + +AMPEREQUAL : '&=' ; + +CIRCUMFLEXEQUAL : '^=' ; + +LEFTSHIFTEQUAL : '<<=' ; + +RIGHTSHIFTEQUAL : '>>=' ; + +DOUBLESTAREQUAL : '**=' ; + +DOUBLESLASHEQUAL : '//=' ; + +DOT : '.' ; + +AT : '@' ; + +FLOAT + : '.' DIGITS (Exponent)? + | DIGITS ('.' (DIGITS (Exponent)?)? | Exponent) + ; + +LONGINT + : INT ('l'|'L') + ; + +fragment +Exponent + : ('e' | 'E') ( '+' | '-' )? DIGITS + ; + +INT : // Hex + '0' ('x' | 'X') ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+ + | // Octal + '0' DIGITS* + | '1'..'9' DIGITS* + ; + +COMPLEX + : INT ('j'|'J') + | FLOAT ('j'|'J') + ; + +fragment +DIGITS : ( '0' .. '9' )+ ; + +NAME: ( 'a' .. 'z' | 'A' .. 'Z' | '_') + ( 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' )* + ; + +/** Match various string types. Note that greedy=false implies ''' + * should make us exit loop not continue. + */ +STRING + : ('r'|'u'|'ur')? + ( '\'\'\'' (options {greedy=false;}:.)* '\'\'\'' + | '"""' (options {greedy=false;}:.)* '"""' + | '"' (ESC|~('\\'|'\n'|'"'))* '"' + | '\'' (ESC|~('\\'|'\n'|'\''))* '\'' + ) + ; + +fragment +ESC + : '\\' . + ; + +/** Consume a newline and any whitespace at start of next line */ +CONTINUED_LINE + : '\\' ('\r')? '\n' (' '|'\t')* { $channel=HIDDEN; } + ; + +/** Treat a sequence of blank lines as a single blank line. If + * nested within a (..), {..}, or [..], then ignore newlines. + * If the first newline starts in column one, they are to be ignored. + */ +NEWLINE + : (('\r')? '\n' )+ + {if ( startPos==0 || implicitLineJoiningLevel>0 ) + $channel=HIDDEN; + } + ; + +WS : {startPos>0}?=> (' '|'\t')+ {$channel=HIDDEN;} + ; + +/** Grab everything before a real symbol. Then if newline, kill it + * as this is a blank line. If whitespace followed by comment, kill it + * as it's a comment on a line by itself. + * + * Ignore leading whitespace when nested in [..], (..), {..}. + */ +LEADING_WS +@init { + int spaces = 0; +} + : {startPos==0}?=> + ( {implicitLineJoiningLevel>0}? ( ' ' | '\t' )+ {$channel=HIDDEN;} + | ( ' ' { 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] = ' '; + } + String s = new String(indentation); + emit(new ClassicToken(LEADING_WS,new String(indentation))); + } + // kill trailing newline if present and then ignore + ( ('\r')? '\n' {if (token!=null) token.setChannel(HIDDEN); else $channel=HIDDEN;})* + // {token.setChannel(99); } + ) + ; + +/** Comments not on line by themselves are turned into newlines. + + b = a # end of line comment + + or + + a = [1, # weird + 2] + + This rule is invoked directly by nextToken when the comment is in + first column or when comment is on end of nonwhitespace line. + + Only match \n here if we didn't start on left edge; let NEWLINE return that. + Kill if newlines if we live on a line by ourselves + + Consume any leading whitespace if it starts on left edge. + */ +COMMENT +@init { + $channel=HIDDEN; +} + : {startPos==0}?=> (' '|'\t')* '#' (~'\n')* '\n'+ + | {startPos>0}?=> '#' (~'\n')* // let NEWLINE handle \n unless char pos==0 for '#' + ; Copied: trunk/sandbox/ast/lib (from rev 3704, trunk/sandbox/wierzbicki/antlr/lib) Added: trunk/sandbox/ast/src/org/python/antlr/Main.java =================================================================== --- trunk/sandbox/ast/src/org/python/antlr/Main.java (rev 0) +++ trunk/sandbox/ast/src/org/python/antlr/Main.java 2007-12-03 03:00:36 UTC (rev 3758) @@ -0,0 +1,69 @@ +package org.python.antlr; + +import java.io.*; +import org.antlr.runtime.*; +import org.antlr.runtime.tree.*; +import org.antlr.stringtemplate.*; +import org.antlr.stringtemplate.language.*; +import org.python.antlr.PythonLexer; +import org.python.antlr.PythonParser; +import org.python.antlr.PythonTree; +import org.python.antlr.PythonTokenSource; + +//import org.python.antlr.ast.modType; + +public class Main { + // override nextToken to set startPos (this seems too hard) + public static class MyLexer extends PythonLexer { + public MyLexer(CharStream lexer) { + super(lexer); + } + public Token nextToken() { + startPos = getCharPositionInLine(); + return super.nextToken(); + } + } + + public static TreeAdaptor myadaptor = new CommonTreeAdaptor() { + public Object create(Token token) { + return new PythonTree(token); + } + public Object dupNode(Object t) { + if ( t==null ) { + return null; + } + return create(((PythonTree)t).token); + } + }; + + public /*modType*/ void parse(String[] args) throws Exception { + //modType result = null; + CharStream input = new ANTLRFileStream(args[0]); + PythonLexer lexer = new MyLexer(input); + CommonTokenStream tokens = new CommonTokenStream(lexer); + tokens.discardOffChannelTokens(true); + PythonTokenSource indentedSource = new PythonTokenSource(tokens); + tokens = new CommonTokenStream(indentedSource); + //System.out.println("tokens="+tokens.getTokens()); + PythonParser parser = new PythonParser(tokens); + parser.setTreeAdaptor(myadaptor); + try { + PythonParser.file_input_return r = parser.file_input(); + //PythonParser.module_return r = parser.module(); + if (args.length > 1) { + System.out.println(((Tree)r.tree).toStringTree()); + } + CommonTreeNodeStream nodes = new CommonTreeNodeStream((Tree)r.tree); + nodes.setTokenStream(tokens); + //PythonWalker walker = new PythonWalker(nodes); + //result = walker.module(); + } catch (RecognitionException e) { + System.err.println("Error: " + e); + } + //return result; + } + + public static void main(String[] args) throws Exception { + new Main().parse(args); + } +} Added: trunk/sandbox/ast/src/org/python/antlr/PythonTokenSource.java =================================================================== --- trunk/sandbox/ast/src/org/python/antlr/PythonTokenSource.java (rev 0) +++ trunk/sandbox/ast/src/org/python/antlr/PythonTokenSource.java 2007-12-03 03:00:36 UTC (rev 3758) @@ -0,0 +1,292 @@ +package org.python.antlr; + +/* + [The "BSD licence"] + Copyright (c) 2004 Terence Parr and Loring Craymer + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +import org.antlr.runtime.*; +import java.util.*; + +/** Python does not explicitly provide begin and end nesting signals. + Rather, the indentation level indicates when you begin and end. + This is an interesting lexical problem because multiple DEDENT + tokens should be sent to the parser sometimes without a corresponding + input symbol! Consider the following example: + + a=1 + if a>1: + print a + b=3 + + Here the "b" token on the left edge signals that a DEDENT is needed + after the "print a \n" and before the "b". The sequence should be + + ... 1 COLON NEWLINE INDENT PRINT a NEWLINE DEDENT b ASSIGN 3 ... + + For more examples, see the big comment at the bottom of this file. + + This TokenStream normally just passes tokens through to the parser. + Upon NEWLINE token from the lexer, however, an INDENT or DEDENT token + may need to be sent to the parser. The NEWLINE is the trigger for + this class to do it's job. NEWLINE is saved and then the first token + of the next line is examined. If non-leading-whitespace token, + then check against stack for indent vs dedent. If LEADING_WS, then + the column of the next non-whitespace token will dictate indent vs + dedent. The column of the next real token is number of spaces + in the LEADING_WS token + 1 (to move past the whitespace). The + lexer grammar must set the text of the LEADING_WS token to be + the proper number of spaces (and do tab conversion etc...). + + A stack of column numbers is tracked and used to detect changes + in indent level from one token to the next. + + A queue of tokens is built up to hold multiple DEDENT tokens that + are generated. Before asking the lexer for another token via + nextToken(), the queue is flushed first one token at a time. + + Terence Parr and Loring Craymer + February 2004 + */ +public class PythonTokenSource implements TokenSource { + public static final int MAX_INDENTS = 100; + public static final int FIRST_CHAR_POSITION = 0; + + /** The stack of indent levels (column numbers) */ + int[] indentStack = new int[MAX_INDENTS]; + /** stack pointer */ + int sp=-1; // grow upwards + + /** The queue of tokens */ + Vector tokens = new Vector(); + + /** We pull real tokens from this lexer */ + CommonTokenStream stream; + + int lastTokenAddedIndex = -1; + + public PythonTokenSource(PythonLexer lexer) { + } + + public PythonTokenSource(CommonTokenStream stream) { + this.stream = stream; + // "state" of indent level is FIRST_CHAR_POSITION + push(FIRST_CHAR_POSITION); + } + + /** From http://www.python.org/doc/2.2.3/ref/indentation.html + + "Before the first line of the file is read, a single zero is + pushed on the stack; this will never be popped off again. The + numbers pushed on the stack will always be strictly increasing + from bottom to top. At the beginning of each logical line, the + line's indentation level is compared to the top of the + stack. If it is equal, nothing happens. If it is larger, it is + pushed on the stack, and one INDENT token is generated. If it + is smaller, it must be one of the numbers occurring on the + stack; all numbers on the stack that are larger are popped + off, and for each number popped off a DEDENT token is + generated. At the end of the file, a DEDENT token is generated + for each number remaining on the stack that is larger than + zero." + + I use char position in line 0..n-1 instead. + + The DEDENTS possibly needed at EOF are gracefully handled by forcing + EOF to have char pos 0 even though with UNIX it's hard to get EOF + at a non left edge. + */ + public Token nextToken() { + // if something in queue, just remove and return it + if ( tokens.size()>0 ) { + Token t = (Token)tokens.firstElement(); + tokens.removeElementAt(0); + // System.out.println(t); + return t; + } + + insertImaginaryIndentDedentTokens(); + + return nextToken(); + } + + protected void insertImaginaryIndentDedentTokens() + { + Token t = stream.LT(1); + stream.consume(); + + // if not a NEWLINE, doesn't signal indent/dedent work; just enqueue + if ( t.getType()!=PythonLexer.NEWLINE ) { + List hiddenTokens = stream.getTokens(lastTokenAddedIndex+1,t.getTokenIndex()-1); + if ( hiddenTokens!=null ) { + tokens.addAll(hiddenTokens); + } + lastTokenAddedIndex = t.getTokenIndex(); + tokens.addElement(t); + return; + } + + // save NEWLINE in the queue + //System.out.println("found newline: "+t+" stack is "+stackString()); + List hiddenTokens = stream.getTokens(lastTokenAddedIndex+1,t.getTokenIndex()-1); + if ( hiddenTokens!=null ) { + tokens.addAll(hiddenTokens); + } + lastTokenAddedIndex = t.getTokenIndex(); + tokens.addElement(t); + + // grab first token of next line + t = stream.LT(1); + stream.consume(); + + hiddenTokens = stream.getTokens(lastTokenAddedIndex+1,t.getTokenIndex()-1); + if ( hiddenTokens!=null ) { + tokens.addAll(hiddenTokens); + } + lastTokenAddedIndex = t.getTokenIndex(); + + // compute cpos as the char pos of next non-WS token in line + int cpos = t.getCharPositionInLine(); // column dictates indent/dedent + if ( t.getType()==Token.EOF ) { + cpos = -1; // pretend EOF always happens at left edge + } + else if ( t.getType()==PythonLexer.LEADING_WS ) { + cpos = t.getText().length(); + } + + //System.out.println("next token is: "+t); + + // compare to last indent level + int lastIndent = peek(); + //System.out.println("cpos, lastIndent = "+cpos+", "+lastIndent); + if ( cpos > lastIndent ) { // they indented; track and gen INDENT + push(cpos); + //System.out.println("push("+cpos+"): "+stackString()); + Token indent = new ClassicToken(PythonParser.INDENT,""); + indent.setCharPositionInLine(t.getCharPositionInLine()); + indent.setLine(t.getLine()); + tokens.addElement(indent); + } + else if ( cpos < lastIndent ) { // they dedented + // how far back did we dedent? + int prevIndex = findPreviousIndent(cpos); + //System.out.println("dedented; prevIndex of cpos="+cpos+" is "+prevIndex); + // generate DEDENTs for each indent level we backed up over + for (int d=sp-1; d>=prevIndex; d--) { + Token dedent = new ClassicToken(PythonParser.DEDENT,""); + dedent.setCharPositionInLine(t.getCharPositionInLine()); + dedent.setLine(t.getLine()); + tokens.addElement(dedent); + } + sp = prevIndex; // pop those off indent level + } + if ( t.getType()!=PythonLexer.LEADING_WS ) { // discard WS + tokens.addElement(t); + } + } + + // T O K E N S T A C K M E T H O D S + + protected void push(int i) { + if (sp>=MAX_INDENTS) { + throw new IllegalStateException("stack overflow"); + } + sp++; + indentStack[sp] = i; + } + + protected int pop() { + if (sp<0) { + throw new IllegalStateException("stack underflow"); + } + int top = indentStack[sp]; + sp--; + return top; + } + + protected int peek() { + return indentStack[sp]; + } + + /** Return the index on stack of previous indent level == i else -1 */ + protected int findPreviousIndent(int i) { + for (int j=sp-1; j>=0; j--) { + if ( indentStack[j]==i ) { + return j; + } + } + return FIRST_CHAR_POSITION; + } + + public String stackString() { + StringBuffer buf = new StringBuffer(); + for (int j=sp; j>=0; j--) { + buf.append(" "); + buf.append(indentStack[j]); + } + return buf.toString(); + } + +} + +/* More example input / output pairs with code simplified to single chars +------- t1 ------- +a a + b b + c +d +a a \n INDENT b b \n c \n DEDENT d \n EOF +------- t2 ------- +a c + b +c +a c \n INDENT b \n DEDENT c \n EOF +------- t3 ------- +a + b + c +d +a \n INDENT b \n INDENT c \n DEDENT DEDENT d \n EOF +------- t4 ------- +a + c + d + e + f + g + h + i + j + k +a \n INDENT c \n INDENT d \n DEDENT e \n f \n INDENT g \n h \n i \n INDENT j \n DEDENT DEDENT k \n DEDENT EOF +------- t5 ------- +a + b + c + d + e +a \n INDENT b \n c \n INDENT d \n e \n DEDENT DEDENT EOF +*/ Added: trunk/sandbox/ast/src/org/python/antlr/PythonTree.java =================================================================== --- trunk/sandbox/ast/src/org/python/antlr/PythonTree.java (rev 0) +++ trunk/sandbox/ast/src/org/python/antlr/PythonTree.java 2007-12-03 03:00:36 UTC (rev 3758) @@ -0,0 +1,47 @@ +package org.python.antlr; + +import org.antlr.runtime.tree.BaseTree; +import org.antlr.runtime.tree.CommonTree; +import org.antlr.runtime.Token; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.antlr.runtime.RecognitionException; + +public class PythonTree extends CommonTree { + + public PythonTree(Token token) { + super(token); + } + + public String toString() { + if ( isNil() ) { + return "None"; + } + return token.getText().toLowerCase(); + } + + public String toStringTree() { + if ( children==null || children.size()==0 ) { + return this.toString(); + } + StringBuffer buf = new StringBuffer(); + if ( !isNil() ) { + buf.append("("); + buf.append(this.toString()); + buf.append(' '); + } + for (int i = 0; children!=null && i < children.size(); i++) { + BaseTree t = (BaseTree) children.get(i); + if ( i>0 ) { + buf.append(' '); + } + buf.append(t.toStringTree()); + } + if ( !isNil() ) { + buf.append(")"); + } + return buf.toString(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-04 03:08:39
|
Revision: 3763 http://jython.svn.sourceforge.net/jython/?rev=3763&view=rev Author: fwierzbicki Date: 2007-12-03 19:08:38 -0800 (Mon, 03 Dec 2007) Log Message: ----------- pulling in a walker. Modified Paths: -------------- trunk/sandbox/ast/asdl_antlr.py trunk/sandbox/ast/build.xml trunk/sandbox/ast/src/org/python/antlr/Main.java trunk/sandbox/ast/src/org/python/antlr/PythonTree.java Added Paths: ----------- trunk/sandbox/ast/grammar/PythonWalker.g trunk/sandbox/ast/run Modified: trunk/sandbox/ast/asdl_antlr.py =================================================================== --- trunk/sandbox/ast/asdl_antlr.py 2007-12-03 22:52:35 UTC (rev 3762) +++ trunk/sandbox/ast/asdl_antlr.py 2007-12-04 03:08:38 UTC (rev 3763) @@ -57,6 +57,7 @@ print >> self.file, 'package org.python.antlr.ast;' if refersToPythonTree: print >> self.file, 'import org.python.antlr.PythonTree;' + print >> self.file, 'import org.antlr.runtime.Token;' if useDataOutput: print >> self.file, 'import java.io.DataOutputStream;' print >> self.file, 'import java.io.IOException;' @@ -157,6 +158,16 @@ self.open("%sType" % name) self.emit("public abstract class %(name)sType extends PythonTree {" % locals(), depth) + self.emit("public %(name)sType(Token token) {" % locals(), depth+1) + self.emit("super(token);", depth+2) + self.emit("}", depth+1) + self.emit("", 0) + + self.emit("public %(name)sType(PythonTree node) {" % locals(), depth+1) + self.emit("super(node);", depth+2) + self.emit("}", depth+1) + self.emit("", 0) + self.emit("}", depth) self.close() for t in sum.types: @@ -207,7 +218,6 @@ ",".join(field_list), depth+1) self.emit("", 0) - self.javaMethods(cons, cons.name, cons.name, cons.fields, depth+1) self.emit("}", depth) @@ -215,88 +225,99 @@ def javaMethods(self, type, clsname, ctorname, fields, depth): # The java ctors - fpargs = ", ".join([self.fieldDef(f) for f in fields]) + token = asdl.Field('Token', 'token') + token.typedef = False + fpargs = ", ".join([self.fieldDef(f) for f in [token] + fields]) self.emit("public %s(%s) {" % (ctorname, fpargs), depth) + self.emit("super(token);", depth+1) for f in fields: self.emit("this.%s = %s;" % (f.name, f.name), depth+1) self.emit("}", depth) self.emit("", 0) - if fpargs: - fpargs += ", " - self.emit("public %s(%sPythonTree parent) {" % (ctorname, fpargs), depth) - self.emit("this(%s);" % - ", ".join([str(f.name) for f in fields]), depth+1) - self.emit("this.beginLine = parent.beginLine;", depth+1); - self.emit("this.beginColumn = parent.beginColumn;", depth+1); + tree = asdl.Field('PythonTree', 'tree') + tree.typedef = False + fpargs = ", ".join([self.fieldDef(f) for f in [tree] + fields]) + self.emit("public %s(%s) {" % (ctorname, fpargs), depth) + self.emit("super(tree);", depth+1) + for f in fields: + self.emit("this.%s = %s;" % (f.name, f.name), depth+1) self.emit("}", depth) self.emit("", 0) + if fpargs: + fpargs += ", " + #self.emit("public %s(%sPythonTree parent) {" % (ctorname, fpargs), depth) + #self.emit("this(%s);" % + # ", ".join([str(f.name) for f in fields]), depth+1) + #self.emit("this.beginLine = parent.beginLine;", depth+1); + #self.emit("this.beginColumn = parent.beginColumn;", depth+1); + #self.emit("}", depth) + #self.emit("", 0) + # The toString() method self.emit("public String toString() {", depth) - self.emit('StringBuffer sb = new StringBuffer("\'%s\', ");' % clsname, - depth+1) - self.emit("return sb.toString();", depth+1) + self.emit('return "%s";' % clsname, depth+1) self.emit("}", depth) self.emit("", 0) # The toStringTree() method - self.emit("public String toStringTree() {", depth) - self.emit('StringBuffer sb = new StringBuffer("%s[");' % clsname, - depth+1) - for f in fields: - self.emit('sb.append("%s=");' % f.name, depth+1) - if not self.bltinnames.has_key(str(f.type)) and f.typedef.simple: - self.emit("sb.append(dumpThis(this.%s, %sType.%sTypeNames));" % - (f.name, f.type, f.type), depth+1) - else: - self.emit("sb.append(dumpThis(this.%s));" % f.name, depth+1) - if f != fields[-1]: - self.emit('sb.append(", ");', depth+1) - self.emit('sb.append("]");', depth+1) - self.emit("return sb.toString();", depth+1) - self.emit("}", depth) - self.emit("", 0) + #self.emit("public String toStringTree() {", depth) + #self.emit('StringBuffer sb = new StringBuffer("%s[");' % clsname, + # depth+1) + #for f in fields: + # self.emit('sb.append("%s=");' % f.name, depth+1) + # if not self.bltinnames.has_key(str(f.type)) and f.typedef.simple: + # self.emit("sb.append(dumpThis(this.%s, %sType.%sTypeNames));" % + # (f.name, f.type, f.type), depth+1) + # else: + # self.emit("sb.append(dumpThis(this.%s));" % f.name, depth+1) + # if f != fields[-1]: + # self.emit('sb.append(", ");', depth+1) + #self.emit('sb.append("]");', depth+1) + #self.emit("return sb.toString();", depth+1) + #self.emit("}", depth) + #self.emit("", 0) # The pickle() method - self.emit("public void pickle(DataOutputStream ostream) throws IOException {", depth) - self.emit("pickleThis(%s, ostream);" % type.index, depth+1); - for f in fields: - self.emit("pickleThis(this.%s, ostream);" % f.name, depth+1) - self.emit("}", depth) - self.emit("", 0) + #self.emit("public void pickle(DataOutputStream ostream) throws IOException {", depth) + #self.emit("pickleThis(%s, ostream);" % type.index, depth+1); + #for f in fields: + # self.emit("pickleThis(this.%s, ostream);" % f.name, depth+1) + #self.emit("}", depth) + #self.emit("", 0) # The accept() method - self.emit("public Object accept(VisitorIF visitor) throws Exception {", depth) - if clsname == ctorname: - self.emit('return visitor.visit%s(this);' % clsname, depth+1) - else: - self.emit('traverse(visitor);' % clsname, depth+1) - self.emit('return null;' % clsname, depth+1) - self.emit("}", depth) - self.emit("", 0) + #self.emit("public Object accept(VisitorIF visitor) throws Exception {", depth) + #if clsname == ctorname: + # self.emit('return visitor.visit%s(this);' % clsname, depth+1) + #else: + # self.emit('traverse(visitor);' % clsname, depth+1) + # self.emit('return null;' % clsname, depth+1) + #self.emit("}", depth) + #self.emit("", 0) # The visitChildren() method - self.emit("public void traverse(VisitorIF visitor) throws Exception {", depth) - for f in fields: - if self.bltinnames.has_key(str(f.type)): - continue - if f.typedef.simple: - continue - if f.seq: - self.emit('if (%s != null) {' % f.name, depth+1) - self.emit('for (int i = 0; i < %s.length; i++) {' % f.name, - depth+2) - self.emit('if (%s[i] != null)' % f.name, depth+3) - self.emit('%s[i].accept(visitor);' % f.name, depth+4) - self.emit('}', depth+2) - self.emit('}', depth+1) - else: - self.emit('if (%s != null)' % f.name, depth+1) - self.emit('%s.accept(visitor);' % f.name, depth+2) - self.emit('}', depth) - self.emit("", 0) + #self.emit("public void traverse(VisitorIF visitor) throws Exception {", depth) + #for f in fields: + # if self.bltinnames.has_key(str(f.type)): + # continue + # if f.typedef.simple: + # continue + # if f.seq: + # self.emit('if (%s != null) {' % f.name, depth+1) + # self.emit('for (int i = 0; i < %s.length; i++) {' % f.name, + # depth+2) + # self.emit('if (%s[i] != null)' % f.name, depth+3) + # self.emit('%s[i].accept(visitor);' % f.name, depth+4) + # self.emit('}', depth+2) + # self.emit('}', depth+1) + # else: + # self.emit('if (%s != null)' % f.name, depth+1) + # self.emit('%s.accept(visitor);' % f.name, depth+2) + #self.emit('}', depth) + #self.emit("", 0) def visitField(self, field, depth): self.emit("public %s;" % self.fieldDef(field), depth) @@ -307,6 +328,8 @@ 'identifier' : 'String', 'string' : 'String', 'object' : 'Object', # was PyObject + 'Token' : 'Token', # to get antlr token type through + 'PythonTree' : 'PythonTree', # also for antlr type } def fieldDef(self, field): Modified: trunk/sandbox/ast/build.xml =================================================================== --- trunk/sandbox/ast/build.xml 2007-12-03 22:52:35 UTC (rev 3762) +++ trunk/sandbox/ast/build.xml 2007-12-04 03:08:38 UTC (rev 3763) @@ -25,14 +25,12 @@ </fileset> </copy> - <!-- <java classname="org.antlr.Tool"> <arg value="grammar/PythonWalker.g"/> <arg value="-o"/> <arg value="build/gensrc/org/python/antlr"/> <classpath refid="main.classpath"/> </java> - --> </target> @@ -48,13 +46,11 @@ </target> <target name="asdl_gen" depends="init"> - <!-- <apply verbose="true" executable="./asdl_antlr.py"> <fileset dir="." includes="Python.asdl"/> </apply> - --> </target> <target name="clean"> Added: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g (rev 0) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-04 03:08:38 UTC (rev 3763) @@ -0,0 +1,500 @@ +tree grammar PythonWalker; + +options { + tokenVocab=Python; + ASTLabelType=PythonTree; +} + +@header { +package org.python.antlr; + +//import org.python.core.Py; +//import org.python.core.PyString; +//import org.python.core.CompilerFlags; +import org.python.antlr.ast.aliasType; +import org.python.antlr.ast.argumentsType; +import org.python.antlr.ast.cmpopType; +import org.python.antlr.ast.exprType; +import org.python.antlr.ast.expr_contextType; +import org.python.antlr.ast.modType; +import org.python.antlr.ast.operatorType; +import org.python.antlr.ast.stmtType; +import org.python.antlr.ast.Assign; +import org.python.antlr.ast.AugAssign; +import org.python.antlr.ast.ClassDef; +import org.python.antlr.ast.Compare; +import org.python.antlr.ast.Dict; +import org.python.antlr.ast.Expr; +import org.python.antlr.ast.FunctionDef; +import org.python.antlr.ast.Import; +import org.python.antlr.ast.Module; +import org.python.antlr.ast.Name; +import org.python.antlr.ast.Num; +import org.python.antlr.ast.Pass; +import org.python.antlr.ast.Tuple; +import org.python.antlr.ast.Pass; +import org.python.antlr.ast.Print; +import org.python.antlr.ast.Str; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +} +@members { + String name = "Test"; + + //XXX: Not sure I need any below... + String filename = "test.py"; + boolean linenumbers = true; + boolean setFile = true; + boolean printResults = false; + //CompilerFlags cflags = Py.getCompilerFlags(); + + private FunctionDef extractFunctionDef(Token t, PythonTree nameToken, argumentsType args, List funcStatements) { + argumentsType a; + if (args != null) { + a = args; + } else { + a = new argumentsType(t, new exprType[0], null, null, new exprType[0]); + } + stmtType[] s = (stmtType[])funcStatements.toArray(new stmtType[funcStatements.size()]); + return new FunctionDef(t, nameToken.getText(), a, s, null); + } + + private argumentsType extractArgumentsType(Token t, List params, PythonTree snameToken, + PythonTree knameToken, List defaults) { + + exprType[] p = (exprType[])params.toArray(new exprType[params.size()]); + exprType[] d = (exprType[])defaults.toArray(new exprType[defaults.size()]); + String s; + String k; + if (snameToken == null) { + s = null; + } else { + s = snameToken.getText(); + } + if (knameToken == null) { + k = null; + } else { + k = knameToken.getText(); + } + return new argumentsType(t, p, s, k, d); + } + + String extractStrings(List s) { + StringBuffer sb = new StringBuffer(); + Iterator iter = s.iterator(); + while (iter.hasNext()) { + sb.append(extractString((String)iter.next())); + } + return sb.toString(); + } + + String extractString(String s) { + char quoteChar = s.charAt(0); + int start=0; + boolean ustring = false; + boolean raw = false; + if (quoteChar == 'u' || quoteChar == 'U') { + ustring = true; + start++; + } + quoteChar = s.charAt(start); + if (quoteChar == 'r' || quoteChar == 'R') { + raw = true; + start++; + } + quoteChar = s.charAt(start); + int quotes = 1; + if (quoteChar == '"' && s.charAt(start +1) == '"' || + quoteChar == '\'' && s.charAt(start+1) == '\'') { + quotes = 3; + } + if (raw) { + //XXX: What about ur? + return s.substring(quotes+start+1, s.length()-quotes); + } else { + StringBuffer sb = new StringBuffer(s.length()); + char[] ca = s.toCharArray(); + int n = ca.length-quotes; + int i=quotes+start; + int last_i=i; + //return PyString.decode_UnicodeEscape(s, i, n, "strict", ustring); + return decode_UnicodeEscape(s, i, n, "strict", ustring); + } + } + + //FIXME: placeholder until I re-integrate with Jython. + public static String decode_UnicodeEscape(String str, int start, int end, String errors, boolean unicode) { + return str; + } + + + Num extractNum(Token t, String s) { + int radix = 10; + if (s.startsWith("0x") || s.startsWith("0X")) { + radix = 16; + } else if (s.startsWith("0")) { + radix = 8; + } + if (s.endsWith("L") || s.endsWith("l")) { + s = s.substring(0, s.length()-1); + //return new Num(t, Py.newLong(new java.math.BigInteger(s, radix))); + return new Num(t, new java.math.BigInteger(s, radix)); + } + int ndigits = s.length(); + int i=0; + while (i < ndigits && s.charAt(i) == '0') + i++; + if ((ndigits - i) > 11) { + //return new Num(t, Py.newLong(new java.math.BigInteger(s, radix))); + return new Num(t, new java.math.BigInteger(s, radix)); + } + + long l = Long.valueOf(s, radix).longValue(); + if (l > 0xffffffffl || (radix == 10 && l > Integer.MAX_VALUE)) { + //return new Num(t, Py.newLong(new java.math.BigInteger(s, radix))); + return new Num(t, new java.math.BigInteger(s, radix)); + } + //return new Num(t, Py.newInteger((int) l)); + return new Num(t, new Long(l)); + } + +} + +module returns [modType mod] +@init { + List moduleStatements = new ArrayList(); +} + : ^(Module stmts?) { + stmtType[] s = (stmtType[])moduleStatements.toArray(new stmtType[moduleStatements.size()]); + $mod = new Module($Module, s); + System.out.println("matched module"); + } + ; + +decorator: ^(Decorator dotted_name ^(ArgList arglist?)) + ; + +decorators: decorator+ + ; + +funcdef : ^(FunctionDef (^(Decorators decorators))? ^(Name NAME) ^(Args varargslist?) ^(Body suite)) + ; + +varargslist + : ^(Arguments defparameter*) (^(StarArgs sname=NAME))? (^(KWArgs kname=NAME))? { + } + | ^(StarArgs sname=NAME) (^(KWArgs kname=NAME))? { + } + | ^(KWArgs NAME) { + } + ; + +defparameter + : NAME (ASSIGN test[expr_contextType.Load] )? { + } + ; + +stmts +scope { + List statements; +} +@init { + $stmts::statements = new ArrayList(); +} + : stmt+ + ; + +stmt //combines simple_stmt and compound_stmt from Python.g + : expr_stmt + | print_stmt + | del_stmt + | pass_stmt + | flow_stmt + | import_stmt + | global_stmt + | exec_stmt + | assert_stmt + | if_stmt + | while_stmt + | for_stmt + | try_stmt + | with_stmt + | funcdef + | classdef + ; + +expr_stmt + : ^(Expr test[expr_contextType.Load]) { + } + | ^(Expr ^(augassign targ=test[expr_contextType.Load] value=test[expr_contextType.Load])) { + } + | ^(Expr ^(Assign targets ^(Value value=test[expr_contextType.Load]))) { + exprType[] e = new exprType[$targets.etypes.size()]; + for(int i=0;i<$targets.etypes.size();i++) { + e[i] = (exprType)$targets.etypes.get(i); + } + Assign a = new Assign($Assign, e, $value.etype); + $stmts::statements.add(a); + } + ; + +targets returns [List etypes] +@init { + List targs = new ArrayList(); +} + : target[targs]+ { + $etypes = targs; + } + ; + +target[List etypes] + : ^(Target test[expr_contextType.Load]) { + etypes.add($test.etype); + } + ; + +augassign + : PLUSEQUAL {} + | MINUSEQUAL {} + | STAREQUAL {} + | SLASHEQUAL {} + | PERCENTEQUAL {} + | AMPEREQUAL {} + | VBAREQUAL {} + | CIRCUMFLEXEQUAL {} + | LEFTSHIFTEQUAL {} + | RIGHTSHIFTEQUAL {} + | DOUBLESTAREQUAL {} + | DOUBLESLASHEQUAL {} + ; + +print_stmt + : ^(Print RIGHTSHIFT? test[expr_contextType.Load]?) + { + } + ; + +del_stmt + : ^(Delete exprlist) + ; + +pass_stmt + : Pass { + } + ; + +flow_stmt + : break_stmt + | continue_stmt + | return_stmt + | raise_stmt + | yield_stmt + ; + +break_stmt + : 'break' + ; + +continue_stmt + : 'continue' + ; + +return_stmt + : ^(Return (test[expr_contextType.Load])?) + ; + +yield_stmt + : ^(Yield test[expr_contextType.Load]?) + ; + +raise_stmt + : ^(Raise (^(Type test[expr_contextType.Load]))? (^(Inst test[expr_contextType.Load]))? (^(Tback test[expr_contextType.Load]))?) + ; + +import_stmt + : ^(Import dotted_as_name+) { + } + | ^(ImportFrom dotted_name ^(Import STAR)) + | ^(ImportFrom dotted_name ^(Import import_as_name+)) + ; + +import_as_name : ^(Alias NAME (^(Asname NAME))?) + ; + +dotted_as_name : ^(Alias dotted_name (^(Asname NAME))?) + ; + +dotted_name + : start=NAME (DOT NAME)* { + } + ; + +global_stmt : ^(Global NAME+) + ; + +exec_stmt : ^(Exec test[expr_contextType.Load] (^(Globals test[expr_contextType.Load]))? (^(Locals test[expr_contextType.Load]))?) + ; + +assert_stmt : ^(Assert ^(Test test[expr_contextType.Load]) (^(Msg test[expr_contextType.Load]))?) + ; + + +if_stmt: ^(If test[expr_contextType.Load] suite elif_clause* (^(Else suite))?) + ; + +elif_clause : ^(Elif test[expr_contextType.Load] suite) + ; + +while_stmt : ^(While test[expr_contextType.Load] ^(Body suite) (^(Else suite))?) + ; + +for_stmt : ^(For exprlist ^(In test[expr_contextType.Load]) ^(Body suite) (^(Else suite))?) + ; + +try_stmt : ^(TryExcept ^(Body suite) except_clause+ (^(Else suite))?) + | ^(TryFinally suite) + ; + +except_clause : ^(Except (^(Type test[expr_contextType.Load]))? (^(Name test[expr_contextType.Load]))? ^(Body suite)) + ; + +with_stmt: ^(With test[expr_contextType.Load] with_var? ^(Body suite)) + ; + +with_var: ('as' | NAME) test[expr_contextType.Load] + ; + + +suite + : INDENT stmt+ DEDENT + | stmt+ + ; + +//FIXME: lots of placeholders +test[int ctype] returns [exprType etype] + : ^('and' test[expr_contextType.Load] test[expr_contextType.Load]) + | ^('or' test[expr_contextType.Load] test[expr_contextType.Load]) + | ^('not' test[expr_contextType.Load]) + | ^(comp_op left=test[expr_contextType.Load] targs=test[expr_contextType.Load]) { + exprType[] targets = new exprType[1]; + int[] ops = new int[1]; + ops[0] = $comp_op.op; + targets[0] = $targs.etype; + $etype = new Compare($comp_op.token, $left.etype, ops, targets); + } + | atom[ctype] (trailer)* {$etype = $atom.etype;} + | ^(PLUS test[expr_contextType.Load] test[expr_contextType.Load]) + | ^(MINUS left=test[expr_contextType.Load] right=test[expr_contextType.Load]) {} + | ^(AMPER test[expr_contextType.Load] test[expr_contextType.Load]) + | ^(VBAR test[expr_contextType.Load] test[expr_contextType.Load]) + | ^(CIRCUMFLEX test[expr_contextType.Load] test[expr_contextType.Load]) + | ^(LEFTSHIFT test[expr_contextType.Load] test[expr_contextType.Load]) + | ^(RIGHTSHIFT test[expr_contextType.Load] test[expr_contextType.Load]) + | ^(STAR test[expr_contextType.Load] test[expr_contextType.Load]) + | ^(SLASH test[expr_contextType.Load] test[expr_contextType.Load]) + | ^(PERCENT test[expr_contextType.Load] test[expr_contextType.Load]) + | ^(DOUBLESLASH test[expr_contextType.Load] test[expr_contextType.Load]) + | ^(DOUBLESTAR test[expr_contextType.Load] test[expr_contextType.Load]) + | ^(UnaryPlus test[expr_contextType.Load]) + | ^(UnaryMinus test[expr_contextType.Load]) + | ^(UnaryTilde test[expr_contextType.Load]) + | lambdef + ; + +comp_op returns [int op] + : LESS {$op = cmpopType.Lt;} + | GREATER {$op = cmpopType.Gt;} + | EQUAL {$op = cmpopType.Eq;} + | GREATEREQUAL {$op = cmpopType.GtE;} + | LESSEQUAL {$op = cmpopType.LtE;} + | ALT_NOTEQUAL {$op = cmpopType.NotEq;} + | NOTEQUAL {$op = cmpopType.NotEq;} + | 'in' {$op = cmpopType.In;} + | NotIn {$op = cmpopType.NotIn;} + | 'is' {$op = cmpopType.Is;} + | IsNot {$op = cmpopType.IsNot;} + ; + +//FIXME: lots of placeholders +atom[int ctype] returns [exprType etype] + : ^(List test[expr_contextType.Load]*) {} + | ^(ListComp list_for) {} + | ^(GenExpFor gen_for) {} + | ^(Parens test[expr_contextType.Load]*) {} + | ^(Dict test[expr_contextType.Load]*) {} + | ^(Repr test[expr_contextType.Load]*) {} + | ^(Name NAME) {System.out.println("NAME matched");} + | ^(Num INT) {System.out.println("INT matched");} + | ^(Num LONGINT) {} + | ^(Num FLOAT) {} + | ^(Num COMPLEX) {} + | stringlist { + } + ; + +stringlist + : ^(String string+) {} + ; + +string + : STRING {} + ; + +lambdef: ^(Lambda varargslist? ^(Body test[expr_contextType.Load])) + ; + +trailer + : ^(ArgList arglist?) + | ^(SubscriptList subscriptlist) + | DOT NAME + ; + +subscriptlist + : subscript+ + ; + +subscript : Ellipsis + | ^(Subscript (^(Start test[expr_contextType.Load]))? (^(End test[expr_contextType.Load]))? (^(SliceOp test[expr_contextType.Load]?))?) + ; + +exprlist : ^(ExprList test[expr_contextType.Load]+) + ; + +classdef + : ^(ClassDef ^(Name NAME) (^(Bases test[expr_contextType.Load]))? ^(Body suite)) { + //System.out.println("class "); + } + ; + +arglist + : ^(Arguments argument+) (^(StarArgs test[expr_contextType.Load]))? (^(KWArgs test[expr_contextType.Load]))? + | ^(StarArgs test[expr_contextType.Load]) (^(KWArgs test[expr_contextType.Load]))? + | ^(KWArgs test[expr_contextType.Load]) + ; + +argument : ^(Arg test[expr_contextType.Load] (^(Default test[expr_contextType.Load]))?) + ; + +list_iter: list_for + | list_if + ; + +list_for: 'for' exprlist 'in' test[expr_contextType.Load] (list_iter)? + ; + +list_if: 'if' test[expr_contextType.Load] (list_iter)? + ; + +gen_iter: gen_for + | gen_if + ; + +gen_for: 'for' exprlist 'in' test[expr_contextType.Load] gen_iter? + ; + +gen_if: 'if' test[expr_contextType.Load] gen_iter? + ; + Added: trunk/sandbox/ast/run =================================================================== --- trunk/sandbox/ast/run (rev 0) +++ trunk/sandbox/ast/run 2007-12-04 03:08:38 UTC (rev 3763) @@ -0,0 +1 @@ +java -classpath lib/antlr-3.0.1.jar:build org.python.antlr.Main $* Property changes on: trunk/sandbox/ast/run ___________________________________________________________________ Name: svn:executable + * Modified: trunk/sandbox/ast/src/org/python/antlr/Main.java =================================================================== --- trunk/sandbox/ast/src/org/python/antlr/Main.java 2007-12-03 22:52:35 UTC (rev 3762) +++ trunk/sandbox/ast/src/org/python/antlr/Main.java 2007-12-04 03:08:38 UTC (rev 3763) @@ -14,8 +14,8 @@ public class Main { // override nextToken to set startPos (this seems too hard) - public static class MyLexer extends PythonLexer { - public MyLexer(CharStream lexer) { + public static class PyLexer extends PythonLexer { + public PyLexer(CharStream lexer) { super(lexer); } public Token nextToken() { @@ -24,8 +24,13 @@ } } - public static TreeAdaptor myadaptor = new CommonTreeAdaptor() { + public static TreeAdaptor pyadaptor = new CommonTreeAdaptor() { public Object create(Token token) { + /* + if (token != null && token.getType() == PythonParser.Target) { + System.out.println("Target found"); + } + */ return new PythonTree(token); } public Object dupNode(Object t) { @@ -36,31 +41,31 @@ } }; - public /*modType*/ void parse(String[] args) throws Exception { - //modType result = null; + public PythonTree parse(String[] args) throws Exception { + PythonTree result = null; CharStream input = new ANTLRFileStream(args[0]); - PythonLexer lexer = new MyLexer(input); + PythonLexer lexer = new PyLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); tokens.discardOffChannelTokens(true); PythonTokenSource indentedSource = new PythonTokenSource(tokens); tokens = new CommonTokenStream(indentedSource); //System.out.println("tokens="+tokens.getTokens()); PythonParser parser = new PythonParser(tokens); - parser.setTreeAdaptor(myadaptor); + parser.setTreeAdaptor(pyadaptor); try { PythonParser.file_input_return r = parser.file_input(); - //PythonParser.module_return r = parser.module(); if (args.length > 1) { System.out.println(((Tree)r.tree).toStringTree()); } CommonTreeNodeStream nodes = new CommonTreeNodeStream((Tree)r.tree); nodes.setTokenStream(tokens); - //PythonWalker walker = new PythonWalker(nodes); - //result = walker.module(); + PythonWalker walker = new PythonWalker(nodes); + result = walker.module(); + System.out.println(result.toStringTree()); } catch (RecognitionException e) { System.err.println("Error: " + e); } - //return result; + return result; } public static void main(String[] args) throws Exception { Modified: trunk/sandbox/ast/src/org/python/antlr/PythonTree.java =================================================================== --- trunk/sandbox/ast/src/org/python/antlr/PythonTree.java 2007-12-03 22:52:35 UTC (rev 3762) +++ trunk/sandbox/ast/src/org/python/antlr/PythonTree.java 2007-12-04 03:08:38 UTC (rev 3763) @@ -15,13 +15,18 @@ super(token); } + public PythonTree(PythonTree node) { + super(node); + } + public String toString() { if ( isNil() ) { return "None"; } - return token.getText().toLowerCase(); + return token.getText(); } + /* public String toStringTree() { if ( children==null || children.size()==0 ) { return this.toString(); @@ -44,4 +49,5 @@ } return buf.toString(); } + */ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-05 23:58:15
|
Revision: 3764 http://jython.svn.sourceforge.net/jython/?rev=3764&view=rev Author: fwierzbicki Date: 2007-12-05 15:58:13 -0800 (Wed, 05 Dec 2007) Log Message: ----------- better PythonTree (replaces SimpleNode from Javacc) Modified Paths: -------------- trunk/sandbox/ast/asdl_antlr.py trunk/sandbox/ast/grammar/PythonWalker.g trunk/sandbox/ast/src/org/python/antlr/PythonTree.java Modified: trunk/sandbox/ast/asdl_antlr.py =================================================================== --- trunk/sandbox/ast/asdl_antlr.py 2007-12-04 03:08:38 UTC (rev 3763) +++ trunk/sandbox/ast/asdl_antlr.py 2007-12-05 23:58:13 UTC (rev 3764) @@ -233,6 +233,10 @@ self.emit("super(token);", depth+1) for f in fields: self.emit("this.%s = %s;" % (f.name, f.name), depth+1) + if f.seq: + self.emit("for(int i%(name)s=0;i%(name)s<%(name)s.length;i%(name)s++) {" % {"name":f.name}, depth+1) + self.emit("addChild(%s[i%s]);" % (f.name, f.name), depth+2) + self.emit("}", depth+1) self.emit("}", depth) self.emit("", 0) @@ -248,13 +252,6 @@ if fpargs: fpargs += ", " - #self.emit("public %s(%sPythonTree parent) {" % (ctorname, fpargs), depth) - #self.emit("this(%s);" % - # ", ".join([str(f.name) for f in fields]), depth+1) - #self.emit("this.beginLine = parent.beginLine;", depth+1); - #self.emit("this.beginColumn = parent.beginColumn;", depth+1); - #self.emit("}", depth) - #self.emit("", 0) # The toString() method self.emit("public String toString() {", depth) @@ -262,24 +259,6 @@ self.emit("}", depth) self.emit("", 0) - # The toStringTree() method - #self.emit("public String toStringTree() {", depth) - #self.emit('StringBuffer sb = new StringBuffer("%s[");' % clsname, - # depth+1) - #for f in fields: - # self.emit('sb.append("%s=");' % f.name, depth+1) - # if not self.bltinnames.has_key(str(f.type)) and f.typedef.simple: - # self.emit("sb.append(dumpThis(this.%s, %sType.%sTypeNames));" % - # (f.name, f.type, f.type), depth+1) - # else: - # self.emit("sb.append(dumpThis(this.%s));" % f.name, depth+1) - # if f != fields[-1]: - # self.emit('sb.append(", ");', depth+1) - #self.emit('sb.append("]");', depth+1) - #self.emit("return sb.toString();", depth+1) - #self.emit("}", depth) - #self.emit("", 0) - # The pickle() method #self.emit("public void pickle(DataOutputStream ostream) throws IOException {", depth) #self.emit("pickleThis(%s, ostream);" % type.index, depth+1); @@ -342,7 +321,6 @@ seq = field.seq and "[]" or "" return "%(jtype)s%(seq)s %(name)s" % locals() - class VisitorVisitor(EmitVisitor): def __init__(self, dir): EmitVisitor.__init__(self, dir) Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-04 03:08:38 UTC (rev 3763) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-05 23:58:13 UTC (rev 3764) @@ -42,6 +42,14 @@ import java.util.Set; } @members { + boolean debugOn = true; + + public void debug(String message) { + if (debugOn) { + System.out.println(message); + } + } + String name = "Test"; //XXX: Not sure I need any below... @@ -51,7 +59,18 @@ boolean printResults = false; //CompilerFlags cflags = Py.getCompilerFlags(); - private FunctionDef extractFunctionDef(Token t, PythonTree nameToken, argumentsType args, List funcStatements) { + private modType makeMod(PythonTree t, List stmts) { + System.out.println("stmts: " + stmts.size()); + stmtType[] s; + if (stmts != null) { + s = (stmtType[])stmts.toArray(new stmtType[stmts.size()]); + } else { + s = new stmtType[0]; + } + return new Module(t, s); + } + + private FunctionDef makeFunctionDef(Token t, PythonTree nameToken, argumentsType args, List funcStatements) { argumentsType a; if (args != null) { a = args; @@ -62,7 +81,7 @@ return new FunctionDef(t, nameToken.getText(), a, s, null); } - private argumentsType extractArgumentsType(Token t, List params, PythonTree snameToken, + private argumentsType makeArgumentsType(Token t, List params, PythonTree snameToken, PythonTree knameToken, List defaults) { exprType[] p = (exprType[])params.toArray(new exprType[params.size()]); @@ -131,7 +150,7 @@ } - Num extractNum(Token t, String s) { + Num makeNum(Token t, String s) { int radix = 10; if (s.startsWith("0x") || s.startsWith("0X")) { radix = 16; @@ -164,13 +183,9 @@ } module returns [modType mod] -@init { - List moduleStatements = new ArrayList(); -} : ^(Module stmts?) { - stmtType[] s = (stmtType[])moduleStatements.toArray(new stmtType[moduleStatements.size()]); - $mod = new Module($Module, s); System.out.println("matched module"); + $mod = makeMod($Module, $stmts.stypes); } ; @@ -197,14 +212,16 @@ } ; -stmts +stmts returns [List stypes] scope { List statements; } @init { $stmts::statements = new ArrayList(); } - : stmt+ + : stmt+ { + $stypes = $stmts::statements; + } ; stmt //combines simple_stmt and compound_stmt from Python.g @@ -232,6 +249,7 @@ | ^(Expr ^(augassign targ=test[expr_contextType.Load] value=test[expr_contextType.Load])) { } | ^(Expr ^(Assign targets ^(Value value=test[expr_contextType.Load]))) { + debug("Matched Assign"); exprType[] e = new exprType[$targets.etypes.size()]; for(int i=0;i<$targets.etypes.size();i++) { e[i] = (exprType)$targets.etypes.get(i); @@ -383,7 +401,8 @@ int[] ops = new int[1]; ops[0] = $comp_op.op; targets[0] = $targs.etype; - $etype = new Compare($comp_op.token, $left.etype, ops, targets); + $etype = new Compare($comp_op.start, $left.etype, ops, targets); + System.out.println("COMP_OP: " + $comp_op.start); } | atom[ctype] (trailer)* {$etype = $atom.etype;} | ^(PLUS test[expr_contextType.Load] test[expr_contextType.Load]) Modified: trunk/sandbox/ast/src/org/python/antlr/PythonTree.java =================================================================== --- trunk/sandbox/ast/src/org/python/antlr/PythonTree.java 2007-12-04 03:08:38 UTC (rev 3763) +++ trunk/sandbox/ast/src/org/python/antlr/PythonTree.java 2007-12-05 23:58:13 UTC (rev 3764) @@ -26,9 +26,9 @@ return token.getText(); } - /* public String toStringTree() { if ( children==null || children.size()==0 ) { + System.out.println("Where are my children? -- asks " + token.getText()); return this.toString(); } StringBuffer buf = new StringBuffer(); @@ -49,5 +49,4 @@ } return buf.toString(); } - */ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-06 13:11:25
|
Revision: 3765 http://jython.svn.sourceforge.net/jython/?rev=3765&view=rev Author: fwierzbicki Date: 2007-12-06 05:11:24 -0800 (Thu, 06 Dec 2007) Log Message: ----------- bugfix for asdl_antlr and run the asdl gen from build.xml with a python command for better cross-platform. Modified Paths: -------------- trunk/sandbox/ast/asdl_antlr.py trunk/sandbox/ast/build.xml Modified: trunk/sandbox/ast/asdl_antlr.py =================================================================== --- trunk/sandbox/ast/asdl_antlr.py 2007-12-05 23:58:13 UTC (rev 3764) +++ trunk/sandbox/ast/asdl_antlr.py 2007-12-06 13:11:24 UTC (rev 3765) @@ -233,7 +233,10 @@ self.emit("super(token);", depth+1) for f in fields: self.emit("this.%s = %s;" % (f.name, f.name), depth+1) - if f.seq: + fparg = self.fieldDef(f) + #For now ignoring int and String -- will want to wrap in a PythonTree later I think. + if f.seq and not fparg.startswith("int") and not fparg.startswith("String"): + print self.fieldDef(f) self.emit("for(int i%(name)s=0;i%(name)s<%(name)s.length;i%(name)s++) {" % {"name":f.name}, depth+1) self.emit("addChild(%s[i%s]);" % (f.name, f.name), depth+2) self.emit("}", depth+1) Modified: trunk/sandbox/ast/build.xml =================================================================== --- trunk/sandbox/ast/build.xml 2007-12-05 23:58:13 UTC (rev 3764) +++ trunk/sandbox/ast/build.xml 2007-12-06 13:11:24 UTC (rev 3765) @@ -48,7 +48,8 @@ <target name="asdl_gen" depends="init"> <apply verbose="true" - executable="./asdl_antlr.py"> + executable="python"> + <arg value="./asdl_antlr.py" /> <fileset dir="." includes="Python.asdl"/> </apply> </target> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-07 02:05:40
|
Revision: 3766 http://jython.svn.sourceforge.net/jython/?rev=3766&view=rev Author: fwierzbicki Date: 2007-12-06 18:05:38 -0800 (Thu, 06 Dec 2007) Log Message: ----------- asdl refactor, better assign matching in walker. Modified Paths: -------------- trunk/sandbox/ast/asdl_antlr.py trunk/sandbox/ast/grammar/PythonWalker.g Modified: trunk/sandbox/ast/asdl_antlr.py =================================================================== --- trunk/sandbox/ast/asdl_antlr.py 2007-12-06 13:11:24 UTC (rev 3765) +++ trunk/sandbox/ast/asdl_antlr.py 2007-12-07 02:05:38 UTC (rev 3766) @@ -223,6 +223,16 @@ self.emit("}", depth) self.close() + def javaConstructorHelper(self, fields, depth): + for f in fields: + self.emit("this.%s = %s;" % (f.name, f.name), depth+1) + fparg = self.fieldDef(f) + #For now ignoring int and String -- will want to wrap in a PythonTree later I think. + if f.seq and not fparg.startswith("int") and not fparg.startswith("String"): + self.emit("for(int i%(name)s=0;i%(name)s<%(name)s.length;i%(name)s++) {" % {"name":f.name}, depth+1) + self.emit("addChild(%s[i%s]);" % (f.name, f.name), depth+2) + self.emit("}", depth+1) + def javaMethods(self, type, clsname, ctorname, fields, depth): # The java ctors token = asdl.Field('Token', 'token') @@ -231,15 +241,7 @@ self.emit("public %s(%s) {" % (ctorname, fpargs), depth) self.emit("super(token);", depth+1) - for f in fields: - self.emit("this.%s = %s;" % (f.name, f.name), depth+1) - fparg = self.fieldDef(f) - #For now ignoring int and String -- will want to wrap in a PythonTree later I think. - if f.seq and not fparg.startswith("int") and not fparg.startswith("String"): - print self.fieldDef(f) - self.emit("for(int i%(name)s=0;i%(name)s<%(name)s.length;i%(name)s++) {" % {"name":f.name}, depth+1) - self.emit("addChild(%s[i%s]);" % (f.name, f.name), depth+2) - self.emit("}", depth+1) + self.javaConstructorHelper(fields, depth) self.emit("}", depth) self.emit("", 0) @@ -248,8 +250,7 @@ fpargs = ", ".join([self.fieldDef(f) for f in [tree] + fields]) self.emit("public %s(%s) {" % (ctorname, fpargs), depth) self.emit("super(tree);", depth+1) - for f in fields: - self.emit("this.%s = %s;" % (f.name, f.name), depth+1) + self.javaConstructorHelper(fields, depth) self.emit("}", depth) self.emit("", 0) Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-06 13:11:24 UTC (rev 3765) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-07 02:05:38 UTC (rev 3766) @@ -60,7 +60,6 @@ //CompilerFlags cflags = Py.getCompilerFlags(); private modType makeMod(PythonTree t, List stmts) { - System.out.println("stmts: " + stmts.size()); stmtType[] s; if (stmts != null) { s = (stmtType[])stmts.toArray(new stmtType[stmts.size()]); @@ -70,7 +69,7 @@ return new Module(t, s); } - private FunctionDef makeFunctionDef(Token t, PythonTree nameToken, argumentsType args, List funcStatements) { + private FunctionDef makeFunctionDef(PythonTree t, PythonTree nameToken, argumentsType args, List funcStatements) { argumentsType a; if (args != null) { a = args; @@ -81,7 +80,7 @@ return new FunctionDef(t, nameToken.getText(), a, s, null); } - private argumentsType makeArgumentsType(Token t, List params, PythonTree snameToken, + private argumentsType makeArgumentsType(PythonTree t, List params, PythonTree snameToken, PythonTree knameToken, List defaults) { exprType[] p = (exprType[])params.toArray(new exprType[params.size()]); @@ -150,7 +149,9 @@ } - Num makeNum(Token t, String s) { + Num makeNum(PythonTree t) { + debug("Num matched"); + String s = t.getText(); int radix = 10; if (s.startsWith("0x") || s.startsWith("0X")) { radix = 16; @@ -184,7 +185,7 @@ module returns [modType mod] : ^(Module stmts?) { - System.out.println("matched module"); + debug("matched module"); $mod = makeMod($Module, $stmts.stypes); } ; @@ -254,6 +255,7 @@ for(int i=0;i<$targets.etypes.size();i++) { e[i] = (exprType)$targets.etypes.get(i); } + debug("exprs: " + e.length); Assign a = new Assign($Assign, e, $value.etype); $stmts::statements.add(a); } @@ -402,7 +404,7 @@ ops[0] = $comp_op.op; targets[0] = $targs.etype; $etype = new Compare($comp_op.start, $left.etype, ops, targets); - System.out.println("COMP_OP: " + $comp_op.start); + debug("COMP_OP: " + $comp_op.start); } | atom[ctype] (trailer)* {$etype = $atom.etype;} | ^(PLUS test[expr_contextType.Load] test[expr_contextType.Load]) @@ -445,11 +447,11 @@ | ^(Parens test[expr_contextType.Load]*) {} | ^(Dict test[expr_contextType.Load]*) {} | ^(Repr test[expr_contextType.Load]*) {} - | ^(Name NAME) {System.out.println("NAME matched");} - | ^(Num INT) {System.out.println("INT matched");} - | ^(Num LONGINT) {} - | ^(Num FLOAT) {} - | ^(Num COMPLEX) {} + | ^(Name NAME) {$etype = new Name($NAME, $NAME.text, ctype);} + | ^(Num INT) {$etype = makeNum($INT);} + | ^(Num LONGINT) {$etype = makeNum($LONGINT);} + | ^(Num FLOAT) {$etype = makeNum($FLOAT);} + | ^(Num COMPLEX) {$etype = makeNum($COMPLEX);} | stringlist { } ; @@ -484,7 +486,7 @@ classdef : ^(ClassDef ^(Name NAME) (^(Bases test[expr_contextType.Load]))? ^(Body suite)) { - //System.out.println("class "); + debug("class matched"); } ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-07 02:42:37
|
Revision: 3767 http://jython.svn.sourceforge.net/jython/?rev=3767&view=rev Author: fwierzbicki Date: 2007-12-06 18:42:36 -0800 (Thu, 06 Dec 2007) Log Message: ----------- a long way to go - but I got a close match between Jim Baker's astlib test output and a jython version (jastlib) for the simple a=1 Modified Paths: -------------- trunk/sandbox/ast/grammar/PythonWalker.g Added Paths: ----------- trunk/sandbox/ast/jastlib.py trunk/sandbox/ast/t1.py Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-07 02:05:38 UTC (rev 3766) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-07 02:42:36 UTC (rev 3767) @@ -42,7 +42,7 @@ import java.util.Set; } @members { - boolean debugOn = true; + boolean debugOn = false; public void debug(String message) { if (debugOn) { Added: trunk/sandbox/ast/jastlib.py =================================================================== --- trunk/sandbox/ast/jastlib.py (rev 0) +++ trunk/sandbox/ast/jastlib.py 2007-12-07 02:42:36 UTC (rev 3767) @@ -0,0 +1,47 @@ +"""lispify_ast - returns a tuple representation of the AST + +Uses 2.5's _ast, not other AST implementations in CPython, since these +are not used by the compilation phase. And that's what we're +interested in. + +Since this is a tuple, we can directly compare, and this is going to +be handy when comparing Jython's implementation vs CPython. + +""" +import org.python.antlr.ast as _ast +import org.python.antlr.Main as parser + +from types import ArrayType + +def lispify_ast(node): + return tuple(lispify_ast2(node)) + +def lispify_ast2(node): + yield str(node) + try: + for field in node._fields: + yield tuple(lispify_field(field, getattr(node, field))) + except: + pass + +def lispify_field(field, child): + yield field + if not isinstance(child, ArrayType): + children = [child] + else: + children = child + + for node in children: + if isinstance(node, (str, int)): + yield node + else: + yield lispify_ast(node) + +if __name__ == '__main__': + import sys + from pprint import pprint + + code_path = sys.argv[1] + ast = parser().parse([code_path]) + lispified = lispify_ast(ast) + pprint(lispified) Added: trunk/sandbox/ast/t1.py =================================================================== --- trunk/sandbox/ast/t1.py (rev 0) +++ trunk/sandbox/ast/t1.py 2007-12-07 02:42:36 UTC (rev 3767) @@ -0,0 +1 @@ +a=1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-08 03:29:37
|
Revision: 3768 http://jython.svn.sourceforge.net/jython/?rev=3768&view=rev Author: fwierzbicki Date: 2007-12-07 19:29:35 -0800 (Fri, 07 Dec 2007) Log Message: ----------- much improved walk -- now walks about 90% of py25 Lib without choking. Modified Paths: -------------- trunk/sandbox/ast/grammar/Python.g trunk/sandbox/ast/grammar/PythonWalker.g trunk/sandbox/ast/src/org/python/antlr/Main.java trunk/sandbox/ast/src/org/python/antlr/PythonTree.java Added Paths: ----------- trunk/sandbox/ast/crawl trunk/sandbox/ast/jy23 trunk/sandbox/ast/py25 trunk/sandbox/ast/regr trunk/sandbox/ast/src/org/python/antlr/GrammarOnly.java trunk/sandbox/ast/walk Added: trunk/sandbox/ast/crawl =================================================================== --- trunk/sandbox/ast/crawl (rev 0) +++ trunk/sandbox/ast/crawl 2007-12-08 03:29:35 UTC (rev 3768) @@ -0,0 +1 @@ +java -classpath lib/antlr-3.0.1.jar:build org.python.antlr.GrammarOnly $* Property changes on: trunk/sandbox/ast/crawl ___________________________________________________________________ Name: svn:executable + * Modified: trunk/sandbox/ast/grammar/Python.g =================================================================== --- trunk/sandbox/ast/grammar/Python.g 2007-12-07 02:42:36 UTC (rev 3767) +++ trunk/sandbox/ast/grammar/Python.g 2007-12-08 03:29:35 UTC (rev 3768) @@ -81,7 +81,6 @@ Module; Test; Msg; - Stmt; Import; ImportFrom; Name; @@ -95,17 +94,19 @@ Arg; Arguments; Assign; + AugAssign; Compare; Expr; - ExprList; Tuple; List; Dict; If; - Else; + OrElse; Elif; While; Pass; + Break; + Continue; Print; TryExcept; TryFinally; @@ -126,6 +127,7 @@ Exec;Globals;Locals; Assert; Ellipsis; + Comprehension; ListComp; Lambda; Repr; @@ -139,9 +141,10 @@ Start; End; SliceOp; - UnaryPlus; - UnaryMinus; - UnaryTilde; + UnaryOp; + UAdd; + USub; + Invert; Delete; Default; Parens; @@ -152,6 +155,14 @@ With; GenExpFor; Id; + Iter; + Ifs; + Elts; + Ctx; + GenFor; + GenIf; + ListFor; + ListIf; } @header { @@ -215,7 +226,7 @@ | DOUBLESTAR kwargs=NAME )? )? - -> ^(Arguments defparameter+) ^(StarArgs $starargs)? ^(KWArgs $kwargs)? + -> ^(Args defparameter+) ^(StarArgs $starargs)? ^(KWArgs $kwargs)? | STAR starargs=NAME (COMMA DOUBLESTAR kwargs=NAME)? -> ^(StarArgs $starargs) ^(KWArgs $kwargs)? | DOUBLESTAR kwargs=NAME @@ -247,7 +258,7 @@ ; //small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt -small_stmt : expr_stmt -> ^(Expr expr_stmt) +small_stmt : expr_stmt | print_stmt | del_stmt | pass_stmt @@ -307,7 +318,7 @@ //del_stmt: 'del' exprlist del_stmt : 'del' exprlist - -> ^(Delete exprlist) + -> ^(Delete ^(Targets exprlist)) ; //pass_stmt: 'pass' @@ -416,7 +427,7 @@ //if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] if_stmt: 'if' test COLON ifsuite=suite elif_clause* ('else' COLON elsesuite=suite)? - -> ^(If test $ifsuite elif_clause* ^(Else $elsesuite)?) + -> ^(If test $ifsuite elif_clause* ^(OrElse $elsesuite)?) ; //not in CPython's Grammar file @@ -426,19 +437,19 @@ //while_stmt: 'while' test ':' suite ['else' ':' suite] while_stmt : 'while' test COLON s1=suite ('else' COLON s2=suite)? - -> ^(While test ^(Body $s1) ^(Else $s2)?) + -> ^(While test ^(Body $s1) ^(OrElse $s2)?) ; //for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] for_stmt : 'for' exprlist 'in' testlist COLON s1=suite ('else' COLON s2=suite)? - -> ^(For exprlist ^(In testlist) ^(Body $s1) ^(Else $s2)?) + -> ^(For ^(Target exprlist) ^(Iter testlist) ^(Body $s1) ^(OrElse $s2)?) ; //try_stmt: ('try' ':' suite (except_clause ':' suite)+ #diagram:break // ['else' ':' suite] | 'try' ':' suite 'finally' ':' suite) try_stmt : 'try' COLON trysuite=suite ( (except_clause+ ('else' COLON elsesuite=suite)? - -> ^(TryExcept ^(Body $trysuite) except_clause+ ^(Else $elsesuite)?)) + -> ^(TryExcept ^(Body $trysuite) except_clause+ ^(OrElse $elsesuite)?)) | ('finally' COLON suite -> ^(TryFinally suite)) ) @@ -459,7 +470,7 @@ ; //suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT -suite : simple_stmt -> ^(Stmt simple_stmt) +suite : simple_stmt | NEWLINE! INDENT (stmt)+ DEDENT ; @@ -539,9 +550,9 @@ ; //factor: ('+'|'-'|'~') factor | power -factor : PLUS factor -> ^(UnaryPlus factor) - | MINUS factor -> ^(UnaryMinus factor) - | TILDE factor -> ^(UnaryTilde factor) +factor : PLUS factor -> ^(UAdd factor) + | MINUS factor -> ^(USub factor) + | TILDE factor -> ^(Invert factor) | power ; @@ -610,7 +621,7 @@ //exprlist: expr (',' expr)* [','] exprlist : expr (options {k=2;}: COMMA expr)* (COMMA)? - -> ^(ExprList expr+) + -> expr+ ; //testlist: test (',' test)* [','] @@ -658,10 +669,12 @@ //list_for: 'for' exprlist 'in' testlist_safe [list_iter] list_for : 'for' exprlist 'in' testlist (list_iter)? + -> ^(ListFor ^(Target exprlist) ^(Iter testlist) ^(Ifs list_iter)?) ; //list_if: 'if' test [list_iter] list_if : 'if' test (list_iter)? + -> ^(ListIf ^(Target test) (Ifs list_iter)?) ; //gen_iter: gen_for | gen_if @@ -671,10 +684,12 @@ //gen_for: 'for' exprlist 'in' or_test [gen_iter] gen_for: 'for' exprlist 'in' or_test gen_iter? + -> ^(GenFor ^(Target exprlist) ^(Iter gen_iter)?) ; //gen_if: 'if' old_test [gen_iter] gen_if: 'if' test gen_iter? + -> ^(GenIf ^(Target test) ^(Iter gen_iter)?) ; //yield_expr: 'yield' [testlist] Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-07 02:42:36 UTC (rev 3767) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-08 03:29:35 UTC (rev 3768) @@ -155,6 +155,7 @@ int radix = 10; if (s.startsWith("0x") || s.startsWith("0X")) { radix = 16; + s = s.substring(2, s.length()); } else if (s.startsWith("0")) { radix = 8; } @@ -196,11 +197,11 @@ decorators: decorator+ ; -funcdef : ^(FunctionDef (^(Decorators decorators))? ^(Name NAME) ^(Args varargslist?) ^(Body suite)) +funcdef : ^(FunctionDef ^(Name NAME) ^(Arguments varargslist?) ^(Body suite) (^(Decorators decorators))? ) ; varargslist - : ^(Arguments defparameter*) (^(StarArgs sname=NAME))? (^(KWArgs kname=NAME))? { + : ^(Args defparameter*) (^(StarArgs sname=NAME))? (^(KWArgs kname=NAME))? { } | ^(StarArgs sname=NAME) (^(KWArgs kname=NAME))? { } @@ -245,11 +246,11 @@ ; expr_stmt - : ^(Expr test[expr_contextType.Load]) { + : test[expr_contextType.Load] { } - | ^(Expr ^(augassign targ=test[expr_contextType.Load] value=test[expr_contextType.Load])) { + | ^(augassign targ=test[expr_contextType.Load] value=test[expr_contextType.Load]) { } - | ^(Expr ^(Assign targets ^(Value value=test[expr_contextType.Load]))) { + | ^(Assign targets ^(Value value=test[expr_contextType.Load])) { debug("Matched Assign"); exprType[] e = new exprType[$targets.etypes.size()]; for(int i=0;i<$targets.etypes.size();i++) { @@ -298,7 +299,7 @@ ; del_stmt - : ^(Delete exprlist) + : ^(Delete ^(Targets test[expr_contextType.Load]+)) ; pass_stmt @@ -362,19 +363,19 @@ ; -if_stmt: ^(If test[expr_contextType.Load] suite elif_clause* (^(Else suite))?) +if_stmt: ^(If test[expr_contextType.Load] suite elif_clause* (^(OrElse suite))?) ; elif_clause : ^(Elif test[expr_contextType.Load] suite) ; -while_stmt : ^(While test[expr_contextType.Load] ^(Body suite) (^(Else suite))?) +while_stmt : ^(While test[expr_contextType.Load] ^(Body suite) (^(OrElse suite))?) ; -for_stmt : ^(For exprlist ^(In test[expr_contextType.Load]) ^(Body suite) (^(Else suite))?) +for_stmt : ^(For ^(Target test[expr_contextType.Load]+) ^(Iter test[expr_contextType.Load]) ^(Body suite) (^(OrElse suite))?) ; -try_stmt : ^(TryExcept ^(Body suite) except_clause+ (^(Else suite))?) +try_stmt : ^(TryExcept ^(Body suite) except_clause+ (^(OrElse suite))?) | ^(TryFinally suite) ; @@ -419,9 +420,9 @@ | ^(PERCENT test[expr_contextType.Load] test[expr_contextType.Load]) | ^(DOUBLESLASH test[expr_contextType.Load] test[expr_contextType.Load]) | ^(DOUBLESTAR test[expr_contextType.Load] test[expr_contextType.Load]) - | ^(UnaryPlus test[expr_contextType.Load]) - | ^(UnaryMinus test[expr_contextType.Load]) - | ^(UnaryTilde test[expr_contextType.Load]) + | ^(UAdd test[expr_contextType.Load]) + | ^(USub test[expr_contextType.Load]) + | ^(Invert test[expr_contextType.Load]) | lambdef ; @@ -444,20 +445,21 @@ : ^(List test[expr_contextType.Load]*) {} | ^(ListComp list_for) {} | ^(GenExpFor gen_for) {} + | ^(Tuple test[expr_contextType.Load]*) {} | ^(Parens test[expr_contextType.Load]*) {} | ^(Dict test[expr_contextType.Load]*) {} | ^(Repr test[expr_contextType.Load]*) {} | ^(Name NAME) {$etype = new Name($NAME, $NAME.text, ctype);} | ^(Num INT) {$etype = makeNum($INT);} | ^(Num LONGINT) {$etype = makeNum($LONGINT);} - | ^(Num FLOAT) {$etype = makeNum($FLOAT);} - | ^(Num COMPLEX) {$etype = makeNum($COMPLEX);} + | ^(Num FLOAT) + | ^(Num COMPLEX) | stringlist { } ; stringlist - : ^(String string+) {} + : ^(Str string+) {} ; string @@ -481,9 +483,6 @@ | ^(Subscript (^(Start test[expr_contextType.Load]))? (^(End test[expr_contextType.Load]))? (^(SliceOp test[expr_contextType.Load]?))?) ; -exprlist : ^(ExprList test[expr_contextType.Load]+) - ; - classdef : ^(ClassDef ^(Name NAME) (^(Bases test[expr_contextType.Load]))? ^(Body suite)) { debug("class matched"); @@ -503,19 +502,19 @@ | list_if ; -list_for: 'for' exprlist 'in' test[expr_contextType.Load] (list_iter)? +list_for: ^(ListFor ^(Target test[expr_contextType.Load]+) ^(Iter test[expr_contextType.Load]+) (^(Ifs list_iter))?) ; -list_if: 'if' test[expr_contextType.Load] (list_iter)? +list_if: ^(ListIf ^(Target test[expr_contextType.Load]) (Ifs list_iter)?) ; gen_iter: gen_for | gen_if ; -gen_for: 'for' exprlist 'in' test[expr_contextType.Load] gen_iter? +gen_for: ^(GenFor ^(Target test[expr_contextType.Load]+) (^(Iter gen_iter))?) ; -gen_if: 'if' test[expr_contextType.Load] gen_iter? +gen_if: ^(GenIf ^(Target test[expr_contextType.Load]) (^(Iter gen_iter))?) ; Added: trunk/sandbox/ast/jy23 =================================================================== --- trunk/sandbox/ast/jy23 (rev 0) +++ trunk/sandbox/ast/jy23 2007-12-08 03:29:35 UTC (rev 3768) @@ -0,0 +1 @@ +find ~/src/jython/trunk/jython/Lib -name '*.py' -print -exec ./run {} \; Property changes on: trunk/sandbox/ast/jy23 ___________________________________________________________________ Name: svn:executable + * Added: trunk/sandbox/ast/py25 =================================================================== --- trunk/sandbox/ast/py25 (rev 0) +++ trunk/sandbox/ast/py25 2007-12-08 03:29:35 UTC (rev 3768) @@ -0,0 +1 @@ +find ~/src/python/release25-maint/Lib -name '*.py' -print -exec ./run {} \; Property changes on: trunk/sandbox/ast/py25 ___________________________________________________________________ Name: svn:executable + * Added: trunk/sandbox/ast/regr =================================================================== --- trunk/sandbox/ast/regr (rev 0) +++ trunk/sandbox/ast/regr 2007-12-08 03:29:35 UTC (rev 3768) @@ -0,0 +1,1240 @@ +echo Lib/_ +./run /Users/frank/src/python/release25-maint/Lib/__future__.py +./run /Users/frank/src/python/release25-maint/Lib/__phello__.foo.py +./run /Users/frank/src/python/release25-maint/Lib/_LWPCookieJar.py +./run /Users/frank/src/python/release25-maint/Lib/_MozillaCookieJar.py +#./run /Users/frank/src/python/release25-maint/Lib/_strptime.py +./run /Users/frank/src/python/release25-maint/Lib/_threading_local.py +./run /Users/frank/src/python/release25-maint/Lib/aifc.py +./run /Users/frank/src/python/release25-maint/Lib/anydbm.py +./run /Users/frank/src/python/release25-maint/Lib/asynchat.py +./run /Users/frank/src/python/release25-maint/Lib/asyncore.py +./run /Users/frank/src/python/release25-maint/Lib/atexit.py +./run /Users/frank/src/python/release25-maint/Lib/audiodev.py +#./run /Users/frank/src/python/release25-maint/Lib/base64.py +./run /Users/frank/src/python/release25-maint/Lib/BaseHTTPServer.py +./run /Users/frank/src/python/release25-maint/Lib/Bastion.py +./run /Users/frank/src/python/release25-maint/Lib/bdb.py +./run /Users/frank/src/python/release25-maint/Lib/binhex.py +./run /Users/frank/src/python/release25-maint/Lib/bisect.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/db.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/dbobj.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/dbrecio.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/dbshelve.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/dbtables.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/dbutils.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_1413192.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_all.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_associate.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_basics.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_compare.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_compat.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_cursor_pget_bug.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_dbobj.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_dbshelve.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_dbtables.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_env_close.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_get_none.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_join.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_lock.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_misc.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_pickle.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_queue.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_recno.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_sequence.py +./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_thread.py +echo Lib/c + +#./run /Users/frank/src/python/release25-maint/Lib/calendar.py +./run /Users/frank/src/python/release25-maint/Lib/cgi.py +./run /Users/frank/src/python/release25-maint/Lib/CGIHTTPServer.py +./run /Users/frank/src/python/release25-maint/Lib/cgitb.py +./run /Users/frank/src/python/release25-maint/Lib/chunk.py +./run /Users/frank/src/python/release25-maint/Lib/cmd.py +./run /Users/frank/src/python/release25-maint/Lib/code.py +./run /Users/frank/src/python/release25-maint/Lib/codecs.py +./run /Users/frank/src/python/release25-maint/Lib/codeop.py +./run /Users/frank/src/python/release25-maint/Lib/colorsys.py +./run /Users/frank/src/python/release25-maint/Lib/commands.py +./run /Users/frank/src/python/release25-maint/Lib/compileall.py +./run /Users/frank/src/python/release25-maint/Lib/compiler/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/compiler/ast.py +./run /Users/frank/src/python/release25-maint/Lib/compiler/consts.py +./run /Users/frank/src/python/release25-maint/Lib/compiler/future.py +./run /Users/frank/src/python/release25-maint/Lib/compiler/misc.py +./run /Users/frank/src/python/release25-maint/Lib/compiler/pyassem.py +#./run /Users/frank/src/python/release25-maint/Lib/compiler/pycodegen.py +./run /Users/frank/src/python/release25-maint/Lib/compiler/symbols.py +./run /Users/frank/src/python/release25-maint/Lib/compiler/syntax.py +./run /Users/frank/src/python/release25-maint/Lib/compiler/transformer.py +./run /Users/frank/src/python/release25-maint/Lib/compiler/visitor.py +./run /Users/frank/src/python/release25-maint/Lib/ConfigParser.py +./run /Users/frank/src/python/release25-maint/Lib/contextlib.py +#./run /Users/frank/src/python/release25-maint/Lib/Cookie.py +./run /Users/frank/src/python/release25-maint/Lib/cookielib.py +./run /Users/frank/src/python/release25-maint/Lib/copy.py +./run /Users/frank/src/python/release25-maint/Lib/copy_reg.py +./run /Users/frank/src/python/release25-maint/Lib/cProfile.py +./run /Users/frank/src/python/release25-maint/Lib/csv.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/_endian.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/macholib/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/macholib/dyld.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/macholib/dylib.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/macholib/framework.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/runtests.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_anon.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_array_in_pointer.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_arrays.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_as_parameter.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_bitfields.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_buffers.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_byteswap.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_callbacks.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_cast.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_cfuncs.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_checkretval.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_errcheck.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_find.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_funcptr.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_functions.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_incomplete.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_init.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_integers.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_internals.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_keeprefs.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_libc.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_loading.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_macholib.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_memfunctions.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_numbers.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_objects.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_parameters.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_pointers.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_prototypes.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_python_api.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_random_things.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_refcounts.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_repr.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_returnfuncptrs.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_simplesubclasses.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_sizes.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_slicing.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_stringptr.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_strings.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_struct_fields.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_structures.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_unaligned_structures.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_unicode.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_values.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_varsize_struct.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/test/test_win32.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/util.py +./run /Users/frank/src/python/release25-maint/Lib/ctypes/wintypes.py +./run /Users/frank/src/python/release25-maint/Lib/curses/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/curses/ascii.py +./run /Users/frank/src/python/release25-maint/Lib/curses/has_key.py +./run /Users/frank/src/python/release25-maint/Lib/curses/panel.py +./run /Users/frank/src/python/release25-maint/Lib/curses/textpad.py +./run /Users/frank/src/python/release25-maint/Lib/curses/wrapper.py +./run /Users/frank/src/python/release25-maint/Lib/dbhash.py +./run /Users/frank/src/python/release25-maint/Lib/decimal.py +./run /Users/frank/src/python/release25-maint/Lib/difflib.py +./run /Users/frank/src/python/release25-maint/Lib/dircache.py +./run /Users/frank/src/python/release25-maint/Lib/dis.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/archive_util.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/bcppcompiler.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/ccompiler.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/cmd.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/bdist.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/bdist_dumb.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/bdist_msi.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/bdist_rpm.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/bdist_wininst.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/build.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/build_clib.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/build_ext.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/build_py.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/build_scripts.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/clean.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/config.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/install.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/install_data.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/install_egg_info.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/install_headers.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/install_lib.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/install_scripts.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/register.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/sdist.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/command/upload.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/core.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/cygwinccompiler.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/debug.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/dep_util.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/dir_util.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/dist.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/emxccompiler.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/errors.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/extension.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/fancy_getopt.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/file_util.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/filelist.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/log.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/msvccompiler.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/mwerkscompiler.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/spawn.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/sysconfig.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/tests/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/tests/support.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/tests/test_build_py.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/tests/test_build_scripts.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/tests/test_dist.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/tests/test_install.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/tests/test_install_scripts.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/tests/test_versionpredicate.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/text_file.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/unixccompiler.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/util.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/version.py +./run /Users/frank/src/python/release25-maint/Lib/distutils/versionpredicate.py +./run /Users/frank/src/python/release25-maint/Lib/doctest.py +./run /Users/frank/src/python/release25-maint/Lib/DocXMLRPCServer.py +./run /Users/frank/src/python/release25-maint/Lib/dumbdbm.py +./run /Users/frank/src/python/release25-maint/Lib/dummy_thread.py +./run /Users/frank/src/python/release25-maint/Lib/dummy_threading.py +#./run /Users/frank/src/python/release25-maint/Lib/email/__init__.py +#./run /Users/frank/src/python/release25-maint/Lib/email/_parseaddr.py +#./run /Users/frank/src/python/release25-maint/Lib/email/base64mime.py +#./run /Users/frank/src/python/release25-maint/Lib/email/charset.py +#./run /Users/frank/src/python/release25-maint/Lib/email/encoders.py +#./run /Users/frank/src/python/release25-maint/Lib/email/errors.py +#./run /Users/frank/src/python/release25-maint/Lib/email/feedparser.py +#./run /Users/frank/src/python/release25-maint/Lib/email/generator.py +#./run /Users/frank/src/python/release25-maint/Lib/email/header.py +#./run /Users/frank/src/python/release25-maint/Lib/email/iterators.py +#./run /Users/frank/src/python/release25-maint/Lib/email/message.py +./run /Users/frank/src/python/release25-maint/Lib/email/mime/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/email/mime/application.py +#./run /Users/frank/src/python/release25-maint/Lib/email/mime/audio.py +#./run /Users/frank/src/python/release25-maint/Lib/email/mime/base.py +#./run /Users/frank/src/python/release25-maint/Lib/email/mime/image.py +#./run /Users/frank/src/python/release25-maint/Lib/email/mime/message.py +#./run /Users/frank/src/python/release25-maint/Lib/email/mime/multipart.py +#./run /Users/frank/src/python/release25-maint/Lib/email/mime/nonmultipart.py +#./run /Users/frank/src/python/release25-maint/Lib/email/mime/text.py +#./run /Users/frank/src/python/release25-maint/Lib/email/parser.py +#./run /Users/frank/src/python/release25-maint/Lib/email/quoprimime.py +./run /Users/frank/src/python/release25-maint/Lib/email/test/__init__.py +#./run /Users/frank/src/python/release25-maint/Lib/email/test/test_email.py +#./run /Users/frank/src/python/release25-maint/Lib/email/test/test_email_codecs.py +#./run /Users/frank/src/python/release25-maint/Lib/email/test/test_email_codecs_renamed.py +#./run /Users/frank/src/python/release25-maint/Lib/email/test/test_email_renamed.py +#./run /Users/frank/src/python/release25-maint/Lib/email/test/test_email_torture.py +#./run /Users/frank/src/python/release25-maint/Lib/email/utils.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/aliases.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/ascii.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/base64_codec.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/big5.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/big5hkscs.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/bz2_codec.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/charmap.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp037.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp1006.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp1026.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp1140.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp1250.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp1251.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp1252.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp1253.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp1254.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp1255.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp1256.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp1257.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp1258.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp424.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp437.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp500.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp737.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp775.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp850.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp852.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp855.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp856.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp857.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp860.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp861.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp862.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp863.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp864.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp865.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp866.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp869.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp874.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp875.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp932.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp949.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/cp950.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/euc_jis_2004.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/euc_jisx0213.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/euc_jp.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/euc_kr.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/gb18030.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/gb2312.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/gbk.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/hex_codec.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/hp_roman8.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/hz.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/idna.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso2022_jp.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso2022_jp_1.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso2022_jp_2.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso2022_jp_2004.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso2022_jp_3.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso2022_jp_ext.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso2022_kr.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso8859_1.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso8859_10.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso8859_11.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso8859_13.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso8859_14.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso8859_15.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso8859_16.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso8859_2.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso8859_3.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso8859_4.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso8859_5.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso8859_6.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso8859_7.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso8859_8.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/iso8859_9.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/johab.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/koi8_r.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/koi8_u.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/latin_1.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/mac_arabic.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/mac_centeuro.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/mac_croatian.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/mac_cyrillic.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/mac_farsi.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/mac_greek.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/mac_iceland.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/mac_latin2.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/mac_roman.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/mac_romanian.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/mac_turkish.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/mbcs.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/palmos.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/ptcp154.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/punycode.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/quopri_codec.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/raw_unicode_escape.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/rot_13.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/shift_jis.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/shift_jis_2004.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/shift_jisx0213.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/string_escape.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/tis_620.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/undefined.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/unicode_escape.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/unicode_internal.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/utf_16.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/utf_16_be.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/utf_16_le.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/utf_7.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/utf_8.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/utf_8_sig.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/uu_codec.py +./run /Users/frank/src/python/release25-maint/Lib/encodings/zlib_codec.py +echo Lib/f +./run /Users/frank/src/python/release25-maint/Lib/filecmp.py +./run /Users/frank/src/python/release25-maint/Lib/fileinput.py +./run /Users/frank/src/python/release25-maint/Lib/fnmatch.py +./run /Users/frank/src/python/release25-maint/Lib/formatter.py +./run /Users/frank/src/python/release25-maint/Lib/fpformat.py +./run /Users/frank/src/python/release25-maint/Lib/ftplib.py +./run /Users/frank/src/python/release25-maint/Lib/functools.py +./run /Users/frank/src/python/release25-maint/Lib/getopt.py +./run /Users/frank/src/python/release25-maint/Lib/getpass.py +#./run /Users/frank/src/python/release25-maint/Lib/gettext.py +./run /Users/frank/src/python/release25-maint/Lib/glob.py +./run /Users/frank/src/python/release25-maint/Lib/gopherlib.py +./run /Users/frank/src/python/release25-maint/Lib/gzip.py +./run /Users/frank/src/python/release25-maint/Lib/hashlib.py +./run /Users/frank/src/python/release25-maint/Lib/heapq.py +#./run /Users/frank/src/python/release25-maint/Lib/hmac.py +./run /Users/frank/src/python/release25-maint/Lib/hotshot/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/hotshot/log.py +./run /Users/frank/src/python/release25-maint/Lib/hotshot/stats.py +./run /Users/frank/src/python/release25-maint/Lib/hotshot/stones.py +./run /Users/frank/src/python/release25-maint/Lib/htmlentitydefs.py +./run /Users/frank/src/python/release25-maint/Lib/htmllib.py +./run /Users/frank/src/python/release25-maint/Lib/HTMLParser.py +./run /Users/frank/src/python/release25-maint/Lib/httplib.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/aboutDialog.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/AutoComplete.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/AutoCompleteWindow.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/AutoExpand.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/Bindings.py +#./run /Users/frank/src/python/release25-maint/Lib/idlelib/CallTips.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/CallTipWindow.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/ClassBrowser.py +#./run /Users/frank/src/python/release25-maint/Lib/idlelib/CodeContext.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/ColorDelegator.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/configDialog.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/configHandler.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/configHelpSourceEdit.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/configSectionNameDialog.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/Debugger.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/Delegator.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/dynOptionMenuWidget.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/EditorWindow.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/FileList.py +#./run /Users/frank/src/python/release25-maint/Lib/idlelib/FormatParagraph.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/GrepDialog.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/HyperParser.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/idle.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/IdleHistory.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/idlever.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/IOBinding.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/keybindingDialog.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/macosxSupport.py +#./run /Users/frank/src/python/release25-maint/Lib/idlelib/MultiCall.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/MultiStatusBar.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/ObjectBrowser.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/OutputWindow.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/ParenMatch.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/PathBrowser.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/Percolator.py +#./run /Users/frank/src/python/release25-maint/Lib/idlelib/PyParse.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/PyShell.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/RemoteDebugger.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/RemoteObjectBrowser.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/ReplaceDialog.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/rpc.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/run.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/ScriptBinding.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/ScrolledList.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/SearchDialog.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/SearchDialogBase.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/SearchEngine.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/StackViewer.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/tabpage.py +#./run /Users/frank/src/python/release25-maint/Lib/idlelib/testcode.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/textView.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/ToolTip.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/TreeWidget.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/UndoDelegator.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/WidgetRedirector.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/WindowList.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/ZoomHeight.py +./run /Users/frank/src/python/release25-maint/Lib/ihooks.py +./run /Users/frank/src/python/release25-maint/Lib/imaplib.py +./run /Users/frank/src/python/release25-maint/Lib/imghdr.py +./run /Users/frank/src/python/release25-maint/Lib/imputil.py +./run /Users/frank/src/python/release25-maint/Lib/inspect.py +echo Lib/k +./run /Users/frank/src/python/release25-maint/Lib/keyword.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/Canvas.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/Dialog.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/FileDialog.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/FixTk.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/ScrolledText.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/SimpleDialog.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/Tix.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/tkColorChooser.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/tkCommonDialog.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/Tkconstants.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/Tkdnd.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/tkFileDialog.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/tkFont.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/Tkinter.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/tkMessageBox.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/tkSimpleDialog.py +./run /Users/frank/src/python/release25-maint/Lib/lib-tk/turtle.py +./run /Users/frank/src/python/release25-maint/Lib/linecache.py +./run /Users/frank/src/python/release25-maint/Lib/locale.py +#./run /Users/frank/src/python/release25-maint/Lib/logging/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/logging/config.py +./run /Users/frank/src/python/release25-maint/Lib/logging/handlers.py +./run /Users/frank/src/python/release25-maint/Lib/macpath.py +./run /Users/frank/src/python/release25-maint/Lib/macurl2path.py +#./run /Users/frank/src/python/release25-maint/Lib/mailbox.py +./run /Users/frank/src/python/release25-maint/Lib/mailcap.py +./run /Users/frank/src/python/release25-maint/Lib/markupbase.py +./run /Users/frank/src/python/release25-maint/Lib/md5.py +./run /Users/frank/src/python/release25-maint/Lib/mhlib.py +./run /Users/frank/src/python/release25-maint/Lib/mimetools.py +./run /Users/frank/src/python/release25-maint/Lib/mimetypes.py +./run /Users/frank/src/python/release25-maint/Lib/MimeWriter.py +./run /Users/frank/src/python/release25-maint/Lib/mimify.py +./run /Users/frank/src/python/release25-maint/Lib/modulefinder.py +./run /Users/frank/src/python/release25-maint/Lib/msilib/__init__.py +#./run /Users/frank/src/python/release25-maint/Lib/msilib/schema.py +./run /Users/frank/src/python/release25-maint/Lib/msilib/sequence.py +./run /Users/frank/src/python/release25-maint/Lib/msilib/text.py +./run /Users/frank/src/python/release25-maint/Lib/multifile.py +./run /Users/frank/src/python/release25-maint/Lib/mutex.py +echo Lib/n +./run /Users/frank/src/python/release25-maint/Lib/netrc.py +./run /Users/frank/src/python/release25-maint/Lib/new.py +./run /Users/frank/src/python/release25-maint/Lib/nntplib.py +./run /Users/frank/src/python/release25-maint/Lib/ntpath.py +./run /Users/frank/src/python/release25-maint/Lib/nturl2path.py +./run /Users/frank/src/python/release25-maint/Lib/opcode.py +./run /Users/frank/src/python/release25-maint/Lib/optparse.py +./run /Users/frank/src/python/release25-maint/Lib/os.py +./run /Users/frank/src/python/release25-maint/Lib/os2emxpath.py +./run /Users/frank/src/python/release25-maint/Lib/pdb.py +./run /Users/frank/src/python/release25-maint/Lib/pickle.py +#./run /Users/frank/src/python/release25-maint/Lib/pickletools.py +./run /Users/frank/src/python/release25-maint/Lib/pipes.py +#./run /Users/frank/src/python/release25-maint/Lib/pkgutil.py +./run /Users/frank/src/python/release25-maint/Lib/plat-aix3/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-aix4/IN.py +#./run /Users/frank/src/python/release25-maint/Lib/plat-atheos/IN.py +#./run /Users/frank/src/python/release25-maint/Lib/plat-atheos/TYPES.py +#./run /Users/frank/src/python/release25-maint/Lib/plat-beos5/IN.py +#./run /Users/frank/src/python/release25-maint/Lib/plat-darwin/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-freebsd2/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-freebsd3/IN.py +#./run /Users/frank/src/python/release25-maint/Lib/plat-freebsd4/IN.py +#./run /Users/frank/src/python/release25-maint/Lib/plat-freebsd5/IN.py +#./run /Users/frank/src/python/release25-maint/Lib/plat-freebsd6/IN.py +#./run /Users/frank/src/python/release25-maint/Lib/plat-freebsd7/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/AL.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/CD.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/cddb.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/cdplayer.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/CL.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/CL_old.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/DEVICE.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/ERRNO.py +#./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/FILE.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/FL.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/flp.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/GET.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/GL.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/GLWS.py +#./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/IOCTL.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/jpeg.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/panel.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/panelparser.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/readcd.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/SV.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/torgb.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/WAIT.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/AL.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/CD.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/cddb.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/cdplayer.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/CL.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/DEVICE.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/ERRNO.py +#./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/FILE.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/FL.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/flp.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/GET.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/GL.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/GLWS.py +#./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/IOCTL.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/jpeg.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/panel.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/panelparser.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/readcd.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/SV.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/torgb.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/WAIT.py +./run /Users/frank/src/python/release25-maint/Lib/plat-linux2/CDROM.py +./run /Users/frank/src/python/release25-maint/Lib/plat-linux2/DLFCN.py +#./run /Users/frank/src/python/release25-maint/Lib/plat-linux2/IN.py +#./run /Users/frank/src/python/release25-maint/Lib/plat-linux2/TYPES.py +echo Lib/plat-mac +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/aepack.py +#./run /Users/frank/src/python/release25-maint/Lib/plat-mac/aetools.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/aetypes.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/applesingle.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/appletrawmain.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/appletrunner.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/argvemulator.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Audio_mac.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/bgenlocations.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/buildtools.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/bundlebuilder.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/AE.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/AH.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Alias.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Aliases.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/App.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Appearance.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/AppleEvents.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/AppleHelp.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/CarbonEvents.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/CarbonEvt.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/CF.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/CG.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Cm.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Components.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/ControlAccessor.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Controls.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/CoreFoundation.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/CoreGraphics.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Ctl.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Dialogs.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Dlg.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Drag.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Dragconst.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Events.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Evt.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/File.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Files.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Fm.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Folder.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Folders.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Fonts.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Help.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/IBCarbon.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/IBCarbonRuntime.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Icn.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Icons.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Launch.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/LaunchServices.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/List.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Lists.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/MacHelp.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/MacTextEditor.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/MediaDescr.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Menu.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Menus.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Mlte.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/OSA.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/OSAconst.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Qd.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Qdoffs.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/QDOffscreen.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Qt.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/QuickDraw.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/QuickTime.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Res.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Resources.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Scrap.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Snd.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Sndihooks.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Sound.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/TE.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/TextEdit.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Win.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/Carbon/Windows.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/cfmfile.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/EasyDialogs.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/findertools.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/FrameWork.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/gensuitemodule.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/ic.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/icopen.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/_builtinSuites/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/_builtinSuites/builtin_Suite.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/CodeWarrior/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/CodeWarrior/CodeWarrior_suite.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/CodeWarrior/Metrowerks_Shell_Suite.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/CodeWarrior/Required.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/CodeWarrior/Standard_Suite.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/Explorer/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/Explorer/Microsoft_Internet_Explorer.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/Explorer/Netscape_Suite.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/Explorer/Required_Suite.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/Explorer/Standard_Suite.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/Explorer/URL_Suite.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/Explorer/Web_Browser_Suite.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/Finder/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/Finder/Containers_and_folders.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/Finder/Enumerations.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/Finder/Files.py +./run /Users/frank/src/python/release25-maint/Lib/... [truncated message content] |
From: <fwi...@us...> - 2007-12-08 04:01:26
|
Revision: 3769 http://jython.svn.sourceforge.net/jython/?rev=3769&view=rev Author: fwierzbicki Date: 2007-12-07 20:01:22 -0800 (Fri, 07 Dec 2007) Log Message: ----------- Lexer ignores formfeed now (py25 libs have them - especially in the email libs -- probably ignoring them is not the right thing to do - put an XXX comment in the grammar to check later. Modified Paths: -------------- trunk/sandbox/ast/grammar/Python.g trunk/sandbox/ast/regr Modified: trunk/sandbox/ast/grammar/Python.g =================================================================== --- trunk/sandbox/ast/grammar/Python.g 2007-12-08 03:29:35 UTC (rev 3768) +++ trunk/sandbox/ast/grammar/Python.g 2007-12-08 04:01:22 UTC (rev 3769) @@ -914,3 +914,8 @@ : {startPos==0}?=> (' '|'\t')* '#' (~'\n')* '\n'+ | {startPos>0}?=> '#' (~'\n')* // let NEWLINE handle \n unless char pos==0 for '#' ; + +/* XXX: Just discarding form feeds -- Does python assing any meaning to formfeed? */ +FORMFEED : '\u000C' {$channel=HIDDEN;} + ; + Modified: trunk/sandbox/ast/regr =================================================================== --- trunk/sandbox/ast/regr 2007-12-08 03:29:35 UTC (rev 3768) +++ trunk/sandbox/ast/regr 2007-12-08 04:01:22 UTC (rev 3769) @@ -11,7 +11,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/asyncore.py ./run /Users/frank/src/python/release25-maint/Lib/atexit.py ./run /Users/frank/src/python/release25-maint/Lib/audiodev.py -#./run /Users/frank/src/python/release25-maint/Lib/base64.py +./run /Users/frank/src/python/release25-maint/Lib/base64.py ./run /Users/frank/src/python/release25-maint/Lib/BaseHTTPServer.py ./run /Users/frank/src/python/release25-maint/Lib/Bastion.py ./run /Users/frank/src/python/release25-maint/Lib/bdb.py @@ -207,35 +207,35 @@ ./run /Users/frank/src/python/release25-maint/Lib/dumbdbm.py ./run /Users/frank/src/python/release25-maint/Lib/dummy_thread.py ./run /Users/frank/src/python/release25-maint/Lib/dummy_threading.py -#./run /Users/frank/src/python/release25-maint/Lib/email/__init__.py -#./run /Users/frank/src/python/release25-maint/Lib/email/_parseaddr.py -#./run /Users/frank/src/python/release25-maint/Lib/email/base64mime.py -#./run /Users/frank/src/python/release25-maint/Lib/email/charset.py -#./run /Users/frank/src/python/release25-maint/Lib/email/encoders.py -#./run /Users/frank/src/python/release25-maint/Lib/email/errors.py -#./run /Users/frank/src/python/release25-maint/Lib/email/feedparser.py -#./run /Users/frank/src/python/release25-maint/Lib/email/generator.py -#./run /Users/frank/src/python/release25-maint/Lib/email/header.py -#./run /Users/frank/src/python/release25-maint/Lib/email/iterators.py -#./run /Users/frank/src/python/release25-maint/Lib/email/message.py +./run /Users/frank/src/python/release25-maint/Lib/email/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/email/_parseaddr.py +./run /Users/frank/src/python/release25-maint/Lib/email/base64mime.py +./run /Users/frank/src/python/release25-maint/Lib/email/charset.py +./run /Users/frank/src/python/release25-maint/Lib/email/encoders.py +./run /Users/frank/src/python/release25-maint/Lib/email/errors.py +./run /Users/frank/src/python/release25-maint/Lib/email/feedparser.py +./run /Users/frank/src/python/release25-maint/Lib/email/generator.py +./run /Users/frank/src/python/release25-maint/Lib/email/header.py +./run /Users/frank/src/python/release25-maint/Lib/email/iterators.py +./run /Users/frank/src/python/release25-maint/Lib/email/message.py ./run /Users/frank/src/python/release25-maint/Lib/email/mime/__init__.py ./run /Users/frank/src/python/release25-maint/Lib/email/mime/application.py -#./run /Users/frank/src/python/release25-maint/Lib/email/mime/audio.py -#./run /Users/frank/src/python/release25-maint/Lib/email/mime/base.py -#./run /Users/frank/src/python/release25-maint/Lib/email/mime/image.py -#./run /Users/frank/src/python/release25-maint/Lib/email/mime/message.py -#./run /Users/frank/src/python/release25-maint/Lib/email/mime/multipart.py -#./run /Users/frank/src/python/release25-maint/Lib/email/mime/nonmultipart.py -#./run /Users/frank/src/python/release25-maint/Lib/email/mime/text.py -#./run /Users/frank/src/python/release25-maint/Lib/email/parser.py -#./run /Users/frank/src/python/release25-maint/Lib/email/quoprimime.py +./run /Users/frank/src/python/release25-maint/Lib/email/mime/audio.py +./run /Users/frank/src/python/release25-maint/Lib/email/mime/base.py +./run /Users/frank/src/python/release25-maint/Lib/email/mime/image.py +./run /Users/frank/src/python/release25-maint/Lib/email/mime/message.py +./run /Users/frank/src/python/release25-maint/Lib/email/mime/multipart.py +./run /Users/frank/src/python/release25-maint/Lib/email/mime/nonmultipart.py +./run /Users/frank/src/python/release25-maint/Lib/email/mime/text.py +./run /Users/frank/src/python/release25-maint/Lib/email/parser.py +./run /Users/frank/src/python/release25-maint/Lib/email/quoprimime.py ./run /Users/frank/src/python/release25-maint/Lib/email/test/__init__.py -#./run /Users/frank/src/python/release25-maint/Lib/email/test/test_email.py -#./run /Users/frank/src/python/release25-maint/Lib/email/test/test_email_codecs.py -#./run /Users/frank/src/python/release25-maint/Lib/email/test/test_email_codecs_renamed.py -#./run /Users/frank/src/python/release25-maint/Lib/email/test/test_email_renamed.py -#./run /Users/frank/src/python/release25-maint/Lib/email/test/test_email_torture.py -#./run /Users/frank/src/python/release25-maint/Lib/email/utils.py +./run /Users/frank/src/python/release25-maint/Lib/email/test/test_email.py +./run /Users/frank/src/python/release25-maint/Lib/email/test/test_email_codecs.py +./run /Users/frank/src/python/release25-maint/Lib/email/test/test_email_codecs_renamed.py +./run /Users/frank/src/python/release25-maint/Lib/email/test/test_email_renamed.py +./run /Users/frank/src/python/release25-maint/Lib/email/test/test_email_torture.py +./run /Users/frank/src/python/release25-maint/Lib/email/utils.py ./run /Users/frank/src/python/release25-maint/Lib/encodings/__init__.py ./run /Users/frank/src/python/release25-maint/Lib/encodings/aliases.py ./run /Users/frank/src/python/release25-maint/Lib/encodings/ascii.py @@ -500,7 +500,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/plat-aix4/IN.py #./run /Users/frank/src/python/release25-maint/Lib/plat-atheos/IN.py #./run /Users/frank/src/python/release25-maint/Lib/plat-atheos/TYPES.py -#./run /Users/frank/src/python/release25-maint/Lib/plat-beos5/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-beos5/IN.py #./run /Users/frank/src/python/release25-maint/Lib/plat-darwin/IN.py ./run /Users/frank/src/python/release25-maint/Lib/plat-freebsd2/IN.py ./run /Users/frank/src/python/release25-maint/Lib/plat-freebsd3/IN.py @@ -516,13 +516,13 @@ ./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/CL_old.py ./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/DEVICE.py ./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/ERRNO.py -#./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/FILE.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/FILE.py ./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/FL.py ./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/flp.py ./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/GET.py ./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/GL.py ./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/GLWS.py -#./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/IN.py ./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/IOCTL.py ./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/jpeg.py ./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/panel.py @@ -860,7 +860,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_atexit.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_audioop.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_augassign.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_base64.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_base64.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_bastion.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_bigaddrspace.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_bigmem.py @@ -997,7 +997,7 @@ #./run /Users/frank/src/python/release25-maint/Lib/test/test_index.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_inspect.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_ioctl.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_isinstance.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_isinstance.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_iter.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_iterlen.py #./run /Users/frank/src/python/release25-maint/Lib/test/test_itertools.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-08 16:44:16
|
Revision: 3773 http://jython.svn.sourceforge.net/jython/?rev=3773&view=rev Author: fwierzbicki Date: 2007-12-08 08:44:14 -0800 (Sat, 08 Dec 2007) Log Message: ----------- fleshed out Assign in the walker. Modified Paths: -------------- trunk/sandbox/ast/grammar/PythonWalker.g Added Paths: ----------- trunk/sandbox/ast/fails Added: trunk/sandbox/ast/fails =================================================================== --- trunk/sandbox/ast/fails (rev 0) +++ trunk/sandbox/ast/fails 2007-12-08 16:44:14 UTC (rev 3773) @@ -0,0 +1,164 @@ +echo /Users/frank/src/python/release25-maint/Lib/_strptime.py +./run /Users/frank/src/python/release25-maint/Lib/_strptime.py +echo /Users/frank/src/python/release25-maint/Lib/calendar.py +./run /Users/frank/src/python/release25-maint/Lib/calendar.py +echo /Users/frank/src/python/release25-maint/Lib/compiler/pycodegen.py +./run /Users/frank/src/python/release25-maint/Lib/compiler/pycodegen.py +echo /Users/frank/src/python/release25-maint/Lib/Cookie.py +./run /Users/frank/src/python/release25-maint/Lib/Cookie.py +echo /Users/frank/src/python/release25-maint/Lib/gettext.py +./run /Users/frank/src/python/release25-maint/Lib/gettext.py +echo /Users/frank/src/python/release25-maint/Lib/hmac.py +./run /Users/frank/src/python/release25-maint/Lib/hmac.py +echo /Users/frank/src/python/release25-maint/Lib/idlelib/CallTips.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/CallTips.py +echo /Users/frank/src/python/release25-maint/Lib/idlelib/CodeContext.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/CodeContext.py +echo /Users/frank/src/python/release25-maint/Lib/idlelib/FormatParagraph.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/FormatParagraph.py +echo /Users/frank/src/python/release25-maint/Lib/idlelib/MultiCall.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/MultiCall.py +echo /Users/frank/src/python/release25-maint/Lib/idlelib/PyParse.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/PyParse.py +echo /Users/frank/src/python/release25-maint/Lib/idlelib/testcode.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/testcode.py +echo /Users/frank/src/python/release25-maint/Lib/logging/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/logging/__init__.py +echo /Users/frank/src/python/release25-maint/Lib/mailbox.py +./run /Users/frank/src/python/release25-maint/Lib/mailbox.py +echo /Users/frank/src/python/release25-maint/Lib/msilib/schema.py +./run /Users/frank/src/python/release25-maint/Lib/msilib/schema.py +echo /Users/frank/src/python/release25-maint/Lib/pickletools.py +./run /Users/frank/src/python/release25-maint/Lib/pickletools.py +echo /Users/frank/src/python/release25-maint/Lib/pkgutil.py +./run /Users/frank/src/python/release25-maint/Lib/pkgutil.py +echo /Users/frank/src/python/release25-maint/Lib/plat-atheos/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-atheos/IN.py +echo /Users/frank/src/python/release25-maint/Lib/plat-atheos/TYPES.py +./run /Users/frank/src/python/release25-maint/Lib/plat-atheos/TYPES.py +echo /Users/frank/src/python/release25-maint/Lib/plat-beos5/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-beos5/IN.py +echo /Users/frank/src/python/release25-maint/Lib/plat-darwin/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-darwin/IN.py +echo /Users/frank/src/python/release25-maint/Lib/plat-freebsd4/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-freebsd4/IN.py +echo /Users/frank/src/python/release25-maint/Lib/plat-freebsd5/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-freebsd5/IN.py +echo /Users/frank/src/python/release25-maint/Lib/plat-freebsd6/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-freebsd6/IN.py +echo /Users/frank/src/python/release25-maint/Lib/plat-freebsd7/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-freebsd7/IN.py +echo /Users/frank/src/python/release25-maint/Lib/plat-irix5/FILE.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/FILE.py +echo /Users/frank/src/python/release25-maint/Lib/plat-irix6/FILE.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/FILE.py +echo /Users/frank/src/python/release25-maint/Lib/plat-irix6/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/IN.py +echo /Users/frank/src/python/release25-maint/Lib/plat-linux2/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-linux2/IN.py +echo /Users/frank/src/python/release25-maint/Lib/plat-linux2/TYPES.py +./run /Users/frank/src/python/release25-maint/Lib/plat-linux2/TYPES.py +echo /Users/frank/src/python/release25-maint/Lib/plat-mac/aetools.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/aetools.py +echo /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py +./run /Users/frank/src/python/release25-maint/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py +echo /Users/frank/src/python/release25-maint/Lib/plat-sunos5/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-sunos5/IN.py +echo /Users/frank/src/python/release25-maint/Lib/plat-sunos5/STROPTS.py +./run /Users/frank/src/python/release25-maint/Lib/plat-sunos5/STROPTS.py +echo /Users/frank/src/python/release25-maint/Lib/plat-sunos5/TYPES.py +./run /Users/frank/src/python/release25-maint/Lib/plat-sunos5/TYPES.py +echo /Users/frank/src/python/release25-maint/Lib/plat-unixware7/IN.py +./run /Users/frank/src/python/release25-maint/Lib/plat-unixware7/IN.py +echo /Users/frank/src/python/release25-maint/Lib/profile.py +./run /Users/frank/src/python/release25-maint/Lib/profile.py +echo /Users/frank/src/python/release25-maint/Lib/pydoc.py +./run /Users/frank/src/python/release25-maint/Lib/pydoc.py +echo /Users/frank/src/python/release25-maint/Lib/smtpd.py +./run /Users/frank/src/python/release25-maint/Lib/smtpd.py +echo /Users/frank/src/python/release25-maint/Lib/sqlite3/test/factory.py +./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/factory.py +echo /Users/frank/src/python/release25-maint/Lib/sqlite3/test/types.py +./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/types.py +echo /Users/frank/src/python/release25-maint/Lib/tarfile.py +./run /Users/frank/src/python/release25-maint/Lib/tarfile.py +echo /Users/frank/src/python/release25-maint/Lib/test/bad_coding2.py +./run /Users/frank/src/python/release25-maint/Lib/test/bad_coding2.py +echo /Users/frank/src/python/release25-maint/Lib/test/crashers/recursive_call.py +./run /Users/frank/src/python/release25-maint/Lib/test/crashers/recursive_call.py +echo /Users/frank/src/python/release25-maint/Lib/test/crashers/weakref_in_del.py +./run /Users/frank/src/python/release25-maint/Lib/test/crashers/weakref_in_del.py +echo /Users/frank/src/python/release25-maint/Lib/test/inspect_fodder2.py +./run /Users/frank/src/python/release25-maint/Lib/test/inspect_fodder2.py +echo /Users/frank/src/python/release25-maint/Lib/test/seq_tests.py +./run /Users/frank/src/python/release25-maint/Lib/test/seq_tests.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_bool.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_bool.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_builtin.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_builtin.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_calendar.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_calendar.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_codeccallbacks.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_codeccallbacks.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_codecs.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_codecs.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_compile.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_compile.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_complex.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_complex.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_complex_args.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_complex_args.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_copy.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_copy.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_decimal.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_decimal.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_decorators.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_decorators.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_descr.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_descr.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_dict.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_dict.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_doctest.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_doctest.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_exception_variations.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_exception_variations.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_format.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_format.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_grammar.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_grammar.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_import.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_import.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_index.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_index.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_itertools.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_itertools.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_mailbox.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_mailbox.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_multibytecodec.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_multibytecodec.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_multibytecodec_support.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_multibytecodec_support.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_pep352.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_pep352.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_random.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_random.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_scope.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_scope.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_set.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_set.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_socket.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_socket.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_struct.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_struct.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_thread.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_thread.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_userdict.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_userdict.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_uuid.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_uuid.py +echo /Users/frank/src/python/release25-maint/Lib/test/test_weakref.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_weakref.py +echo /Users/frank/src/python/release25-maint/Lib/urllib.py +./run /Users/frank/src/python/release25-maint/Lib/urllib.py +echo /Users/frank/src/python/release25-maint/Lib/urllib2.py +./run /Users/frank/src/python/release25-maint/Lib/urllib2.py Property changes on: trunk/sandbox/ast/fails ___________________________________________________________________ Name: svn:executable + * Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-08 15:00:17 UTC (rev 3772) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-08 16:44:14 UTC (rev 3773) @@ -250,7 +250,7 @@ } | ^(augassign targ=test[expr_contextType.Load] value=test[expr_contextType.Load]) { } - | ^(Assign targets ^(Value value=test[expr_contextType.Load])) { + | ^(Assign targets ^(Value value=test[expr_contextType.Store])) { debug("Matched Assign"); exprType[] e = new exprType[$targets.etypes.size()]; for(int i=0;i<$targets.etypes.size();i++) { @@ -396,10 +396,10 @@ //FIXME: lots of placeholders test[int ctype] returns [exprType etype] - : ^('and' test[expr_contextType.Load] test[expr_contextType.Load]) - | ^('or' test[expr_contextType.Load] test[expr_contextType.Load]) - | ^('not' test[expr_contextType.Load]) - | ^(comp_op left=test[expr_contextType.Load] targs=test[expr_contextType.Load]) { + : ^('and' test[ctype] test[ctype]) + | ^('or' test[ctype] test[ctype]) + | ^('not' test[ctype]) + | ^(comp_op left=test[ctype] targs=test[ctype]) { exprType[] targets = new exprType[1]; int[] ops = new int[1]; ops[0] = $comp_op.op; @@ -408,21 +408,21 @@ debug("COMP_OP: " + $comp_op.start); } | atom[ctype] (trailer)* {$etype = $atom.etype;} - | ^(PLUS test[expr_contextType.Load] test[expr_contextType.Load]) - | ^(MINUS left=test[expr_contextType.Load] right=test[expr_contextType.Load]) {} - | ^(AMPER test[expr_contextType.Load] test[expr_contextType.Load]) - | ^(VBAR test[expr_contextType.Load] test[expr_contextType.Load]) - | ^(CIRCUMFLEX test[expr_contextType.Load] test[expr_contextType.Load]) - | ^(LEFTSHIFT test[expr_contextType.Load] test[expr_contextType.Load]) - | ^(RIGHTSHIFT test[expr_contextType.Load] test[expr_contextType.Load]) - | ^(STAR test[expr_contextType.Load] test[expr_contextType.Load]) - | ^(SLASH test[expr_contextType.Load] test[expr_contextType.Load]) - | ^(PERCENT test[expr_contextType.Load] test[expr_contextType.Load]) - | ^(DOUBLESLASH test[expr_contextType.Load] test[expr_contextType.Load]) - | ^(DOUBLESTAR test[expr_contextType.Load] test[expr_contextType.Load]) - | ^(UAdd test[expr_contextType.Load]) - | ^(USub test[expr_contextType.Load]) - | ^(Invert test[expr_contextType.Load]) + | ^(PLUS test[ctype] test[ctype]) + | ^(MINUS left=test[ctype] right=test[ctype]) {} + | ^(AMPER test[ctype] test[ctype]) + | ^(VBAR test[ctype] test[ctype]) + | ^(CIRCUMFLEX test[ctype] test[ctype]) + | ^(LEFTSHIFT test[ctype] test[ctype]) + | ^(RIGHTSHIFT test[ctype] test[ctype]) + | ^(STAR test[ctype] test[ctype]) + | ^(SLASH test[ctype] test[ctype]) + | ^(PERCENT test[ctype] test[ctype]) + | ^(DOUBLESLASH test[ctype] test[ctype]) + | ^(DOUBLESTAR test[ctype] test[ctype]) + | ^(UAdd test[ctype]) + | ^(USub test[ctype]) + | ^(Invert test[ctype]) | lambdef ; @@ -440,15 +440,43 @@ | IsNot {$op = cmpopType.IsNot;} ; +//I *think* only sequences need to collect test rules in the walker since +//testlist in the parser either results in one test or a tuple. +elts[int ctype] returns [List etypes] +scope { + List elements; +} +@init { + $elts::elements = new ArrayList(); +} + + : elt[ctype]+ { + $etypes = $elts::elements; + } + ; + +elt[int ctype] + : test[ctype] { + $elts::elements.add($test.etype); + } + ; + //FIXME: lots of placeholders atom[int ctype] returns [exprType etype] - : ^(List test[expr_contextType.Load]*) {} + : ^(Tuple elts[ctype]) { + exprType[] e = new exprType[$elts.etypes.size()]; + for(int i=0;i<$elts.etypes.size();i++) { + e[i] = (exprType)$elts.etypes.get(i); + } + $etype = new Tuple($Tuple, e, ctype); + } + | ^(List test[ctype]*) {} | ^(ListComp list_for) {} | ^(GenExpFor gen_for) {} - | ^(Tuple test[expr_contextType.Load]*) {} - | ^(Parens test[expr_contextType.Load]*) {} - | ^(Dict test[expr_contextType.Load]*) {} - | ^(Repr test[expr_contextType.Load]*) {} +// | ^(Tuple test[ctype]*) {} + | ^(Parens test[ctype]*) {} + | ^(Dict test[ctype]*) {} + | ^(Repr test[ctype]*) {} | ^(Name NAME) {$etype = new Name($NAME, $NAME.text, ctype);} | ^(Num INT) {$etype = makeNum($INT);} | ^(Num LONGINT) {$etype = makeNum($LONGINT);} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-08 18:10:08
|
Revision: 3776 http://jython.svn.sourceforge.net/jython/?rev=3776&view=rev Author: fwierzbicki Date: 2007-12-08 10:10:06 -0800 (Sat, 08 Dec 2007) Log Message: ----------- Adding FunctionDef to output. Modified Paths: -------------- trunk/sandbox/ast/grammar/Python.g trunk/sandbox/ast/grammar/PythonWalker.g Added Paths: ----------- trunk/sandbox/ast/t3.py Modified: trunk/sandbox/ast/grammar/Python.g =================================================================== --- trunk/sandbox/ast/grammar/Python.g 2007-12-08 17:22:05 UTC (rev 3775) +++ trunk/sandbox/ast/grammar/Python.g 2007-12-08 18:10:06 UTC (rev 3776) @@ -214,7 +214,7 @@ //funcdef: [decorators] 'def' NAME parameters ':' suite funcdef : decorators? 'def' NAME parameters COLON suite - -> ^(FunctionDef ^(Name NAME) ^(Arguments parameters) ^(Body suite) ^(Decorators decorators)?) + -> ^(FunctionDef ^(Name NAME) ^(Arguments parameters) ^(Body suite) ^(Decorators decorators?)) ; //parameters: '(' [varargslist] ')' Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-08 17:22:05 UTC (rev 3775) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-08 18:10:06 UTC (rev 3776) @@ -69,19 +69,27 @@ return new Module(t, s); } - private FunctionDef makeFunctionDef(PythonTree t, PythonTree nameToken, argumentsType args, List funcStatements) { + private FunctionDef makeFunctionDef(PythonTree t, PythonTree nameToken, argumentsType args, List funcStatements, List decorators) { argumentsType a; + debug("Matched FunctionDef"); if (args != null) { a = args; } else { a = new argumentsType(t, new exprType[0], null, null, new exprType[0]); } stmtType[] s = (stmtType[])funcStatements.toArray(new stmtType[funcStatements.size()]); - return new FunctionDef(t, nameToken.getText(), a, s, null); + exprType[] d; + if (decorators != null) { + d = (exprType[])decorators.toArray(new exprType[decorators.size()]); + } else { + d = new exprType[0]; + } + return new FunctionDef(t, nameToken.getText(), a, s, d); } private argumentsType makeArgumentsType(PythonTree t, List params, PythonTree snameToken, PythonTree knameToken, List defaults) { + debug("Matched Arguments"); exprType[] p = (exprType[])params.toArray(new exprType[params.size()]); exprType[] d = (exprType[])defaults.toArray(new exprType[defaults.size()]); @@ -191,29 +199,51 @@ } ; -decorator: ^(Decorator dotted_name ^(ArgList arglist?)) - ; +funcdef + : ^(FunctionDef ^(Name NAME) ^(Arguments varargslist?) ^(Body stmts) ^(Decorators decorators?)) { + $stmts::statements.add(makeFunctionDef($FunctionDef, $NAME, $varargslist.args, $stmts.stypes, $decorators.etypes)); + } + ; -decorators: decorator+ - ; - -funcdef : ^(FunctionDef ^(Name NAME) ^(Arguments varargslist?) ^(Body suite) (^(Decorators decorators))? ) - ; - -varargslist - : ^(Args defparameter*) (^(StarArgs sname=NAME))? (^(KWArgs kname=NAME))? { +varargslist returns [argumentsType args] +@init { + List params = new ArrayList(); + List defaults = new ArrayList(); +} + : ^(Args defparameter[params, defaults]+) (^(StarArgs sname=NAME))? (^(KWArgs kname=NAME))? { + $args = makeArgumentsType($Args,params, $sname, $kname, defaults); } | ^(StarArgs sname=NAME) (^(KWArgs kname=NAME))? { + $args = makeArgumentsType($StarArgs,params, $sname, $kname, defaults); } | ^(KWArgs NAME) { + $args = makeArgumentsType($KWArgs, params, null, $NAME, defaults); } ; -defparameter +defparameter[List params, List defaults] : NAME (ASSIGN test[expr_contextType.Load] )? { + params.add(new Name($NAME, $NAME.text, org.python.antlr.ast.Name.Param)); + if ($test.etype != null) { + defaults.add($test.etype); + } } ; +decorator + : ^(Decorator dotted_name ^(ArgList arglist?)) + ; + +decorators returns [List etypes] +@init { + List decs = new ArrayList(); +} + : decorator+ { + $etypes = decs; + } + ; + + stmts returns [List stypes] scope { List statements; @@ -222,8 +252,13 @@ $stmts::statements = new ArrayList(); } : stmt+ { + debug("Matched stmts"); $stypes = $stmts::statements; } + | INDENT stmt+ DEDENT { + debug("Matched stmts"); + $stypes = $stmts::statements; + } ; stmt //combines simple_stmt and compound_stmt from Python.g @@ -304,6 +339,7 @@ pass_stmt : Pass { + debug("Matched Pass"); } ; @@ -477,7 +513,7 @@ | ^(Parens test[ctype]*) {} | ^(Dict test[ctype]*) {} | ^(Repr test[ctype]*) {} - | ^(Name NAME) {$etype = new Name($NAME, $NAME.text, ctype);} + | ^(Name NAME) {$etype = new Name($NAME, $NAME.text, ctype); debug("Matched Name");} | ^(Num INT) {$etype = makeNum($INT);} | ^(Num LONGINT) {$etype = makeNum($LONGINT);} | ^(Num FLOAT) Added: trunk/sandbox/ast/t3.py =================================================================== --- trunk/sandbox/ast/t3.py (rev 0) +++ trunk/sandbox/ast/t3.py 2007-12-08 18:10:06 UTC (rev 3776) @@ -0,0 +1,2 @@ +def hello(spam, *eggs, **foo): + pass This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-08 21:12:37
|
Revision: 3778 http://jython.svn.sourceforge.net/jython/?rev=3778&view=rev Author: fwierzbicki Date: 2007-12-08 13:12:36 -0800 (Sat, 08 Dec 2007) Log Message: ----------- tests. Added Paths: ----------- trunk/sandbox/ast/t4.py trunk/sandbox/ast/t5.py Added: trunk/sandbox/ast/t4.py =================================================================== --- trunk/sandbox/ast/t4.py (rev 0) +++ trunk/sandbox/ast/t4.py 2007-12-08 21:12:36 UTC (rev 3778) @@ -0,0 +1,2 @@ +class Hello(spam.egg, foo.bar): + pass Added: trunk/sandbox/ast/t5.py =================================================================== --- trunk/sandbox/ast/t5.py (rev 0) +++ trunk/sandbox/ast/t5.py 2007-12-08 21:12:36 UTC (rev 3778) @@ -0,0 +1,3 @@ +def egg(): + def spam(): + pass This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-09 02:51:10
|
Revision: 3781 http://jython.svn.sourceforge.net/jython/?rev=3781&view=rev Author: fwierzbicki Date: 2007-12-08 18:51:09 -0800 (Sat, 08 Dec 2007) Log Message: ----------- Fleshed out try/except/finally -- not quite matching python 2.5 ast. Modified Paths: -------------- trunk/sandbox/ast/Python.asdl trunk/sandbox/ast/grammar/PythonWalker.g trunk/sandbox/ast/jastlib.py Modified: trunk/sandbox/ast/Python.asdl =================================================================== --- trunk/sandbox/ast/Python.asdl 2007-12-09 00:16:26 UTC (rev 3780) +++ trunk/sandbox/ast/Python.asdl 2007-12-09 02:51:09 UTC (rev 3781) @@ -101,8 +101,8 @@ -- TODO(jhylton): Figure out if there is a better way to handle -- lineno and col_offset fields, particularly when -- ast is exposed to Python. - excepthandler = (expr? type, expr? name, stmt* body, int lineno, - int col_offset) + -- XXX(fwierzbicki): removed lineno and col_offset -- antlr handles this + excepthandler = (expr? type, expr? name, stmt* body) arguments = (expr* args, identifier? vararg, identifier? kwarg, expr* defaults) Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-09 00:16:26 UTC (rev 3780) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-09 02:51:09 UTC (rev 3781) @@ -14,6 +14,7 @@ import org.python.antlr.ast.aliasType; import org.python.antlr.ast.argumentsType; import org.python.antlr.ast.cmpopType; +import org.python.antlr.ast.excepthandlerType; import org.python.antlr.ast.exprType; import org.python.antlr.ast.expr_contextType; import org.python.antlr.ast.modType; @@ -30,7 +31,7 @@ import org.python.antlr.ast.Module; import org.python.antlr.ast.Name; import org.python.antlr.ast.Num; -import org.python.antlr.ast.Pass; +import org.python.antlr.ast.TryExcept; import org.python.antlr.ast.Tuple; import org.python.antlr.ast.Pass; import org.python.antlr.ast.Print; @@ -346,6 +347,7 @@ pass_stmt : Pass { debug("Matched Pass"); + $stmts::statements.add(new Pass($Pass)); } ; @@ -427,12 +429,25 @@ ; try_stmt - : ^(TryExcept ^(Body suite) except_clause+ (^(OrElse suite))? (^(FinalBody 'finally' suite))?) +@init { + List handlers = new ArrayList(); +} + : ^(TryExcept ^(Body body=stmts) except_clause[handlers]+ (^(OrElse orelse=stmts))? (^(FinalBody 'finally' fin=stmts))?) { + excepthandlerType[] e = (excepthandlerType[])handlers.toArray(new excepthandlerType[handlers.size()]); + stmtType[] b = (stmtType[])$body.stypes.toArray(new stmtType[$body.stypes.size()]); + stmtType[] o = (stmtType[])$orelse.stypes.toArray(new stmtType[$orelse.stypes.size()]); + stmtType[] f = (stmtType[])$orelse.stypes.toArray(new stmtType[$fin.stypes.size()]); + TryExcept te = new TryExcept($TryExcept, b, e, o, f); + $stmts::statements.add(te); + } | ^(TryFinally ^(Body suite) ^(FinalBody suite)) ; -except_clause - : ^(ExceptHandler (^(Type test[expr_contextType.Load]))? (^(Name test[expr_contextType.Load]))? ^(Body suite)) +except_clause[List handlers] + : ^(ExceptHandler (^(Type type=test[expr_contextType.Load]))? (^(Name name=test[expr_contextType.Load]))? ^(Body stmts)) { + stmtType[] b = (stmtType[])$stmts.stypes.toArray(new stmtType[$stmts.stypes.size()]); + handlers.add(new excepthandlerType($ExceptHandler, $type.etype, $name.etype, b)); + } ; with_stmt Modified: trunk/sandbox/ast/jastlib.py =================================================================== --- trunk/sandbox/ast/jastlib.py 2007-12-09 00:16:26 UTC (rev 3780) +++ trunk/sandbox/ast/jastlib.py 2007-12-09 02:51:09 UTC (rev 3781) @@ -29,7 +29,7 @@ if not isinstance(child, ArrayType): children = [child] else: - children = child + children = child.tolist() for node in children: if isinstance(node, (str, int)): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-09 16:50:18
|
Revision: 3783 http://jython.svn.sourceforge.net/jython/?rev=3783&view=rev Author: fwierzbicki Date: 2007-12-09 08:50:16 -0800 (Sun, 09 Dec 2007) Log Message: ----------- Some refinement of try/except, start of support of gen_for arguments. Modified Paths: -------------- trunk/sandbox/ast/fails trunk/sandbox/ast/grammar/Python.g trunk/sandbox/ast/grammar/PythonWalker.g trunk/sandbox/ast/regr Modified: trunk/sandbox/ast/fails =================================================================== --- trunk/sandbox/ast/fails 2007-12-09 03:30:38 UTC (rev 3782) +++ trunk/sandbox/ast/fails 2007-12-09 16:50:16 UTC (rev 3783) @@ -4,8 +4,6 @@ ./run /Users/frank/src/python/release25-maint/Lib/calendar.py echo /Users/frank/src/python/release25-maint/Lib/compiler/pycodegen.py ./run /Users/frank/src/python/release25-maint/Lib/compiler/pycodegen.py -echo /Users/frank/src/python/release25-maint/Lib/Cookie.py -./run /Users/frank/src/python/release25-maint/Lib/Cookie.py echo /Users/frank/src/python/release25-maint/Lib/gettext.py ./run /Users/frank/src/python/release25-maint/Lib/gettext.py echo /Users/frank/src/python/release25-maint/Lib/hmac.py @@ -36,8 +34,6 @@ ./run /Users/frank/src/python/release25-maint/Lib/plat-atheos/IN.py echo /Users/frank/src/python/release25-maint/Lib/plat-atheos/TYPES.py ./run /Users/frank/src/python/release25-maint/Lib/plat-atheos/TYPES.py -echo /Users/frank/src/python/release25-maint/Lib/plat-beos5/IN.py -./run /Users/frank/src/python/release25-maint/Lib/plat-beos5/IN.py echo /Users/frank/src/python/release25-maint/Lib/plat-darwin/IN.py ./run /Users/frank/src/python/release25-maint/Lib/plat-darwin/IN.py echo /Users/frank/src/python/release25-maint/Lib/plat-freebsd4/IN.py @@ -48,8 +44,6 @@ ./run /Users/frank/src/python/release25-maint/Lib/plat-freebsd6/IN.py echo /Users/frank/src/python/release25-maint/Lib/plat-freebsd7/IN.py ./run /Users/frank/src/python/release25-maint/Lib/plat-freebsd7/IN.py -echo /Users/frank/src/python/release25-maint/Lib/plat-irix5/FILE.py -./run /Users/frank/src/python/release25-maint/Lib/plat-irix5/FILE.py echo /Users/frank/src/python/release25-maint/Lib/plat-irix6/FILE.py ./run /Users/frank/src/python/release25-maint/Lib/plat-irix6/FILE.py echo /Users/frank/src/python/release25-maint/Lib/plat-irix6/IN.py @@ -74,8 +68,6 @@ ./run /Users/frank/src/python/release25-maint/Lib/profile.py echo /Users/frank/src/python/release25-maint/Lib/pydoc.py ./run /Users/frank/src/python/release25-maint/Lib/pydoc.py -echo /Users/frank/src/python/release25-maint/Lib/smtpd.py -./run /Users/frank/src/python/release25-maint/Lib/smtpd.py echo /Users/frank/src/python/release25-maint/Lib/sqlite3/test/factory.py ./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/factory.py echo /Users/frank/src/python/release25-maint/Lib/sqlite3/test/types.py @@ -90,18 +82,8 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/crashers/weakref_in_del.py echo /Users/frank/src/python/release25-maint/Lib/test/inspect_fodder2.py ./run /Users/frank/src/python/release25-maint/Lib/test/inspect_fodder2.py -echo /Users/frank/src/python/release25-maint/Lib/test/seq_tests.py -./run /Users/frank/src/python/release25-maint/Lib/test/seq_tests.py echo /Users/frank/src/python/release25-maint/Lib/test/test_bool.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_bool.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_builtin.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_builtin.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_calendar.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_calendar.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_codeccallbacks.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_codeccallbacks.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_codecs.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_codecs.py echo /Users/frank/src/python/release25-maint/Lib/test/test_compile.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_compile.py echo /Users/frank/src/python/release25-maint/Lib/test/test_complex.py @@ -120,32 +102,20 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_dict.py echo /Users/frank/src/python/release25-maint/Lib/test/test_doctest.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_doctest.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_exception_variations.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_exception_variations.py echo /Users/frank/src/python/release25-maint/Lib/test/test_format.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_format.py echo /Users/frank/src/python/release25-maint/Lib/test/test_grammar.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_grammar.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_import.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_import.py echo /Users/frank/src/python/release25-maint/Lib/test/test_index.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_index.py echo /Users/frank/src/python/release25-maint/Lib/test/test_itertools.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_itertools.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_mailbox.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_mailbox.py echo /Users/frank/src/python/release25-maint/Lib/test/test_multibytecodec.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_multibytecodec.py echo /Users/frank/src/python/release25-maint/Lib/test/test_multibytecodec_support.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_multibytecodec_support.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_pep352.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_pep352.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_random.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_random.py echo /Users/frank/src/python/release25-maint/Lib/test/test_scope.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_scope.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_set.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_set.py echo /Users/frank/src/python/release25-maint/Lib/test/test_socket.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_socket.py echo /Users/frank/src/python/release25-maint/Lib/test/test_struct.py Modified: trunk/sandbox/ast/grammar/Python.g =================================================================== --- trunk/sandbox/ast/grammar/Python.g 2007-12-09 03:30:38 UTC (rev 3782) +++ trunk/sandbox/ast/grammar/Python.g 2007-12-09 16:50:16 UTC (rev 3783) @@ -665,8 +665,11 @@ ; //argument: [test '='] test // Really [keyword '='] test -argument : t1=test (ASSIGN t2=test)? - -> ^(Arg $t1 ^(Default $t2)?) +argument : t1=test + ( (ASSIGN t2=test) -> ^(Arg $t1 ^(Default $t2)?) + | gen_for -> ^(GenFor $t1 gen_for) + | -> ^(Arg $t1) + ) ; //list_iter: list_for | list_if Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-09 03:30:38 UTC (rev 3782) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-09 16:50:16 UTC (rev 3783) @@ -452,7 +452,11 @@ TryExcept te = makeTryExcept($TryExcept, $body.stypes, handlers, o); $stmts::statements.add(te); } - | ^(TryFinally ^(Body suite) ^(FinalBody suite)) + | ^(TryFinally + ( ^(TryExcept ^(Body suite) except_clause[handlers]+ (^(OrElse suite))?) + | ^(Body suite) + ) + ^(FinalBody suite)) ; except_clause[List handlers] @@ -622,6 +626,7 @@ ; argument : ^(Arg test[expr_contextType.Load] (^(Default test[expr_contextType.Load]))?) + | ^(GenFor test[expr_contextType.Load] gen_for) ; list_iter: list_for Modified: trunk/sandbox/ast/regr =================================================================== --- trunk/sandbox/ast/regr 2007-12-09 03:30:38 UTC (rev 3782) +++ trunk/sandbox/ast/regr 2007-12-09 16:50:16 UTC (rev 3783) @@ -46,8 +46,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_sequence.py ./run /Users/frank/src/python/release25-maint/Lib/bsddb/test/test_thread.py echo Lib/c - -#./run /Users/frank/src/python/release25-maint/Lib/calendar.py +./run /Users/frank/src/python/release25-maint/Lib/calendar.py ./run /Users/frank/src/python/release25-maint/Lib/cgi.py ./run /Users/frank/src/python/release25-maint/Lib/CGIHTTPServer.py ./run /Users/frank/src/python/release25-maint/Lib/cgitb.py @@ -72,7 +71,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/compiler/visitor.py ./run /Users/frank/src/python/release25-maint/Lib/ConfigParser.py ./run /Users/frank/src/python/release25-maint/Lib/contextlib.py -#./run /Users/frank/src/python/release25-maint/Lib/Cookie.py +./run /Users/frank/src/python/release25-maint/Lib/Cookie.py ./run /Users/frank/src/python/release25-maint/Lib/cookielib.py ./run /Users/frank/src/python/release25-maint/Lib/copy.py ./run /Users/frank/src/python/release25-maint/Lib/copy_reg.py @@ -465,7 +464,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/logging/handlers.py ./run /Users/frank/src/python/release25-maint/Lib/macpath.py ./run /Users/frank/src/python/release25-maint/Lib/macurl2path.py -#./run /Users/frank/src/python/release25-maint/Lib/mailbox.py +./run /Users/frank/src/python/release25-maint/Lib/mailbox.py ./run /Users/frank/src/python/release25-maint/Lib/mailcap.py ./run /Users/frank/src/python/release25-maint/Lib/markupbase.py ./run /Users/frank/src/python/release25-maint/Lib/md5.py @@ -756,7 +755,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/SimpleHTTPServer.py ./run /Users/frank/src/python/release25-maint/Lib/SimpleXMLRPCServer.py ./run /Users/frank/src/python/release25-maint/Lib/site.py -#./run /Users/frank/src/python/release25-maint/Lib/smtpd.py +./run /Users/frank/src/python/release25-maint/Lib/smtpd.py ./run /Users/frank/src/python/release25-maint/Lib/smtplib.py ./run /Users/frank/src/python/release25-maint/Lib/sndhdr.py ./run /Users/frank/src/python/release25-maint/Lib/socket.py @@ -843,7 +842,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/regrtest.py ./run /Users/frank/src/python/release25-maint/Lib/test/reperf.py ./run /Users/frank/src/python/release25-maint/Lib/test/sample_doctest.py -#./run /Users/frank/src/python/release25-maint/Lib/test/seq_tests.py +./run /Users/frank/src/python/release25-maint/Lib/test/seq_tests.py ./run /Users/frank/src/python/release25-maint/Lib/test/sortperf.py ./run /Users/frank/src/python/release25-maint/Lib/test/string_tests.py echo Lib/test/t @@ -873,9 +872,9 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_bsddb185.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_bsddb3.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_bufio.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_builtin.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_builtin.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_bz2.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_calendar.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_calendar.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_call.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_capi.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_cd.py @@ -887,7 +886,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_cmath.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_cmd_line.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_code.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_codeccallbacks.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_codeccallbacks.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_codecencodings_cn.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_codecencodings_hk.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_codecencodings_jp.py @@ -898,7 +897,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_codecmaps_jp.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_codecmaps_kr.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_codecmaps_tw.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_codecs.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_codecs.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_codeop.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_coding.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_coercion.py @@ -946,7 +945,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_enumerate.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_eof.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_errno.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_exception_variations.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_exception_variations.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_exceptions.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_extcall.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_fcntl.py @@ -992,7 +991,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_imaplib.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_imgfile.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_imp.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_import.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_import.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_importhooks.py #./run /Users/frank/src/python/release25-maint/Lib/test/test_index.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_inspect.py @@ -1046,7 +1045,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_pep263.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_pep277.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_pep292.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_pep352.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_pep352.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_pickle.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_pickletools.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_pkg.py @@ -1068,7 +1067,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_pyexpat.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_queue.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_quopri.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_random.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_random.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_re.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_repr.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_resource.py @@ -1081,7 +1080,7 @@ #./run /Users/frank/src/python/release25-maint/Lib/test/test_scope.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_scriptpackages.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_select.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_set.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_set.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_sets.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_sgmllib.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_sha.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2007-12-10 12:10:53
|
Revision: 3789 http://jython.svn.sourceforge.net/jython/?rev=3789&view=rev Author: otmarhumbel Date: 2007-12-10 04:10:46 -0800 (Mon, 10 Dec 2007) Log Message: ----------- added a JUnit regression test suite, for full IDE support like debug, rerun and the like Added Paths: ----------- trunk/sandbox/ast/test/ trunk/sandbox/ast/test/org/ trunk/sandbox/ast/test/org/python/ trunk/sandbox/ast/test/org/python/antlr/ trunk/sandbox/ast/test/org/python/antlr/PythonTreeWalkerTestCase.java trunk/sandbox/ast/test/org/python/antlr/RegressionTestSuite.java Added: trunk/sandbox/ast/test/org/python/antlr/PythonTreeWalkerTestCase.java =================================================================== --- trunk/sandbox/ast/test/org/python/antlr/PythonTreeWalkerTestCase.java (rev 0) +++ trunk/sandbox/ast/test/org/python/antlr/PythonTreeWalkerTestCase.java 2007-12-10 12:10:46 UTC (rev 3789) @@ -0,0 +1,59 @@ +package org.python.antlr; + +import java.io.File; + +import junit.framework.TestCase; + +/** + * Decorates the PythonTreeWalker class as a JUnit test case for a single .py + * file + */ +public class PythonTreeWalkerTestCase extends TestCase { + + private String _path; + + /** + * Constructor called from rerun menu point in eclipse + * + * @param name The name of the test. + */ + public PythonTreeWalkerTestCase(String name) { + super(name); + setPath(name); + } + + /** + * Create a test case which walks <code>pyFile</code>. + * + * @param pyFile The *.py file + */ + public PythonTreeWalkerTestCase(File pyFile) { + this(pyFile.getAbsolutePath()); + } + + @Override + protected void runTest() throws Throwable { + String path = getPath(); + File file = new File(path); + assertTrue("file " + path + " not found", file.exists()); + PythonTreeWalker treeWalker = new PythonTreeWalker(); + treeWalker.setTolerant(false); + treeWalker.setParseOnly(false); + PythonTree tree = treeWalker.parse(new String[] { path }); + assertNotNull("no tree generated for file ".concat(path), tree); + } + + @Override + public int countTestCases() { + return 1; + } + + private void setPath(String path) { + _path = path; + } + + private String getPath() { + return _path; + } + +} Added: trunk/sandbox/ast/test/org/python/antlr/RegressionTestSuite.java =================================================================== --- trunk/sandbox/ast/test/org/python/antlr/RegressionTestSuite.java (rev 0) +++ trunk/sandbox/ast/test/org/python/antlr/RegressionTestSuite.java 2007-12-10 12:10:46 UTC (rev 3789) @@ -0,0 +1,98 @@ +package org.python.antlr; + +import java.io.File; +import java.io.FilenameFilter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; + +import junit.framework.Assert; +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * A regression test suite traversing all *.py files, parsing and walking them + * <p> + * The root directory of the *.py files is read from a System property + * <code>base.dir</code>. If this property is not set, we use the current + * directory where the runner is started. + * <p> + * Example: call the runner with + * + * <pre> + * -Dbase.dir=/your/dir/containing/py/files + * </pre> + */ +public class RegressionTestSuite extends TestSuite { + private static final String BASEDIR_PROPERTY = "base.dir"; + + /** + * Method called by a JUnit test runner + * + * @return the test suite containing all the tests + * + * @throws Exception + */ + public static Test suite() throws Exception { + String baseDirName = System.getProperty(BASEDIR_PROPERTY, System.getProperty("user.dir", null)); + Assert.assertNotNull("unable to determine root directory. Try specifying property " + BASEDIR_PROPERTY, + baseDirName); + File baseDir = new File(baseDirName); + Assert.assertTrue(baseDirName + " does not exist", baseDir.exists()); + Assert.assertTrue(baseDirName + " is not a directory", baseDir.isDirectory()); + TestSuite suite = new TestSuite("Regression test " + baseDirName + " recursive."); + buildSuite(baseDir, new PyFileFilter(), suite); + return suite; + } + + private static void buildSuite(File currentDir, FilenameFilter filter, TestSuite currentSuite) throws Exception { + List<File> potentialDirectories = Arrays.asList(currentDir.listFiles(filter)); + if (potentialDirectories.size() == 0) { + return; + } + + List<File> pyFiles = new ArrayList<File>(potentialDirectories.size()); + Collections.sort(potentialDirectories, new FileComparator()); + Iterator<File> directoryIterator = potentialDirectories.iterator(); + while (directoryIterator.hasNext()) { + File potentialDirectory = directoryIterator.next(); + if (potentialDirectory.isDirectory()) { + TestSuite subTestSuite = new TestSuite(potentialDirectory.getName()); + buildSuite(potentialDirectory, filter, subTestSuite); + // only if suite contains tests + if (subTestSuite.countTestCases() > 0) { + currentSuite.addTest(subTestSuite); + } + } else { + pyFiles.add(potentialDirectory); + } + } + Iterator<File> fileIterator = pyFiles.iterator(); + while (fileIterator.hasNext()) { + currentSuite.addTest(new PythonTreeWalkerTestCase(fileIterator.next())); + } + } + + private static class PyFileFilter implements FilenameFilter { + public boolean accept(File dir, String name) { + if (name.endsWith(".py")) { + return true; + } else { + if (name.equals(".svn")) { + return false; + } + } + return new File(dir, name).isDirectory(); + } + } + + private static class FileComparator implements Comparator<File> { + public int compare(File f1, File f2) { + return f1.getAbsolutePath().compareTo(f2.getAbsolutePath()); + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-10 14:31:18
|
Revision: 3790 http://jython.svn.sourceforge.net/jython/?rev=3790&view=rev Author: fwierzbicki Date: 2007-12-10 06:31:07 -0800 (Mon, 10 Dec 2007) Log Message: ----------- match simple lambdas. Modified Paths: -------------- trunk/sandbox/ast/fails trunk/sandbox/ast/grammar/Python.g trunk/sandbox/ast/regr Modified: trunk/sandbox/ast/fails =================================================================== --- trunk/sandbox/ast/fails 2007-12-10 12:10:46 UTC (rev 3789) +++ trunk/sandbox/ast/fails 2007-12-10 14:31:07 UTC (rev 3790) @@ -1,35 +1,15 @@ echo /Users/frank/src/python/release25-maint/Lib/_strptime.py ./run /Users/frank/src/python/release25-maint/Lib/_strptime.py -echo /Users/frank/src/python/release25-maint/Lib/calendar.py -./run /Users/frank/src/python/release25-maint/Lib/calendar.py echo /Users/frank/src/python/release25-maint/Lib/compiler/pycodegen.py ./run /Users/frank/src/python/release25-maint/Lib/compiler/pycodegen.py -echo /Users/frank/src/python/release25-maint/Lib/gettext.py -./run /Users/frank/src/python/release25-maint/Lib/gettext.py -echo /Users/frank/src/python/release25-maint/Lib/hmac.py -./run /Users/frank/src/python/release25-maint/Lib/hmac.py -echo /Users/frank/src/python/release25-maint/Lib/idlelib/CallTips.py -./run /Users/frank/src/python/release25-maint/Lib/idlelib/CallTips.py echo /Users/frank/src/python/release25-maint/Lib/idlelib/CodeContext.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/CodeContext.py echo /Users/frank/src/python/release25-maint/Lib/idlelib/FormatParagraph.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/FormatParagraph.py -echo /Users/frank/src/python/release25-maint/Lib/idlelib/MultiCall.py -./run /Users/frank/src/python/release25-maint/Lib/idlelib/MultiCall.py echo /Users/frank/src/python/release25-maint/Lib/idlelib/PyParse.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/PyParse.py -echo /Users/frank/src/python/release25-maint/Lib/idlelib/testcode.py -./run /Users/frank/src/python/release25-maint/Lib/idlelib/testcode.py -echo /Users/frank/src/python/release25-maint/Lib/logging/__init__.py -./run /Users/frank/src/python/release25-maint/Lib/logging/__init__.py -echo /Users/frank/src/python/release25-maint/Lib/mailbox.py -./run /Users/frank/src/python/release25-maint/Lib/mailbox.py echo /Users/frank/src/python/release25-maint/Lib/msilib/schema.py ./run /Users/frank/src/python/release25-maint/Lib/msilib/schema.py -echo /Users/frank/src/python/release25-maint/Lib/pickletools.py -./run /Users/frank/src/python/release25-maint/Lib/pickletools.py -echo /Users/frank/src/python/release25-maint/Lib/pkgutil.py -./run /Users/frank/src/python/release25-maint/Lib/pkgutil.py echo /Users/frank/src/python/release25-maint/Lib/plat-atheos/IN.py ./run /Users/frank/src/python/release25-maint/Lib/plat-atheos/IN.py echo /Users/frank/src/python/release25-maint/Lib/plat-atheos/TYPES.py @@ -64,71 +44,31 @@ ./run /Users/frank/src/python/release25-maint/Lib/plat-sunos5/TYPES.py echo /Users/frank/src/python/release25-maint/Lib/plat-unixware7/IN.py ./run /Users/frank/src/python/release25-maint/Lib/plat-unixware7/IN.py -echo /Users/frank/src/python/release25-maint/Lib/profile.py -./run /Users/frank/src/python/release25-maint/Lib/profile.py echo /Users/frank/src/python/release25-maint/Lib/pydoc.py ./run /Users/frank/src/python/release25-maint/Lib/pydoc.py -echo /Users/frank/src/python/release25-maint/Lib/sqlite3/test/factory.py -./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/factory.py echo /Users/frank/src/python/release25-maint/Lib/sqlite3/test/types.py ./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/types.py echo /Users/frank/src/python/release25-maint/Lib/tarfile.py ./run /Users/frank/src/python/release25-maint/Lib/tarfile.py echo /Users/frank/src/python/release25-maint/Lib/test/bad_coding2.py ./run /Users/frank/src/python/release25-maint/Lib/test/bad_coding2.py -echo /Users/frank/src/python/release25-maint/Lib/test/crashers/recursive_call.py -./run /Users/frank/src/python/release25-maint/Lib/test/crashers/recursive_call.py echo /Users/frank/src/python/release25-maint/Lib/test/crashers/weakref_in_del.py ./run /Users/frank/src/python/release25-maint/Lib/test/crashers/weakref_in_del.py -echo /Users/frank/src/python/release25-maint/Lib/test/inspect_fodder2.py -./run /Users/frank/src/python/release25-maint/Lib/test/inspect_fodder2.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_bool.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_bool.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_compile.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_compile.py echo /Users/frank/src/python/release25-maint/Lib/test/test_complex.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_complex.py echo /Users/frank/src/python/release25-maint/Lib/test/test_complex_args.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_complex_args.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_copy.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_copy.py echo /Users/frank/src/python/release25-maint/Lib/test/test_decimal.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_decimal.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_decorators.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_decorators.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_descr.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_descr.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_dict.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_dict.py echo /Users/frank/src/python/release25-maint/Lib/test/test_doctest.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_doctest.py echo /Users/frank/src/python/release25-maint/Lib/test/test_format.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_format.py echo /Users/frank/src/python/release25-maint/Lib/test/test_grammar.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_grammar.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_index.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_index.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_itertools.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_itertools.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_multibytecodec.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_multibytecodec.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_multibytecodec_support.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_multibytecodec_support.py +echo /users/frank/src/python/release25-maint/lib/test/test_mailbox.py +./run /users/frank/src/python/release25-maint/lib/test/test_mailbox.py echo /Users/frank/src/python/release25-maint/Lib/test/test_scope.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_scope.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_socket.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_socket.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_struct.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_struct.py echo /Users/frank/src/python/release25-maint/Lib/test/test_thread.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_thread.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_userdict.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_userdict.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_uuid.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_uuid.py -echo /Users/frank/src/python/release25-maint/Lib/test/test_weakref.py -./run /Users/frank/src/python/release25-maint/Lib/test/test_weakref.py -echo /Users/frank/src/python/release25-maint/Lib/urllib.py -./run /Users/frank/src/python/release25-maint/Lib/urllib.py -echo /Users/frank/src/python/release25-maint/Lib/urllib2.py -./run /Users/frank/src/python/release25-maint/Lib/urllib2.py Modified: trunk/sandbox/ast/grammar/Python.g =================================================================== --- trunk/sandbox/ast/grammar/Python.g 2007-12-10 12:10:46 UTC (rev 3789) +++ trunk/sandbox/ast/grammar/Python.g 2007-12-10 14:31:07 UTC (rev 3790) @@ -175,6 +175,17 @@ import org.python.antlr.PythonTree; } +@members { + boolean debugOn = false; + + private void debug(String message) { + if (debugOn) { + System.out.println(message); + } + } +} + + @lexer::header { package org.python.antlr; } @@ -196,7 +207,7 @@ ; //file_input: (NEWLINE | stmt)* ENDMARKER -file_input : (NEWLINE | stmt)* +file_input : (NEWLINE | stmt)* {debug("parsed file_input");} -> ^(Module stmt*) ; @@ -484,12 +495,12 @@ //FIXME: looks like this one is going to be tough. //test: or_test ['if' or_test 'else' test] | lambdef test: or_test //('if' test 'else' test)? - | lambdef + | lambdef {debug("parsed lambdef");} ; //or_test: and_test ('or' and_test)* or_test : and_test ('or'^ and_test)* - ; + ; //and_test: not_test ('and' not_test)* and_test : not_test ('and'^ not_test)* @@ -577,7 +588,7 @@ | LBRACK (listmaker)? RBRACK -> ^(List listmaker?) | LCURLY (dictmaker)? RCURLY -> ^(Dict dictmaker?) | BACKQUOTE testlist BACKQUOTE -> ^(Repr testlist) - | NAME -> ^(Name NAME) + | NAME {debug("parsed NAME");} -> ^(Name NAME) | INT -> ^(Num INT) | LONGINT -> ^(Num LONGINT) | FLOAT -> ^(Num FLOAT) @@ -599,10 +610,11 @@ (COMMA)? ; - +//FIXME: switched to or_test for now which allows simple lambdas to work - but +// this prevents nested lambdas. see test_scope.py for examples that fail. //lambdef: 'lambda' [varargslist] ':' test -lambdef: 'lambda' (varargslist)? COLON test - -> ^(Lambda varargslist? ^(Body test)) +lambdef: 'lambda' (varargslist)? COLON or_test {debug("parsed lambda");} + -> ^(Lambda varargslist? ^(Body or_test)) ; //trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME Modified: trunk/sandbox/ast/regr =================================================================== --- trunk/sandbox/ast/regr 2007-12-10 12:10:46 UTC (rev 3789) +++ trunk/sandbox/ast/regr 2007-12-10 14:31:07 UTC (rev 3790) @@ -360,13 +360,13 @@ ./run /Users/frank/src/python/release25-maint/Lib/functools.py ./run /Users/frank/src/python/release25-maint/Lib/getopt.py ./run /Users/frank/src/python/release25-maint/Lib/getpass.py -#./run /Users/frank/src/python/release25-maint/Lib/gettext.py +./run /Users/frank/src/python/release25-maint/Lib/gettext.py ./run /Users/frank/src/python/release25-maint/Lib/glob.py ./run /Users/frank/src/python/release25-maint/Lib/gopherlib.py ./run /Users/frank/src/python/release25-maint/Lib/gzip.py ./run /Users/frank/src/python/release25-maint/Lib/hashlib.py ./run /Users/frank/src/python/release25-maint/Lib/heapq.py -#./run /Users/frank/src/python/release25-maint/Lib/hmac.py +./run /Users/frank/src/python/release25-maint/Lib/hmac.py ./run /Users/frank/src/python/release25-maint/Lib/hotshot/__init__.py ./run /Users/frank/src/python/release25-maint/Lib/hotshot/log.py ./run /Users/frank/src/python/release25-maint/Lib/hotshot/stats.py @@ -381,7 +381,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/idlelib/AutoCompleteWindow.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/AutoExpand.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/Bindings.py -#./run /Users/frank/src/python/release25-maint/Lib/idlelib/CallTips.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/CallTips.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/CallTipWindow.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/ClassBrowser.py #./run /Users/frank/src/python/release25-maint/Lib/idlelib/CodeContext.py @@ -404,7 +404,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/idlelib/IOBinding.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/keybindingDialog.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/macosxSupport.py -#./run /Users/frank/src/python/release25-maint/Lib/idlelib/MultiCall.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/MultiCall.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/MultiStatusBar.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/ObjectBrowser.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/OutputWindow.py @@ -425,7 +425,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/idlelib/SearchEngine.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/StackViewer.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/tabpage.py -#./run /Users/frank/src/python/release25-maint/Lib/idlelib/testcode.py +./run /Users/frank/src/python/release25-maint/Lib/idlelib/testcode.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/textView.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/ToolTip.py ./run /Users/frank/src/python/release25-maint/Lib/idlelib/TreeWidget.py @@ -459,7 +459,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/lib-tk/turtle.py ./run /Users/frank/src/python/release25-maint/Lib/linecache.py ./run /Users/frank/src/python/release25-maint/Lib/locale.py -#./run /Users/frank/src/python/release25-maint/Lib/logging/__init__.py +./run /Users/frank/src/python/release25-maint/Lib/logging/__init__.py ./run /Users/frank/src/python/release25-maint/Lib/logging/config.py ./run /Users/frank/src/python/release25-maint/Lib/logging/handlers.py ./run /Users/frank/src/python/release25-maint/Lib/macpath.py @@ -492,9 +492,9 @@ ./run /Users/frank/src/python/release25-maint/Lib/os2emxpath.py ./run /Users/frank/src/python/release25-maint/Lib/pdb.py ./run /Users/frank/src/python/release25-maint/Lib/pickle.py -#./run /Users/frank/src/python/release25-maint/Lib/pickletools.py +./run /Users/frank/src/python/release25-maint/Lib/pickletools.py ./run /Users/frank/src/python/release25-maint/Lib/pipes.py -#./run /Users/frank/src/python/release25-maint/Lib/pkgutil.py +./run /Users/frank/src/python/release25-maint/Lib/pkgutil.py ./run /Users/frank/src/python/release25-maint/Lib/plat-aix3/IN.py ./run /Users/frank/src/python/release25-maint/Lib/plat-aix4/IN.py #./run /Users/frank/src/python/release25-maint/Lib/plat-atheos/IN.py @@ -729,7 +729,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/posixfile.py ./run /Users/frank/src/python/release25-maint/Lib/posixpath.py ./run /Users/frank/src/python/release25-maint/Lib/pprint.py -#./run /Users/frank/src/python/release25-maint/Lib/profile.py +./run /Users/frank/src/python/release25-maint/Lib/profile.py ./run /Users/frank/src/python/release25-maint/Lib/pstats.py ./run /Users/frank/src/python/release25-maint/Lib/pty.py ./run /Users/frank/src/python/release25-maint/Lib/py_compile.py @@ -764,7 +764,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/sqlite3/dbapi2.py ./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/__init__.py ./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/dbapi.py -#./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/factory.py +./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/factory.py ./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/hooks.py ./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/regression.py ./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/transactions.py @@ -817,7 +817,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/crashers/modify_dict_attr.py ./run /Users/frank/src/python/release25-maint/Lib/test/crashers/nasty_eq_vs_dict.py ./run /Users/frank/src/python/release25-maint/Lib/test/crashers/recursion_limit_too_high.py -#./run /Users/frank/src/python/release25-maint/Lib/test/crashers/recursive_call.py +./run /Users/frank/src/python/release25-maint/Lib/test/crashers/recursive_call.py #./run /Users/frank/src/python/release25-maint/Lib/test/crashers/weakref_in_del.py ./run /Users/frank/src/python/release25-maint/Lib/test/doctest_aliases.py ./run /Users/frank/src/python/release25-maint/Lib/test/double_const.py @@ -825,7 +825,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/fork_wait.py ./run /Users/frank/src/python/release25-maint/Lib/test/infinite_reload.py ./run /Users/frank/src/python/release25-maint/Lib/test/inspect_fodder.py -#./run /Users/frank/src/python/release25-maint/Lib/test/inspect_fodder2.py +./run /Users/frank/src/python/release25-maint/Lib/test/inspect_fodder2.py ./run /Users/frank/src/python/release25-maint/Lib/test/leakers/__init__.py ./run /Users/frank/src/python/release25-maint/Lib/test/leakers/test_ctypes.py ./run /Users/frank/src/python/release25-maint/Lib/test/leakers/test_gestalt.py @@ -867,7 +867,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_binhex.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_binop.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_bisect.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_bool.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_bool.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_bsddb.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_bsddb185.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_bsddb3.py @@ -904,7 +904,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_colorsys.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_commands.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_compare.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_compile.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_compile.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_compiler.py #./run /Users/frank/src/python/release25-maint/Lib/test/test_complex.py #./run /Users/frank/src/python/release25-maint/Lib/test/test_complex_args.py @@ -912,7 +912,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_contextlib.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_cookie.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_cookielib.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_copy.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_copy.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_copy_reg.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_cpickle.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_cProfile.py @@ -923,12 +923,12 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_datetime.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_dbm.py #./run /Users/frank/src/python/release25-maint/Lib/test/test_decimal.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_decorators.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_decorators.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_defaultdict.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_deque.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_descr.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_descr.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_descrtut.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_dict.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_dict.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_difflib.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_dircache.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_dis.py @@ -993,13 +993,13 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_imp.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_import.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_importhooks.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_index.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_index.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_inspect.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_ioctl.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_isinstance.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_iter.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_iterlen.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_itertools.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_itertools.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_largefile.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_linuxaudiodev.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_list.py @@ -1022,8 +1022,8 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_minidom.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_mmap.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_module.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_multibytecodec.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_multibytecodec_support.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_multibytecodec.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_multibytecodec_support.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_multifile.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_mutants.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_netrc.py @@ -1090,7 +1090,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_signal.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_site.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_slice.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_socket.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_socket.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_socket_ssl.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_socketserver.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_softspace.py @@ -1118,7 +1118,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_tcl.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_tempfile.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_textwrap.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_thread.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_thread.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_threaded_import.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_threadedtempfile.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_threading.py @@ -1146,16 +1146,16 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_urllib2net.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_urllibnet.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_urlparse.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_userdict.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_userdict.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_userlist.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_userstring.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_uu.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_uuid.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_uuid.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_wait3.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_wait4.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_warnings.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_wave.py -#./run /Users/frank/src/python/release25-maint/Lib/test/test_weakref.py +./run /Users/frank/src/python/release25-maint/Lib/test/test_weakref.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_whichdb.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_winreg.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_winsound.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-11 02:24:20
|
Revision: 3793 http://jython.svn.sourceforge.net/jython/?rev=3793&view=rev Author: fwierzbicki Date: 2007-12-10 18:24:19 -0800 (Mon, 10 Dec 2007) Log Message: ----------- try/except/finally support pretty good now. Modified Paths: -------------- trunk/sandbox/ast/grammar/PythonWalker.g Added Paths: ----------- trunk/sandbox/ast/t6.py Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-11 00:34:00 UTC (rev 3792) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-11 02:24:19 UTC (rev 3793) @@ -32,6 +32,7 @@ import org.python.antlr.ast.Name; import org.python.antlr.ast.Num; import org.python.antlr.ast.TryExcept; +import org.python.antlr.ast.TryFinally; import org.python.antlr.ast.Tuple; import org.python.antlr.ast.Pass; import org.python.antlr.ast.Print; @@ -197,17 +198,30 @@ return new Num(t, new Long(l)); } - private TryExcept makeTryExcept(PythonTree t, List body, List handlers, List orelses) { + private stmtType makeTryExcept(PythonTree t, List body, List handlers, List orelses, List finBody) { + stmtType[] b = (stmtType[])body.toArray(new stmtType[body.size()]); excepthandlerType[] e = (excepthandlerType[])handlers.toArray(new excepthandlerType[handlers.size()]); - stmtType[] b = (stmtType[])body.toArray(new stmtType[body.size()]); stmtType[] o; if (orelses != null) { o = (stmtType[])orelses.toArray(new stmtType[orelses.size()]); } else { o = new stmtType[0]; } - return new TryExcept(t, b, e, o); + + stmtType te = new TryExcept(t, b, e, o); + if (finBody == null) { + return te; + } + stmtType[] f = (stmtType[])finBody.toArray(new stmtType[finBody.size()]); + stmtType[] mainBody = new stmtType[]{te}; + return new TryFinally(t, mainBody, f); } + + private TryFinally makeTryFinally(PythonTree t, List body, List finBody) { + stmtType[] b = (stmtType[])body.toArray(new stmtType[body.size()]); + stmtType[] f = (stmtType[])finBody.toArray(new stmtType[finBody.size()]); + return new TryFinally(t, b, f); + } } module returns [modType mod] @@ -446,17 +460,20 @@ } : ^(TryExcept ^(Body body=stmts) except_clause[handlers]+ (^(OrElse orelse=stmts))? (^(FinalBody 'finally' fin=stmts))?) { List o = null; + List f = null; if ($OrElse != null) { o = $orelse.stypes; } - TryExcept te = makeTryExcept($TryExcept, $body.stypes, handlers, o); + if ($FinalBody != null) { + f = $fin.stypes; + } + stmtType te = makeTryExcept($TryExcept, $body.stypes, handlers, o, f); $stmts::statements.add(te); } - | ^(TryFinally - ( ^(TryExcept ^(Body suite) except_clause[handlers]+ (^(OrElse suite))?) - | ^(Body suite) - ) - ^(FinalBody suite)) + | ^(TryFinally ^(Body body=stmts) ^(FinalBody fin=stmts)) { + TryFinally tf = makeTryFinally($TryFinally, $body.stypes, $fin.stypes); + $stmts::statements.add(tf); + } ; except_clause[List handlers] Added: trunk/sandbox/ast/t6.py =================================================================== --- trunk/sandbox/ast/t6.py (rev 0) +++ trunk/sandbox/ast/t6.py 2007-12-11 02:24:19 UTC (rev 3793) @@ -0,0 +1,8 @@ +try: + pass +except name: + pass +else: + pass +finally: + pass This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-12 00:44:03
|
Revision: 3796 http://jython.svn.sourceforge.net/jython/?rev=3796&view=rev Author: fwierzbicki Date: 2007-12-11 16:43:57 -0800 (Tue, 11 Dec 2007) Log Message: ----------- Decorators work pretty well except for starargs and kwargs. Modified Paths: -------------- trunk/sandbox/ast/fails trunk/sandbox/ast/grammar/Python.g trunk/sandbox/ast/grammar/PythonWalker.g trunk/sandbox/ast/regr Modified: trunk/sandbox/ast/fails =================================================================== --- trunk/sandbox/ast/fails 2007-12-11 22:23:45 UTC (rev 3795) +++ trunk/sandbox/ast/fails 2007-12-12 00:43:57 UTC (rev 3796) @@ -51,8 +51,6 @@ echo /Users/frank/src/python/release25-maint/Lib/pydoc.py ./run /Users/frank/src/python/release25-maint/Lib/pydoc.py -echo /Users/frank/src/python/release25-maint/Lib/sqlite3/test/types.py -./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/types.py echo /Users/frank/src/python/release25-maint/Lib/tarfile.py ./run /Users/frank/src/python/release25-maint/Lib/tarfile.py echo /Users/frank/src/python/release25-maint/Lib/test/bad_coding2.py Modified: trunk/sandbox/ast/grammar/Python.g =================================================================== --- trunk/sandbox/ast/grammar/Python.g 2007-12-11 22:23:45 UTC (rev 3795) +++ trunk/sandbox/ast/grammar/Python.g 2007-12-12 00:43:57 UTC (rev 3796) @@ -91,6 +91,7 @@ Arguments; Args; Arg; + Keyword; StarArgs; KWArgs; Assign; @@ -161,6 +162,7 @@ Ifs; Elts; Ctx; + Attr; //The tokens below are not represented in the 2.5 Python.asdl GenFor; GenIf; @@ -215,15 +217,19 @@ eval_input : (NEWLINE!)* testlist (NEWLINE!)* ; -//decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE -decorator: AT dotted_name (LPAREN arglist? RPAREN)? NEWLINE - -> ^(Decorator dotted_name ^(ArgList arglist?)) - ; - //decorators: decorator+ decorators: decorator+ ; +//decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE +decorator: AT dotted_attr (LPAREN arglist? RPAREN)? NEWLINE + -> ^(Decorator dotted_attr ^(ArgList arglist)?) + ; + +dotted_attr + : NAME (DOT^ NAME)* + ; + //funcdef: [decorators] 'def' NAME parameters ':' suite funcdef : decorators? 'def' NAME parameters COLON suite -> ^(FunctionDef ^(Name NAME) ^(Arguments parameters) ^(Body suite) ^(Decorators decorators?)) @@ -669,7 +675,7 @@ | DOUBLESTAR kwargs=test )? )? - -> ^(Arguments argument+) ^(StarArgs $starargs)? ^(KWArgs $kwargs)? + -> ^(Args argument+) ^(StarArgs $starargs)? ^(KWArgs $kwargs)? | STAR starargs=test (COMMA DOUBLESTAR kwargs=test)? -> ^(StarArgs $starargs) ^(KWArgs $kwargs)? | DOUBLESTAR kwargs=test @@ -678,7 +684,7 @@ //argument: [test '='] test // Really [keyword '='] test argument : t1=test - ( (ASSIGN t2=test) -> ^(Arg $t1 ^(Default $t2)?) + ( (ASSIGN t2=test) -> ^(Keyword ^(Arg $t1) ^(Value $t2)?) | gen_for -> ^(GenFor $t1 gen_for) | -> ^(Arg $t1) ) @@ -706,7 +712,7 @@ //gen_for: 'for' exprlist 'in' or_test [gen_iter] gen_for: 'for' exprlist 'in' or_test gen_iter? - -> ^(GenFor ^(Target exprlist) ^(Iter gen_iter)?) + -> ^(GenFor ^(Target exprlist) ^(Iter gen_iter)?) ; //gen_if: 'if' old_test [gen_iter] Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-11 22:23:45 UTC (rev 3795) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-12 00:43:57 UTC (rev 3796) @@ -17,11 +17,14 @@ import org.python.antlr.ast.excepthandlerType; import org.python.antlr.ast.exprType; import org.python.antlr.ast.expr_contextType; +import org.python.antlr.ast.keywordType; import org.python.antlr.ast.modType; import org.python.antlr.ast.operatorType; import org.python.antlr.ast.stmtType; import org.python.antlr.ast.Assign; +import org.python.antlr.ast.Attribute; import org.python.antlr.ast.AugAssign; +import org.python.antlr.ast.Call; import org.python.antlr.ast.ClassDef; import org.python.antlr.ast.Compare; import org.python.antlr.ast.Dict; @@ -244,7 +247,7 @@ List defaults = new ArrayList(); } : ^(Args defparameter[params, defaults]+) (^(StarArgs sname=NAME))? (^(KWArgs kname=NAME))? { - $args = makeArgumentsType($Args,params, $sname, $kname, defaults); + $args = makeArgumentsType($Args, params, $sname, $kname, defaults); } | ^(StarArgs sname=NAME) (^(KWArgs kname=NAME))? { $args = makeArgumentsType($StarArgs,params, $sname, $kname, defaults); @@ -257,26 +260,43 @@ defparameter[List params, List defaults] : NAME (ASSIGN test[expr_contextType.Load] )? { params.add(new Name($NAME, $NAME.text, org.python.antlr.ast.Name.Param)); - if ($test.etype != null) { + if ($ASSIGN != null) { defaults.add($test.etype); } } ; -decorator - : ^(Decorator dotted_name ^(ArgList arglist?)) - ; - decorators returns [List etypes] @init { List decs = new ArrayList(); } - : decorator+ { + : decorator[decs]+ { $etypes = decs; } ; +decorator [List decs] + : ^(Decorator dotted_attr (^(ArgList arglist))?) { + if ($ArgList == null) { + debug("not call site!"); + decs.add($dotted_attr.etype); + } else { + exprType[] args = (exprType[])$arglist.args.toArray(new exprType[$arglist.args.size()]); + keywordType[] keywords = (keywordType[])$arglist.keywords.toArray(new keywordType[$arglist.keywords.size()]); + Call c = new Call($ArgList, $dotted_attr.etype, args, keywords, $arglist.starargs, $arglist.kwargs); + debug("call site!"); + decs.add(c); + } + } + ; +dotted_attr returns [exprType etype] + : NAME {$etype = new Name($NAME, $NAME.text, expr_contextType.Load); debug("Matched Name");} + | ^(DOT n1=dotted_attr n2=dotted_attr) { + $etype = new Attribute($DOT, $n1.etype, $n2.text, expr_contextType.Load); + } + ; + stmts returns [List stypes] scope { List statements; @@ -421,8 +441,7 @@ ; dotted_name - : start=NAME (DOT NAME)* { - } + : start=NAME (DOT NAME)* ; global_stmt @@ -482,7 +501,16 @@ if ($stmts.start != null) { b = (stmtType[])$stmts.stypes.toArray(new stmtType[$stmts.stypes.size()]); } else b = new stmtType[0]; - handlers.add(new excepthandlerType($ExceptHandler, $type.etype, $name.etype, b)); + exprType t = null; + if ($Type != null) { + t = $type.etype; + } + exprType n = null; + if ($Name != null) { + n = $name.etype; + } + //handlers.add(new excepthandlerType($ExceptHandler, $type.etype, $name.etype, b)); + handlers.add(new excepthandlerType($ExceptHandler, t, n, b)); } ; @@ -604,7 +632,8 @@ ; trailer - : ^(ArgList arglist?) + : ^(ArgList arglist?) { + } | ^(SubscriptList subscriptlist) | DOT NAME ; @@ -636,16 +665,38 @@ : test[expr_contextType.Store] {names.add($test.etype);} ; -arglist - : ^(Arguments argument+) (^(StarArgs test[expr_contextType.Load]))? (^(KWArgs test[expr_contextType.Load]))? - | ^(StarArgs test[expr_contextType.Load]) (^(KWArgs test[expr_contextType.Load]))? - | ^(KWArgs test[expr_contextType.Load]) +arglist returns [List args, List keywords, exprType starargs, exprType kwargs] +@init { + List arguments = new ArrayList(); + List kws = new ArrayList(); +} + : ^(Args argument[arguments]* keyword[kws]*) (^(StarArgs stest=test[expr_contextType.Load]))? (^(KWArgs ktest=test[expr_contextType.Load]))? { + $args=arguments; + $keywords=kws; + //$starargs=stest.etype; + //$kwargs=ktest.etype; + } + | ^(StarArgs test[expr_contextType.Load]) (^(KWArgs test[expr_contextType.Load]))? { + $args=arguments; + $keywords=kws; + } + | ^(KWArgs test[expr_contextType.Load]) { + $args=arguments; + $keywords=kws; + } ; -argument : ^(Arg test[expr_contextType.Load] (^(Default test[expr_contextType.Load]))?) - | ^(GenFor test[expr_contextType.Load] gen_for) - ; +argument[List arguments] + : ^(Arg test[expr_contextType.Load] (^(Default test[expr_contextType.Load]))?) + | ^(GenFor test[expr_contextType.Load] gen_for) + ; +keyword[List kws] + : ^(Keyword ^(Arg arg=test[expr_contextType.Load]) ^(Value val=test[expr_contextType.Load])) { + kws.add(new keywordType($Keyword, $arg.text, $val.etype)); + } + ; + list_iter: list_for | list_if ; Modified: trunk/sandbox/ast/regr =================================================================== --- trunk/sandbox/ast/regr 2007-12-11 22:23:45 UTC (rev 3795) +++ trunk/sandbox/ast/regr 2007-12-12 00:43:57 UTC (rev 3796) @@ -768,7 +768,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/hooks.py ./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/regression.py ./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/transactions.py -#./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/types.py +./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/types.py ./run /Users/frank/src/python/release25-maint/Lib/sqlite3/test/userfunctions.py ./run /Users/frank/src/python/release25-maint/Lib/sre.py ./run /Users/frank/src/python/release25-maint/Lib/sre_compile.py @@ -1008,6 +1008,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/test/test_long.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_long_future.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_longexp.py +echo Lib/test/m ./run /Users/frank/src/python/release25-maint/Lib/test/test_macfs.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_macostools.py ./run /Users/frank/src/python/release25-maint/Lib/test/test_macpath.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-14 13:03:00
|
Revision: 3805 http://jython.svn.sourceforge.net/jython/?rev=3805&view=rev Author: fwierzbicki Date: 2007-12-14 05:02:53 -0800 (Fri, 14 Dec 2007) Log Message: ----------- added diff testing to astlib.py. Modified Paths: -------------- trunk/sandbox/ast/jastlib.py trunk/sandbox/ast/run Added Paths: ----------- trunk/sandbox/ast/astlib.py Added: trunk/sandbox/ast/astlib.py =================================================================== --- trunk/sandbox/ast/astlib.py (rev 0) +++ trunk/sandbox/ast/astlib.py 2007-12-14 13:02:53 UTC (rev 3805) @@ -0,0 +1,78 @@ +"""lispify_ast - returns a tuple representation of the AST + +Uses 2.5's _ast, not other AST implementations in CPython, since these +are not used by the compilation phase. And that's what we're +interested in. + +Since this is a tuple, we can directly compare, and this is going to +be handy when comparing Jython's implementation vs CPython. + +""" + +import _ast + +def lispify_ast(node): + return tuple(lispify_ast2(node)) + +def lispify_ast2(node): + yield node.__class__.__name__ + try: + for field in node._fields: + yield tuple(lispify_field(field, getattr(node, field))) + except: + pass + +def lispify_field(field, child): + yield field + if not isinstance(child, list): + children = [child] + else: + children = child + + for node in children: + if isinstance(node, _ast.AST): + yield lispify_ast(node) + else: + yield node + + +if __name__ == '__main__': + import sys + from pprint import pprint + from popen2 import popen2 + from StringIO import StringIO + from difflib import Differ + + code_path = sys.argv[1] + jy_exe = "jython" + if len(sys.argv) > 2: + jy_exe = sys.argv[2] + ast = compile(open(code_path).read(), code_path, "exec", _ast.PyCF_ONLY_AST) + lispified = lispify_ast(ast) + sio = StringIO() + pprint(lispified, stream=sio) + + fin, fout = popen2("%s jastlib.py %s" % (jy_exe, code_path)) + + sio.seek(0) + pstr = sio.readlines() + jstr = fin.readlines() + + differs = False + diffstr = [] + diff = Differ() + results = diff.compare(pstr, jstr) + for d in results: + diffstr.append(d) + if d[0] in ['+', '-']: + differs = True + + if differs: + print "---------- ouput -------------" + print "py: %s" % sio.getvalue() + print "jy: %s" % "".join(jstr) + print "---------- DIFF -------------" + print "".join(diffstr) + + #ast2 = compile(open(code_path).read(), code_path, "exec", _ast.PyCF_ONLY_AST) + #assert(lispified == lispify_ast(ast2)) Modified: trunk/sandbox/ast/jastlib.py =================================================================== --- trunk/sandbox/ast/jastlib.py 2007-12-13 13:27:57 UTC (rev 3804) +++ trunk/sandbox/ast/jastlib.py 2007-12-14 13:02:53 UTC (rev 3805) @@ -8,16 +8,22 @@ be handy when comparing Jython's implementation vs CPython. """ -import org.python.antlr.ast as _ast +import org.python.antlr.PythonTree as AST import org.python.antlr.Main as parser from types import ArrayType +contexts = {0:("0Store"),1:tuple(["Load"]),2:tuple(["Store"]),3:["3Store"],4:["4Store"],5:["5Store"],6:tuple(["Param"])} + def lispify_ast(node): return tuple(lispify_ast2(node)) def lispify_ast2(node): - yield str(node) + s = node.__class__.__name__ + name = s.split(".")[-1] + if name.endswith("Type"): + name = name[:-4] + yield name try: for field in node._fields: yield tuple(lispify_field(field, getattr(node, field))) @@ -25,17 +31,23 @@ pass def lispify_field(field, child): + fname = field yield field if not isinstance(child, ArrayType): children = [child] else: - children = child.tolist() + children = child for node in children: - if isinstance(node, (str, int)): - yield node + if isinstance(node, AST): + yield lispify_ast(node) else: - yield lispify_ast(node) + if fname == "ctx": + yield contexts[node] + elif fname == "n": + yield int(node) + else: + yield node if __name__ == '__main__': import sys @@ -43,5 +55,7 @@ code_path = sys.argv[1] ast = parser().parse([code_path]) + lispified = lispify_ast(ast) pprint(lispified) + #assert(lispified == lispify_ast(ast2)) Modified: trunk/sandbox/ast/run =================================================================== --- trunk/sandbox/ast/run 2007-12-13 13:27:57 UTC (rev 3804) +++ trunk/sandbox/ast/run 2007-12-14 13:02:53 UTC (rev 3805) @@ -1 +1,2 @@ java -classpath lib/antlr-3.0.1.jar:build org.python.antlr.Main $* +#ng org.python.antlr.Main $* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-15 15:29:34
|
Revision: 3807 http://jython.svn.sourceforge.net/jython/?rev=3807&view=rev Author: fwierzbicki Date: 2007-12-15 07:29:32 -0800 (Sat, 15 Dec 2007) Log Message: ----------- Work on exceptions, strings, and call sites. Modified Paths: -------------- trunk/sandbox/ast/Python.asdl trunk/sandbox/ast/grammar/Python.g trunk/sandbox/ast/grammar/PythonWalker.g trunk/sandbox/ast/regr Modified: trunk/sandbox/ast/Python.asdl =================================================================== --- trunk/sandbox/ast/Python.asdl 2007-12-15 00:22:58 UTC (rev 3806) +++ trunk/sandbox/ast/Python.asdl 2007-12-15 15:29:32 UTC (rev 3807) @@ -101,8 +101,8 @@ -- TODO(jhylton): Figure out if there is a better way to handle -- lineno and col_offset fields, particularly when -- ast is exposed to Python. - -- XXX(fwierzbicki): removed lineno and col_offset -- antlr handles this - excepthandler = (expr? type, expr? name, stmt* body) + excepthandler = (expr? type, expr? name, stmt* body, int lineno, + int col_offset) arguments = (expr* args, identifier? vararg, identifier? kwarg, expr* defaults) Modified: trunk/sandbox/ast/grammar/Python.g =================================================================== --- trunk/sandbox/ast/grammar/Python.g 2007-12-15 00:22:58 UTC (rev 3806) +++ trunk/sandbox/ast/grammar/Python.g 2007-12-15 15:29:32 UTC (rev 3807) @@ -135,7 +135,6 @@ Lambda; Repr; BinOp; - ArgList; Subscript; SubscriptList; Target; @@ -163,6 +162,7 @@ Elts; Ctx; Attr; + Call; //The tokens below are not represented in the 2.5 Python.asdl GenFor; GenIf; @@ -223,7 +223,7 @@ //decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE decorator: AT dotted_attr (LPAREN arglist? RPAREN)? NEWLINE - -> ^(Decorator dotted_attr ^(ArgList arglist)?) + -> ^(Decorator dotted_attr ^(Call arglist)?) ; dotted_attr @@ -583,7 +583,7 @@ ; //power: atom trailer* ['**' factor] -power : atom (trailer)* (options {greedy=true;}:DOUBLESTAR^ factor)? +power : atom (trailer^)* (options {greedy=true;}:DOUBLESTAR^ factor)? ; //atom: '(' [testlist] ')' | '[' [listmaker] ']' | '{' [dictmaker] '}' | '`' testlist1 '`' | NAME | NUMBER | STRING+ @@ -626,9 +626,9 @@ ; //trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME -trailer : LPAREN (arglist)? RPAREN -> ^(ArgList arglist?) +trailer : LPAREN (arglist)? RPAREN -> ^(Call ^(Args arglist)?) | LBRACK subscriptlist RBRACK -> ^(SubscriptList subscriptlist) - | DOT NAME + | DOT^ NAME {debug("motched DOT^ NAME");} ; //subscriptlist: subscript (',' subscript)* [','] @@ -653,7 +653,7 @@ //testlist: test (',' test)* [','] testlist : (test COMMA) => test (options {k=2;}: COMMA test)* (COMMA)? -> ^(Tuple test+) - | test -> test + | test ; //XXX: Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-15 00:22:58 UTC (rev 3806) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-15 15:29:32 UTC (rev 3807) @@ -42,6 +42,7 @@ import org.python.antlr.ast.Tuple; import org.python.antlr.ast.Pass; import org.python.antlr.ast.Print; +import org.python.antlr.ast.Raise; import org.python.antlr.ast.Return; import org.python.antlr.ast.Str; import org.python.antlr.ast.Yield; @@ -137,24 +138,25 @@ char quoteChar = s.charAt(0); int start=0; boolean ustring = false; - boolean raw = false; if (quoteChar == 'u' || quoteChar == 'U') { ustring = true; start++; } quoteChar = s.charAt(start); + boolean raw = false; if (quoteChar == 'r' || quoteChar == 'R') { raw = true; start++; } - quoteChar = s.charAt(start); - int quotes = 1; - if (quoteChar == '"' && s.charAt(start +1) == '"' || - quoteChar == '\'' && s.charAt(start+1) == '\'') { - quotes = 3; + int quotes = 3; + if (s.length() - start == 2) { + quotes = 1; } + if (s.charAt(start) != s.charAt(start+1)) { + quotes = 1; + } + if (raw) { - //XXX: What about ur? return s.substring(quotes+start+1, s.length()-quotes); } else { StringBuffer sb = new StringBuffer(s.length()); @@ -169,7 +171,7 @@ //FIXME: placeholder until I re-integrate with Jython. public static String decode_UnicodeEscape(String str, int start, int end, String errors, boolean unicode) { - return str; + return str.substring(start, end); } @@ -281,14 +283,14 @@ ; decorator [List decs] - : ^(Decorator dotted_attr (^(ArgList arglist))?) { - if ($ArgList == null) { + : ^(Decorator dotted_attr (^(Call arglist))?) { + if ($Call == null) { debug("not call site!"); decs.add($dotted_attr.etype); } else { exprType[] args = (exprType[])$arglist.args.toArray(new exprType[$arglist.args.size()]); keywordType[] keywords = (keywordType[])$arglist.keywords.toArray(new keywordType[$arglist.keywords.size()]); - Call c = new Call($ArgList, $dotted_attr.etype, args, keywords, $arglist.starargs, $arglist.kwargs); + Call c = new Call($Call, $dotted_attr.etype, args, keywords, $arglist.starargs, $arglist.kwargs); debug("call site!"); decs.add(c); } @@ -296,7 +298,7 @@ ; dotted_attr returns [exprType etype] - : NAME {$etype = new Name($NAME, $NAME.text, expr_contextType.Load); debug("Matched Name");} + : NAME {$etype = new Name($NAME, $NAME.text, expr_contextType.Load); debug("matched NAME in dotted_attr");} | ^(DOT n1=dotted_attr n2=dotted_attr) { $etype = new Attribute($DOT, $n1.etype, $n2.text, expr_contextType.Load); } @@ -355,8 +357,26 @@ Assign a = new Assign($Assign, e, $value.etype); $stmts::statements.add(a); } +// | call_expr ; +call_expr + : ^(Call (^(Args arglist))? test[expr_contextType.Load]) { + Call c; + if ($Args == null) { + c = new Call($Call, $test.etype, new exprType[0], new keywordType[0], null, null); + debug("Matched Call site no args"); + } else { + debug($arglist.text + "!!!!" + $test.text); + debug("Matched Call w/ args"); + exprType[] args = (exprType[])$arglist.args.toArray(new exprType[$arglist.args.size()]); + keywordType[] keywords = (keywordType[])$arglist.keywords.toArray(new keywordType[$arglist.keywords.size()]); + c = new Call($Call, $test.etype, args, keywords, $arglist.starargs, $arglist.kwargs); + } + $stmts::statements.add(new Expr($Call, c)); + } + ; + targets returns [List etypes] @init { List targs = new ArrayList(); @@ -448,7 +468,22 @@ ; raise_stmt - : ^(Raise (^(Type test[expr_contextType.Load]))? (^(Inst test[expr_contextType.Load]))? (^(Tback test[expr_contextType.Load]))?) + : ^(Raise (^(Type type=test[expr_contextType.Load]))? (^(Inst inst=test[expr_contextType.Load]))? (^(Tback tback=test[expr_contextType.Load]))?) { + exprType t = null; + if ($Type != null) { + t = $type.etype; + } + exprType i = null; + if ($Inst != null) { + i = $inst.etype; + } + exprType b = null; + if ($Tback != null) { + b = $tback.etype; + } + + $stmts::statements.add(new Raise($Raise, t, i, b)); + } ; import_stmt @@ -535,8 +570,9 @@ if ($Name != null) { n = $name.etype; } - //handlers.add(new excepthandlerType($ExceptHandler, $type.etype, $name.etype, b)); - handlers.add(new excepthandlerType($ExceptHandler, t, n, b)); + //XXX: getCharPositionInLine() -7 is only accurate in the simplist cases -- need to + // look harder at CPython to figure out what is really needed here. + handlers.add(new excepthandlerType($ExceptHandler, t, n, b, $ExceptHandler.getLine(), $ExceptHandler.getCharPositionInLine())); } ; @@ -567,7 +603,11 @@ $etype = new Compare($comp_op.start, $left.etype, ops, targets); debug("COMP_OP: " + $comp_op.start); } - | atom[ctype] (trailer)* {$etype = $atom.etype;} + | atom[ctype] { + debug("matched atom"); + debug("***" + $atom.etype); + $etype = $atom.etype; + } | ^(PLUS test[ctype] test[ctype]) | ^(MINUS left=test[ctype] right=test[ctype]) {} | ^(AMPER test[ctype] test[ctype]) @@ -584,6 +624,7 @@ | ^(USub test[ctype]) | ^(Invert test[ctype]) | lambdef + | call_expr ; comp_op returns [int op] @@ -637,33 +678,37 @@ | ^(Parens test[ctype]*) {} | ^(Dict test[ctype]*) {} | ^(Repr test[ctype]*) {} - | ^(Name NAME) {$etype = new Name($NAME, $NAME.text, ctype); debug("Matched Name");} + | ^(Name NAME) { + debug("matched Name " + $NAME.text); + $etype = new Name($NAME, $NAME.text, ctype); + } + | ^(DOT NAME test[ctype]) { + $etype = new Attribute($DOT, $atom.etype, $NAME.text, expr_contextType.Load); + } + | ^(SubscriptList subscriptlist test[ctype]) | ^(Num INT) {$etype = makeNum($INT);} | ^(Num LONGINT) {$etype = makeNum($LONGINT);} | ^(Num FLOAT) | ^(Num COMPLEX) | stringlist { + $etype = new Str($stringlist.start, extractStrings($stringlist.strings)); } ; -stringlist - : ^(Str string+) {} +stringlist returns [List strings] +@init { + List strs = new ArrayList(); +} + : ^(Str string[strs]+) {$strings = strs;} ; -string - : STRING {} +string[List strs] + : STRING {strs.add($STRING.text);} ; lambdef: ^(Lambda varargslist? ^(Body test[expr_contextType.Load])) ; -trailer - : ^(ArgList arglist?) { - } - | ^(SubscriptList subscriptlist) - | DOT NAME - ; - subscriptlist : subscript+ ; @@ -699,22 +744,34 @@ : ^(Args argument[arguments]* keyword[kws]*) (^(StarArgs stest=test[expr_contextType.Load]))? (^(KWArgs ktest=test[expr_contextType.Load]))? { $args=arguments; $keywords=kws; - //$starargs=stest.etype; - //$kwargs=ktest.etype; + if ($StarArgs != null) { + $starargs=$stest.etype; + } + if ($KWArgs != null) { + $kwargs=$ktest.etype; + } } - | ^(StarArgs test[expr_contextType.Load]) (^(KWArgs test[expr_contextType.Load]))? { + | ^(StarArgs stest=test[expr_contextType.Load]) (^(KWArgs ktest=test[expr_contextType.Load]))? { $args=arguments; $keywords=kws; + $starargs=$stest.etype; + if ($KWArgs != null) { + $kwargs=$ktest.etype; + } } | ^(KWArgs test[expr_contextType.Load]) { $args=arguments; $keywords=kws; + $kwargs=$test.etype; } ; argument[List arguments] - : ^(Arg test[expr_contextType.Load] (^(Default test[expr_contextType.Load]))?) + : ^(Arg test[expr_contextType.Load]) { + arguments.add($test.etype); + } | ^(GenFor test[expr_contextType.Load] gen_for) + //arguments.add($test.etype)); ; keyword[List kws] Modified: trunk/sandbox/ast/regr =================================================================== --- trunk/sandbox/ast/regr 2007-12-15 00:22:58 UTC (rev 3806) +++ trunk/sandbox/ast/regr 2007-12-15 15:29:32 UTC (rev 3807) @@ -139,6 +139,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/curses/panel.py ./run /Users/frank/src/python/release25-maint/Lib/curses/textpad.py ./run /Users/frank/src/python/release25-maint/Lib/curses/wrapper.py +echo Lib/d ./run /Users/frank/src/python/release25-maint/Lib/dbhash.py ./run /Users/frank/src/python/release25-maint/Lib/decimal.py ./run /Users/frank/src/python/release25-maint/Lib/difflib.py @@ -206,6 +207,7 @@ ./run /Users/frank/src/python/release25-maint/Lib/dumbdbm.py ./run /Users/frank/src/python/release25-maint/Lib/dummy_thread.py ./run /Users/frank/src/python/release25-maint/Lib/dummy_threading.py +echo Lib/e ./run /Users/frank/src/python/release25-maint/Lib/email/__init__.py ./run /Users/frank/src/python/release25-maint/Lib/email/_parseaddr.py ./run /Users/frank/src/python/release25-maint/Lib/email/base64mime.py This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-18 15:53:05
|
Revision: 3838 http://jython.svn.sourceforge.net/jython/?rev=3838&view=rev Author: fwierzbicki Date: 2007-12-18 07:52:44 -0800 (Tue, 18 Dec 2007) Log Message: ----------- improved Print and Import -- also improved astlib.py tool, try: astlib.py -h to see new options. Also if given a directory, it will find all of the .py files in that directory and below and test. Modified Paths: -------------- trunk/sandbox/ast/astlib.py trunk/sandbox/ast/grammar/Python.g trunk/sandbox/ast/grammar/PythonWalker.g trunk/sandbox/ast/jastlib.py Modified: trunk/sandbox/ast/astlib.py =================================================================== --- trunk/sandbox/ast/astlib.py 2007-12-17 23:33:17 UTC (rev 3837) +++ trunk/sandbox/ast/astlib.py 2007-12-18 15:52:44 UTC (rev 3838) @@ -10,6 +10,8 @@ """ import _ast +import os +import glob def lispify_ast(node): return tuple(lispify_ast2(node)) @@ -35,44 +37,87 @@ else: yield node - -if __name__ == '__main__': - import sys +def main(code_path, jy_exe="jython", print_diff=True, print_fail=False, print_success=False,): from pprint import pprint from popen2 import popen2 from StringIO import StringIO from difflib import Differ - code_path = sys.argv[1] - jy_exe = "jython" - if len(sys.argv) > 2: - jy_exe = sys.argv[2] - ast = compile(open(code_path).read(), code_path, "exec", _ast.PyCF_ONLY_AST) - lispified = lispify_ast(ast) - sio = StringIO() - pprint(lispified, stream=sio) + if os.path.isdir(code_path): + pyfiles = glob.glob("%s/**.py" % code_path) + else: + pyfiles = [code_path] - fin, fout = popen2("%s jastlib.py %s" % (jy_exe, code_path)) + for pyfile in pyfiles: + ast = compile(open(pyfile).read(), pyfile, "exec", _ast.PyCF_ONLY_AST) + lispified = lispify_ast(ast) + sio = StringIO() + pprint(lispified, stream=sio) - sio.seek(0) - pstr = sio.readlines() - jstr = fin.readlines() + fin, fout = popen2("%s jastlib.py %s" % (jy_exe, pyfile)) - differs = False - diffstr = [] - diff = Differ() - results = diff.compare(pstr, jstr) - for d in results: - diffstr.append(d) - if d[0] in ['+', '-']: - differs = True + sio.seek(0) + pstr = sio.readlines() + jstr = fin.readlines() - if differs: - print "---------- ouput -------------" - print "py: %s" % sio.getvalue() - print "jy: %s" % "".join(jstr) - print "---------- DIFF -------------" - print "".join(diffstr) + differs = False + diffstr = [] + diff = Differ() + results = diff.compare(pstr, jstr) + for d in results: + diffstr.append(d) + if d[0] in ['+', '-']: + differs = True - #ast2 = compile(open(code_path).read(), code_path, "exec", _ast.PyCF_ONLY_AST) - #assert(lispified == lispify_ast(ast2)) + if print_success and not differs: + print "SUCCESS: %s" % pyfile + + if print_fail and differs: + print "FAIL: %s" % pyfile + + if print_diff and differs: + print "---------- ouput -------------" + print "py: %s" % sio.getvalue() + print "jy: %s" % "".join(jstr) + print "---------- DIFF -------------" + print "".join(diffstr) + +if __name__ == '__main__': + import sys + import getopt + + usage = """\ +Usage: python %s [-j jython_exe_name] [-s -f -d] code_path + where -s = print success messages + -f = print failure messages + -d = don't print diffs on failure + if codepath is a file test it, if codepath is a directory + test all .py files in and below that directory. +""" % sys.argv[0] + + jy_exe = 'jython' + print_diff = True + print_fail = False + print_success = False + try: + opts, args = getopt.getopt(sys.argv[1:], 'j:sfdh') + except: + print usage + sys.exit(1) + for o, v in opts: + if o == '-h': + print usage + sys.exit(0) + if o == '-j' and v != '': + jy_exe = v + if o == '-s': + print_success = True + if o == '-f': + print_fail = True + if o == '-d': + print_diff = False + if len(args) < 1 or len(args) > 7: + print usage + sys.exit(1) + + main(args[0], jy_exe, print_diff, print_fail, print_success) Modified: trunk/sandbox/ast/grammar/Python.g =================================================================== --- trunk/sandbox/ast/grammar/Python.g 2007-12-17 23:33:17 UTC (rev 3837) +++ trunk/sandbox/ast/grammar/Python.g 2007-12-18 15:52:44 UTC (rev 3838) @@ -162,6 +162,9 @@ Ctx; Attr; Call; + Dest; + Values; + Newline; //The tokens below are not represented in the 2.5 Python.asdl GenFor; GenIf; @@ -329,11 +332,12 @@ ; //print_stmt: 'print' ( [ test (',' test)* [','] ] | '>>' test [ (',' test)+ [','] ] ) +//XXX: we need to capture the presence/absence of a trailing comma for print (yuck) print_stmt : 'print' ( testlist | RIGHTSHIFT testlist )? - -> ^(Print RIGHTSHIFT? testlist?) + -> ^(Print ^(Dest RIGHTSHIFT)? ^(Values testlist)?) ; //del_stmt: 'del' exprlist @@ -652,9 +656,13 @@ ; //testlist: test (',' test)* [','] -testlist : (test COMMA) => test (options {k=2;}: COMMA test)* (COMMA)? -> ^(Tuple ^(Elts test+)) - | test - ; +//XXX: newline is only used by print - is there a better way? +testlist returns [Token newline] + : (test COMMA) => test (options {k=2;}: COMMA test)* (trailcomma=COMMA)? { + $newline=$trailcomma; + } -> ^(Tuple ^(Elts test+)) + | test {$newline = null;} + ; //XXX: //testlist_safe: test [(',' test)+ [',']] Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-17 23:33:17 UTC (rev 3837) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-18 15:52:44 UTC (rev 3838) @@ -39,6 +39,7 @@ import org.python.antlr.ast.Global; import org.python.antlr.ast.If; import org.python.antlr.ast.Import; +import org.python.antlr.ast.ImportFrom; import org.python.antlr.ast.Module; import org.python.antlr.ast.Name; import org.python.antlr.ast.Num; @@ -454,7 +455,37 @@ ; print_stmt - : ^(Print RIGHTSHIFT? test[expr_contextType.Load]?) { + : ^(Print (^(Dest RIGHTSHIFT))? (^(Values test[expr_contextType.Load]))?) { + Print p; + exprType[] values; + + exprType dest = null; + boolean hasdest = false; + + //FIXME: just assuming newline for now. + boolean newline = true; + + if ($Dest != null) { + hasdest = true; + } + if ($Values != null) { + if ($test.etype instanceof Tuple) { + Tuple t = (Tuple)$test.etype; + if (hasdest) { + dest = t.elts[0]; + values = new exprType[t.elts.length - 1]; + System.arraycopy(t.elts, 1, values, 0, values.length); + } else { + values = t.elts; + } + } else { + values = new exprType[]{$test.etype}; + } + } else { + values = new exprType[0]; + } + p = new Print($Print, dest, values, newline); + $stmts::statements.add(p); } ; @@ -540,18 +571,26 @@ aliasType[] n = (aliasType[])nms.toArray(new aliasType[nms.size()]); $stmts::statements.add(new Import($Import, n)); } - | ^(ImportFrom dotted_name ^(Import STAR)) - | ^(ImportFrom dotted_name ^(Import import_as_name+)) + | ^(ImportFrom dotted_name ^(Import STAR)) { + //XXX here + aliasType[] n = (aliasType[])nms.toArray(new aliasType[nms.size()]); + $stmts::statements.add(new ImportFrom($Import, $dotted_name.result, new aliasType[]{new aliasType($STAR, "*", null)}, 0)); + } + | ^(ImportFrom dotted_name ^(Import import_as_name[nms]+)) { + //XXX here + aliasType[] n = (aliasType[])nms.toArray(new aliasType[nms.size()]); + $stmts::statements.add(new ImportFrom($Import, $dotted_name.result, n, 0)); + } ; -import_as_name +import_as_name[List nms] : ^(Alias name=NAME (^(Asname asname=NAME))?) { String as = null; if ($Asname != null) { as = $asname.text; } aliasType a = new aliasType($Alias, $name.text, as); - //nms.add(a); + nms.add(a); } ; @@ -561,15 +600,29 @@ if ($Asname != null) { as = $NAME.text; } - aliasType a = new aliasType($Alias, $dotted_name.text, as); + aliasType a = new aliasType($Alias, $dotted_name.result, as); nms.add(a); } ; -dotted_name - : start=NAME (DOT NAME)* +dotted_name returns [String result] +@init { + StringBuffer buf = new StringBuffer(); +} + : NAME dot_name[buf]* { + $result = $NAME.text + buf.toString(); + debug("matched dotted_name " + $result); + } ; +dot_name [StringBuffer buf] + : DOT NAME { + buf.append("."); + buf.append($NAME.text); + debug("matched dot_name " + buf); + } + ; + global_stmt @init { List nms = new ArrayList(); Modified: trunk/sandbox/ast/jastlib.py =================================================================== --- trunk/sandbox/ast/jastlib.py 2007-12-17 23:33:17 UTC (rev 3837) +++ trunk/sandbox/ast/jastlib.py 2007-12-18 15:52:44 UTC (rev 3838) @@ -14,6 +14,7 @@ from types import ArrayType contexts = {0:("0Store"),1:tuple(["Load"]),2:tuple(["Store"]),3:["3Store"],4:["4Store"],5:["5Store"],6:tuple(["Param"])} +#ops = {0:("Store"),1:tuple(["Eq"]),2:tuple(["Sub"]),3:["3Store"],4:["4Store"],5:["5Store"],6:tuple(["Param"])} def lispify_ast(node): return tuple(lispify_ast2(node)) @@ -44,6 +45,8 @@ else: if fname == "ctx": yield contexts[node] + #if fname == "ops": + # yield ops[node] elif fname == "n": yield int(node) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2007-12-19 00:10:20
|
Revision: 3840 http://jython.svn.sourceforge.net/jython/?rev=3840&view=rev Author: otmarhumbel Date: 2007-12-18 16:10:18 -0800 (Tue, 18 Dec 2007) Log Message: ----------- preserve antlr recovery, including verbose error messages Modified Paths: -------------- trunk/sandbox/ast/grammar/Python.g trunk/sandbox/ast/src/org/python/antlr/PythonTreeWalker.java Modified: trunk/sandbox/ast/grammar/Python.g =================================================================== --- trunk/sandbox/ast/grammar/Python.g 2007-12-18 23:17:30 UTC (rev 3839) +++ trunk/sandbox/ast/grammar/Python.g 2007-12-19 00:10:18 UTC (rev 3840) @@ -189,26 +189,36 @@ } /** - * Overridden to throw an exception on a mismatched token (see p. 252) - */ - protected void mismatch(IntStream input, int ttype, BitSet follow) throws RecognitionException { - throw new MismatchedTokenException(ttype, input); + * A list holding the error message(s) encountered during parse. + */ + private List<String> _errors = new ArrayList<String>(); + + /** + * @return <code>true</code> if the parser collected one or more error messages, + * <code>false</code> otherwise. + */ + public boolean hasErrors() { + return getErrors().size() > 0; } /** - * Overridden to throw an exception on a mismatched token (see p. 252) - */ - public void recoverFromMismatchedSet(IntStream input, RecognitionException e, BitSet follow) throws RecognitionException { - throw e; + * @return A list of the error message(s) collected during parse. + */ + public List<String> getErrors() { + return _errors; } -} -// really throw recognition errors (see p. 252) -@rulecatch { - catch (RecognitionException e) { - throw e; + /** + * Overridden to be able to collect error messages. + * <p> + * Since we do not want to lose the recovery mechanism and the verbose messages. + */ + @Override + public void emitErrorMessage(String msg) { + super.emitErrorMessage(msg); + getErrors().add(msg); } -} +} @lexer::header { package org.python.antlr; Modified: trunk/sandbox/ast/src/org/python/antlr/PythonTreeWalker.java =================================================================== --- trunk/sandbox/ast/src/org/python/antlr/PythonTreeWalker.java 2007-12-18 23:17:30 UTC (rev 3839) +++ trunk/sandbox/ast/src/org/python/antlr/PythonTreeWalker.java 2007-12-19 00:10:18 UTC (rev 3840) @@ -36,6 +36,15 @@ parser.setTreeAdaptor(pyadaptor); try { PythonParser.file_input_return r = parser.file_input(); + if (parser.hasErrors()) { + // handle errors swallowed by antlr recovery + String errors = parser.getErrors().toString(); + if (isTolerant()) { + System.err.println(errors); + } else { + throw new RuntimeException(errors); + } + } if (args.length > 1) { System.out.println(((Tree) r.tree).toStringTree()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-20 16:43:12
|
Revision: 3843 http://jython.svn.sourceforge.net/jython/?rev=3843&view=rev Author: fwierzbicki Date: 2007-12-20 08:42:52 -0800 (Thu, 20 Dec 2007) Log Message: ----------- Changed all of the int based enums to real java enums -- also fixed a bug in Print. Modified Paths: -------------- trunk/sandbox/ast/asdl_antlr.py trunk/sandbox/ast/grammar/Python.g trunk/sandbox/ast/grammar/PythonWalker.g trunk/sandbox/ast/jastlib.py Modified: trunk/sandbox/ast/asdl_antlr.py =================================================================== --- trunk/sandbox/ast/asdl_antlr.py 2007-12-20 16:25:47 UTC (rev 3842) +++ trunk/sandbox/ast/asdl_antlr.py 2007-12-20 16:42:52 UTC (rev 3843) @@ -139,18 +139,18 @@ def simple_sum(self, sum, name, depth): self.open("%sType" % name, refersToPythonTree=0) - self.emit("public interface %(name)sType {" % locals(), depth) + self.emit("public enum %(name)sType {" % locals(), depth) + self.emit("UNDEFINED,", depth + 1) for i in range(len(sum.types)): type = sum.types[i] - self.emit("public static final int %s = %d;" % (type.name, i+1), - depth + 1) - self.emit("", 0) - self.emit("public static final String[] %sTypeNames = new String[] {" % - name, depth+1) - self.emit('"<undef>",', depth+2) - for type in sum.types: - self.emit('"%s",' % type.name, depth+2) - self.emit("};", depth+1) + self.emit("%s," % type.name, depth + 1) + #self.emit("", 0) + #self.emit("public static final String[] %sTypeNames = new String[] {" % + # name, depth+1) + #self.emit('"<undef>",', depth+2) + #for type in sum.types: + # self.emit('"%s",' % type.name, depth+2) + #self.emit("};", depth+1) self.emit("}", depth) self.close() @@ -200,12 +200,12 @@ for f in cons.fields: if f.typedef and f.typedef.simple: enums.append("%sType" % f.type) - if enums: - s = "implements %s " % ", ".join(enums) - else: - s = "" - self.emit("public class %s extends %sType %s{" % - (cons.name, name, s), depth) + #if enums: + # s = "implements %s " % ", ".join(enums) + #else: + # s = "" + self.emit("public class %s extends %sType {" % + (cons.name, name), depth) for f in cons.fields: self.visit(f, depth + 1) self.emit("", depth) @@ -227,8 +227,12 @@ for f in fields: self.emit("this.%s = %s;" % (f.name, f.name), depth+1) fparg = self.fieldDef(f) - #For now ignoring int and String -- will want to wrap in a PythonTree later I think. - if f.seq and not fparg.startswith("int") and not fparg.startswith("String"): + #if field.typedef and field.typedef.simple: + not_simple = True + if f.typedef is not None and f.typedef.simple: + not_simple = False + #For now ignoring String -- will want to revisit + if f.seq and not_simple and not fparg.startswith("String"): self.emit("for(int i%(name)s=0;i%(name)s<%(name)s.length;i%(name)s++) {" % {"name":f.name}, depth+1) self.emit("addChild(%s[i%s]);" % (f.name, f.name), depth+2) self.emit("}", depth+1) @@ -317,10 +321,10 @@ def fieldDef(self, field): jtype = str(field.type) - if field.typedef and field.typedef.simple: - jtype = 'int' - else: - jtype = self.bltinnames.get(jtype, jtype + 'Type') + #if field.typedef and field.typedef.simple: + # jtype = 'int' + #else: + jtype = self.bltinnames.get(jtype, jtype + 'Type') name = field.name seq = field.seq and "[]" or "" return "%(jtype)s%(seq)s %(name)s" % locals() Modified: trunk/sandbox/ast/grammar/Python.g =================================================================== --- trunk/sandbox/ast/grammar/Python.g 2007-12-20 16:25:47 UTC (rev 3842) +++ trunk/sandbox/ast/grammar/Python.g 2007-12-20 16:42:52 UTC (rev 3843) @@ -367,7 +367,7 @@ -> ^(Print ^(Values $t1)) | RIGHTSHIFT t2=testlist -> {$t2.newline}? ^(Print ^(Dest RIGHTSHIFT) ^(Values testlist) ^(Newline)) -> ^(Print ^(Dest RIGHTSHIFT) ^(Values testlist)) - | -> Print + | -> ^(Print ^(Newline)) ) ; @@ -526,7 +526,9 @@ //except_clause: 'except' [test [',' test]] except_clause : 'except' (t1=test (COMMA t2=test)?)? COLON suite - -> ^(ExceptHandler ^(Type $t1)? ^(Name $t2)? ^(Body suite)) + //Note: passing the 'except' keyword on so we can pass the same offset + // as CPython. + -> ^(ExceptHandler 'except' ^(Type $t1)? ^(Name $t2)? ^(Body suite)) ; //suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-20 16:25:47 UTC (rev 3842) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-20 16:42:52 UTC (rev 3843) @@ -25,6 +25,7 @@ import org.python.antlr.ast.Assign; import org.python.antlr.ast.Attribute; import org.python.antlr.ast.AugAssign; +import org.python.antlr.ast.BinOp; import org.python.antlr.ast.Break; import org.python.antlr.ast.Call; import org.python.antlr.ast.ClassDef; @@ -313,7 +314,7 @@ defparameter[List params, List defaults] : NAME (ASSIGN test[expr_contextType.Load] )? { - params.add(new Name($NAME, $NAME.text, org.python.antlr.ast.Name.Param)); + params.add(new Name($NAME, $NAME.text, expr_contextType.Param)); if ($ASSIGN != null) { defaults.add($test.etype); } @@ -439,7 +440,7 @@ } ; -augassign returns [int op] +augassign returns [operatorType op] : PLUSEQUAL {$op = operatorType.Add;} | MINUSEQUAL {$op = operatorType.Sub;} | STAREQUAL {$op = operatorType.Mult;} @@ -725,7 +726,7 @@ ; except_clause[List handlers] - : ^(ExceptHandler (^(Type type=test[expr_contextType.Load]))? (^(Name name=test[expr_contextType.Load]))? ^(Body stmts)) { + : ^(ExceptHandler 'except' (^(Type type=test[expr_contextType.Load]))? (^(Name name=test[expr_contextType.Store]))? ^(Body stmts)) { stmtType[] b; if ($stmts.start != null) { b = (stmtType[])$stmts.stypes.toArray(new stmtType[$stmts.stypes.size()]); @@ -753,13 +754,13 @@ ; //FIXME: lots of placeholders -test[int ctype] returns [exprType etype] +test[expr_contextType ctype] returns [exprType etype] : ^('and' test[ctype] test[ctype]) | ^('or' test[ctype] test[ctype]) | ^('not' test[ctype]) | ^(comp_op left=test[ctype] targs=test[ctype]) { exprType[] targets = new exprType[1]; - int[] ops = new int[1]; + cmpopType[] ops = new cmpopType[1]; ops[0] = $comp_op.op; targets[0] = $targs.etype; $etype = new Compare($comp_op.start, $left.etype, ops, targets); @@ -772,14 +773,14 @@ } | ^(PLUS test[ctype] test[ctype]) | ^(MINUS left=test[ctype] right=test[ctype]) {} - | ^(AMPER test[ctype] test[ctype]) + | ^(AMPER left=test[ctype] right=test[ctype]) | ^(VBAR test[ctype] test[ctype]) | ^(CIRCUMFLEX test[ctype] test[ctype]) | ^(LEFTSHIFT test[ctype] test[ctype]) | ^(RIGHTSHIFT test[ctype] test[ctype]) | ^(STAR test[ctype] test[ctype]) | ^(SLASH test[ctype] test[ctype]) - | ^(PERCENT test[ctype] test[ctype]) + | ^(PERCENT left=test[ctype] right=test[ctype]) {$etype = new BinOp($left.start, left.etype, operatorType.Mod, right.etype);} | ^(DOUBLESLASH test[ctype] test[ctype]) | ^(DOUBLESTAR test[ctype] test[ctype]) | ^(UAdd test[ctype]) @@ -789,7 +790,7 @@ | lambdef ; -comp_op returns [int op] +comp_op returns [cmpopType op] : LESS {$op = cmpopType.Lt;} | GREATER {$op = cmpopType.Gt;} | EQUAL {$op = cmpopType.Eq;} @@ -805,7 +806,7 @@ //I *think* only sequences need to collect test rules in the walker since //testlist in the parser either results in one test or a tuple. -elts[int ctype] returns [List etypes] +elts[expr_contextType ctype] returns [List etypes] scope { List elements; } @@ -818,14 +819,14 @@ } ; -elt[int ctype] +elt[expr_contextType ctype] : test[ctype] { $elts::elements.add($test.etype); } ; //FIXME: lots of placeholders -atom[int ctype] returns [exprType etype] +atom[expr_contextType ctype] returns [exprType etype] : ^(Tuple (^(Elts elts[ctype]))?) { debug("matched Tuple"); exprType[] e; Modified: trunk/sandbox/ast/jastlib.py =================================================================== --- trunk/sandbox/ast/jastlib.py 2007-12-20 16:25:47 UTC (rev 3842) +++ trunk/sandbox/ast/jastlib.py 2007-12-20 16:42:52 UTC (rev 3843) @@ -13,9 +13,6 @@ from types import ArrayType -contexts = {0:("0Store"),1:tuple(["Load"]),2:tuple(["Store"]),3:["3Store"],4:["4Store"],5:["5Store"],6:tuple(["Param"])} -#ops = {0:("Store"),1:tuple(["Eq"]),2:tuple(["Sub"]),3:["3Store"],4:["4Store"],5:["5Store"],6:tuple(["Param"])} - def lispify_ast(node): return tuple(lispify_ast2(node)) @@ -43,10 +40,12 @@ if isinstance(node, AST): yield lispify_ast(node) else: - if fname == "ctx": - yield contexts[node] - #if fname == "ops": + if fname in ("ctx", "ops", "op"): + yield tuple([str(node)]) + #elif fname == "ops": # yield ops[node] + #elif fname == "op": + # yield op[node] elif fname == "n": yield int(node) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-21 02:32:39
|
Revision: 3845 http://jython.svn.sourceforge.net/jython/?rev=3845&view=rev Author: fwierzbicki Date: 2007-12-20 18:32:38 -0800 (Thu, 20 Dec 2007) Log Message: ----------- elif and binop support. Modified Paths: -------------- trunk/sandbox/ast/astlib.py trunk/sandbox/ast/grammar/PythonWalker.g Modified: trunk/sandbox/ast/astlib.py =================================================================== --- trunk/sandbox/ast/astlib.py 2007-12-21 02:21:13 UTC (rev 3844) +++ trunk/sandbox/ast/astlib.py 2007-12-21 02:32:38 UTC (rev 3845) @@ -1,3 +1,4 @@ +#!/usr/bin/env python """lispify_ast - returns a tuple representation of the AST Uses 2.5's _ast, not other AST implementations in CPython, since these Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-21 02:21:13 UTC (rev 3844) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-21 02:32:38 UTC (rev 3845) @@ -58,6 +58,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; +import java.util.ListIterator; import java.util.Map; import java.util.Set; } @@ -455,6 +456,22 @@ | DOUBLESLASHEQUAL {$op = operatorType.FloorDiv;} ; +binop returns [operatorType op] + : PLUS {$op = operatorType.Add;} + | MINUS {$op = operatorType.Sub;} + | STAR {$op = operatorType.Mult;} + | SLASH {$op = operatorType.Div;} + | PERCENT {$op = operatorType.Mod;} + | AMPER {$op = operatorType.BitAnd;} + | VBAR {$op = operatorType.BitOr;} + | CIRCUMFLEX {$op = operatorType.BitXor;} + | LEFTSHIFT {$op = operatorType.LShift;} + | RIGHTSHIFT {$op = operatorType.RShift;} + | DOUBLESTAR {$op = operatorType.Pow;} + | DOUBLESLASH {$op = operatorType.FloorDiv;} + ; + + print_stmt : ^(Print (^(Dest RIGHTSHIFT))? (^(Values test[expr_contextType.Load]))? (Newline)?) { Print p; @@ -667,18 +684,37 @@ ; if_stmt - : ^(If test[expr_contextType.Load] body=stmts elif_clause* (^(OrElse orelse=stmts))?) { - List o = null; +@init { + List elifs = new ArrayList(); +} + + : ^(If test[expr_contextType.Load] body=stmts elif_clause[elifs]* (^(OrElse orelse=stmts))?) { + stmtType[] o; if ($OrElse != null) { - o = $orelse.stypes; + o = (stmtType[])$orelse.stypes.toArray(new stmtType[$orelse.stypes.size()]); + } else { + o = new stmtType[0]; } - If i = makeIf($If, $test.etype, $body.stypes, o); + stmtType[] b = (stmtType[])$body.stypes.toArray(new stmtType[$body.stypes.size()]); + ListIterator iter = elifs.listIterator(elifs.size()); + while (iter.hasPrevious()) { + If elif = (If)iter.previous(); + elif.orelse = o; + o = new stmtType[]{elif}; + } + If i = new If($If, $test.etype, b, o); $stmts::statements.add(i); } ; -elif_clause - : ^(Elif test[expr_contextType.Load] stmts) +elif_clause[List elifs] + : ^(Elif test[expr_contextType.Load] stmts) { + debug("matched elif"); + stmtType[] b = (stmtType[])$stmts.stypes.toArray(new stmtType[$stmts.stypes.size()]); + //the stmtType[0] is intended to be replaced in the iterator of the if_stmt rule. + //there is probably a better way to do this. + elifs.add(new If($Elif, $test.etype, b, new stmtType[0])); + } ; while_stmt @@ -771,18 +807,10 @@ debug("***" + $atom.etype); $etype = $atom.etype; } - | ^(PLUS test[ctype] test[ctype]) - | ^(MINUS left=test[ctype] right=test[ctype]) {} - | ^(AMPER left=test[ctype] right=test[ctype]) - | ^(VBAR test[ctype] test[ctype]) - | ^(CIRCUMFLEX test[ctype] test[ctype]) - | ^(LEFTSHIFT test[ctype] test[ctype]) - | ^(RIGHTSHIFT test[ctype] test[ctype]) - | ^(STAR test[ctype] test[ctype]) - | ^(SLASH test[ctype] test[ctype]) - | ^(PERCENT left=test[ctype] right=test[ctype]) {$etype = new BinOp($left.start, left.etype, operatorType.Mod, right.etype);} - | ^(DOUBLESLASH test[ctype] test[ctype]) - | ^(DOUBLESTAR test[ctype] test[ctype]) + | ^(binop left=test[ctype] right=test[ctype]) { + debug("BinOp matched"); + $etype = new BinOp($left.start, left.etype, $binop.op, right.etype); + } | ^(UAdd test[ctype]) | ^(USub test[ctype]) | ^(Invert test[ctype]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2007-12-31 16:48:23
|
Revision: 3918 http://jython.svn.sourceforge.net/jython/?rev=3918&view=rev Author: fwierzbicki Date: 2007-12-31 08:48:20 -0800 (Mon, 31 Dec 2007) Log Message: ----------- Some handling of negatives, start of slice support, added a -n option to astlib to report the number of diff lines for each tested file. Modified Paths: -------------- trunk/sandbox/ast/astlib.py trunk/sandbox/ast/grammar/Python.g trunk/sandbox/ast/grammar/PythonWalker.g trunk/sandbox/ast/jastlib.py Modified: trunk/sandbox/ast/astlib.py =================================================================== --- trunk/sandbox/ast/astlib.py 2007-12-30 23:50:02 UTC (rev 3917) +++ trunk/sandbox/ast/astlib.py 2007-12-31 16:48:20 UTC (rev 3918) @@ -38,7 +38,7 @@ else: yield node -def main(code_path, jy_exe="jython", print_diff=True, print_fail=False, print_success=False,): +def main(code_path, jy_exe="jython", print_diff=True, print_fail=False, print_success=False, print_diff_lines=False): from pprint import pprint from popen2 import popen2 from StringIO import StringIO @@ -63,12 +63,14 @@ differs = False diffstr = [] + difflines = 0 diff = Differ() results = diff.compare(pstr, jstr) for d in results: diffstr.append(d) if d[0] in ['+', '-']: differs = True + difflines += 1 if print_success and not differs: print "SUCCESS: %s" % pyfile @@ -76,6 +78,9 @@ if print_fail and differs: print "FAIL: %s" % pyfile + if print_diff_lines: + print "%s diff lines in %s" % (difflines, pyfile) + if print_diff and differs: print "---------- ouput -------------" print "py: %s" % sio.getvalue() @@ -88,9 +93,10 @@ import getopt usage = """\ -Usage: python %s [-j jython_exe_name] [-s -f -d] code_path +Usage: python %s [-j jython_exe_name] [-s -f -d -n] code_path where -s = print success messages -f = print failure messages + -n = print number of diff lines -d = don't print diffs on failure if codepath is a file test it, if codepath is a directory test all .py files in and below that directory. @@ -98,10 +104,11 @@ jy_exe = 'jython' print_diff = True + print_diff_lines = False print_fail = False print_success = False try: - opts, args = getopt.getopt(sys.argv[1:], 'j:sfdh') + opts, args = getopt.getopt(sys.argv[1:], 'j:sfdhn') except: print usage sys.exit(1) @@ -117,8 +124,10 @@ print_fail = True if o == '-d': print_diff = False + if o == '-n': + print_diff_lines = True if len(args) < 1 or len(args) > 7: print usage sys.exit(1) - main(args[0], jy_exe, print_diff, print_fail, print_success) + main(args[0], jy_exe, print_diff, print_fail, print_success, print_diff_lines) Modified: trunk/sandbox/ast/grammar/Python.g =================================================================== --- trunk/sandbox/ast/grammar/Python.g 2007-12-30 23:50:02 UTC (rev 3917) +++ trunk/sandbox/ast/grammar/Python.g 2007-12-31 16:48:20 UTC (rev 3918) @@ -140,8 +140,9 @@ Target; Targets; Value; - Start; - End; + Lower; + Upper; + Step; SliceOp; UnaryOp; UAdd; @@ -551,7 +552,7 @@ ; //not_test: 'not' not_test | comparison -not_test : 'not'^ not_test +not_test : NOT^ not_test | comparison ; @@ -574,9 +575,9 @@ | ALT_NOTEQUAL | NOTEQUAL | 'in' - | 'not' 'in' -> NotIn + | NOT 'in' -> NotIn | 'is' - | 'is' 'not' -> IsNot + | 'is' NOT -> IsNot ; //expr: xor_expr ('|' xor_expr)* @@ -683,12 +684,12 @@ //subscript: '.' '.' '.' | test | [test] ':' [test] [sliceop] subscript : DOT DOT DOT -> Ellipsis - | t1=test (COLON (t2=test)? (sliceop)?)? -> ^(Subscript ^(Start $t1) ^(End $t2)? ^(SliceOp sliceop)?) - | COLON (test)? (sliceop)? -> ^(Subscript ^(End test)? ^(SliceOp sliceop)?) + | t1=test (COLON (t2=test)? (sliceop)?)? -> ^(Subscript ^(Lower $t1) ^(Upper $t2)? ^(Step sliceop)?) + | COLON (test)? (sliceop)? -> ^(Subscript ^(Upper test)? ^(Step sliceop)?) ; //sliceop: ':' [test] -sliceop : COLON (test)? -> test? +sliceop : COLON (test)? -> ^(SliceOp test)? ; //exprlist: expr (',' expr)* [','] @@ -879,6 +880,8 @@ OR : 'or' ; +NOT : 'not' ; + FLOAT : '.' DIGITS (Exponent)? | DIGITS ('.' (DIGITS (Exponent)?)? | Exponent) Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-30 23:50:02 UTC (rev 3917) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2007-12-31 16:48:20 UTC (rev 3918) @@ -22,7 +22,9 @@ import org.python.antlr.ast.keywordType; import org.python.antlr.ast.modType; import org.python.antlr.ast.operatorType; +import org.python.antlr.ast.sliceType; import org.python.antlr.ast.stmtType; +import org.python.antlr.ast.unaryopType; import org.python.antlr.ast.Assert; import org.python.antlr.ast.Assign; import org.python.antlr.ast.Attribute; @@ -42,12 +44,15 @@ import org.python.antlr.ast.FunctionDef; import org.python.antlr.ast.Global; import org.python.antlr.ast.If; +import org.python.antlr.ast.Index; import org.python.antlr.ast.Import; import org.python.antlr.ast.ImportFrom; import org.python.antlr.ast.ListComp; import org.python.antlr.ast.Module; import org.python.antlr.ast.Name; import org.python.antlr.ast.Num; +import org.python.antlr.ast.Slice; +import org.python.antlr.ast.Subscript; import org.python.antlr.ast.TryExcept; import org.python.antlr.ast.TryFinally; import org.python.antlr.ast.Tuple; @@ -56,9 +61,11 @@ import org.python.antlr.ast.Raise; import org.python.antlr.ast.Return; import org.python.antlr.ast.Str; +import org.python.antlr.ast.UnaryOp; import org.python.antlr.ast.While; import org.python.antlr.ast.Yield; +import java.math.BigInteger; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; @@ -190,7 +197,7 @@ Num makeNum(PythonTree t) { - debug("Num matched"); + debug("Num matched " + t.getText()); String s = t.getText(); int radix = 10; if (s.startsWith("0x") || s.startsWith("0X")) { @@ -201,25 +208,25 @@ } if (s.endsWith("L") || s.endsWith("l")) { s = s.substring(0, s.length()-1); - //return new Num(t, Py.newLong(new java.math.BigInteger(s, radix))); - return new Num(t, new java.math.BigInteger(s, radix)); + //return new Num(t, Py.newLong(new BigInteger(s, radix))); + return new Num(t, new BigInteger(s, radix)); } int ndigits = s.length(); int i=0; while (i < ndigits && s.charAt(i) == '0') i++; if ((ndigits - i) > 11) { - //return new Num(t, Py.newLong(new java.math.BigInteger(s, radix))); - return new Num(t, new java.math.BigInteger(s, radix)); + //return new Num(t, Py.newLong(new BigInteger(s, radix))); + return new Num(t, new BigInteger(s, radix)); } long l = Long.valueOf(s, radix).longValue(); if (l > 0xffffffffl || (radix == 10 && l > Integer.MAX_VALUE)) { - //return new Num(t, Py.newLong(new java.math.BigInteger(s, radix))); - return new Num(t, new java.math.BigInteger(s, radix)); + //return new Num(t, Py.newLong(new BigInteger(s, radix))); + return new Num(t, new BigInteger(s, radix)); } //return new Num(t, Py.newInteger((int) l)); - return new Num(t, new Long(l)); + return new Num(t, BigInteger.valueOf(l)); } private stmtType makeTryExcept(PythonTree t, List body, List handlers, List orelse, List finBody) { @@ -285,6 +292,17 @@ stmtType[] b = (stmtType[])body.toArray(new stmtType[body.size()]); return new For(t, target, iter, b, o); } + + //FIXME: only handling Num for now. + private exprType negate(exprType o) { + if (o instanceof Num) { + Num num = (Num)o; + BigInteger b = (BigInteger)num.n; + num.n = b.negate(); + return num; + } + return o; + } } module returns [modType mod] @@ -395,6 +413,7 @@ expr_stmt : test[expr_contextType.Load] { + debug("matched expr_stmt:test " + $test.etype); $stmts::statements.add(new Expr($test.start, $test.etype)); } | ^(augassign targ=test[expr_contextType.Store] value=test[expr_contextType.Load]) { @@ -878,7 +897,10 @@ //XXX: could re-use BoolOps discarded above in many cases. $etype = new BoolOp($OR, boolopType.Or, e); } - | ^('not' test[ctype]) + | ^(NOT test[ctype]) { + $etype = new UnaryOp($NOT, unaryopType.Not, $test.etype); + $etype = $test.etype; + } | ^(comp_op left=test[ctype] targs=test[ctype]) { exprType[] targets = new exprType[1]; cmpopType[] ops = new cmpopType[1]; @@ -896,10 +918,9 @@ debug("BinOp matched"); $etype = new BinOp($left.start, left.etype, $binop.op, right.etype); } - | ^(UAdd test[ctype]) - | ^(USub test[ctype]) - | ^(Invert test[ctype]) - | call_expr {$etype = $call_expr.etype;} + | call_expr { + $etype = $call_expr.etype; + } | lambdef ; @@ -992,14 +1013,38 @@ debug("matched DOT in atom: " + $test.etype + "###" + $NAME.text); $etype = new Attribute($DOT, $test.etype, $NAME.text, ctype); } - | ^(SubscriptList subscriptlist test[ctype]) - | ^(Num INT) {$etype = makeNum($INT);} + | ^(SubscriptList subscriptlist test[expr_contextType.Load]) { + //XXX: only handling one subscript for now. + sliceType s; + if ($subscriptlist.sltypes.size() == 0) { + s = null; + } else { + s = (sliceType)$subscriptlist.sltypes.get(0); + } + $etype = new Subscript($SubscriptList, $test.etype, s, ctype); + } + | ^(Num INT) { + $etype = makeNum($INT); + debug("makeNum output: " + $etype); + } | ^(Num LONGINT) {$etype = makeNum($LONGINT);} | ^(Num FLOAT) | ^(Num COMPLEX) | stringlist { $etype = new Str($stringlist.start, extractStrings($stringlist.strings)); } + | ^(USub test[ctype]) { + debug("USub matched " + $test.etype); + //FIXME: need to actually negate this + $etype = negate($test.etype); + } + | ^(UAdd test[ctype]) { + $etype = $test.etype; + } + | ^(Invert test[ctype]) { + //FIXME: need to actually invert this + $etype = $test.etype; + } ; stringlist returns [List strings] @@ -1016,12 +1061,41 @@ lambdef: ^(Lambda varargslist? ^(Body test[expr_contextType.Load])) ; -subscriptlist - : subscript+ +subscriptlist returns [List sltypes] +@init { + List subs = new ArrayList(); +} + : subscript[subs]+ { + $sltypes = subs; + } ; -subscript : Ellipsis - | ^(Subscript (^(Start test[expr_contextType.Load]))? (^(End test[expr_contextType.Load]))? (^(SliceOp test[expr_contextType.Load]?))?) +subscript [List subs] + : Ellipsis + | ^(Subscript (^(Lower start=test[expr_contextType.Load]))? + (^(Upper end=test[expr_contextType.Load]))? (^(Step (^(SliceOp op=test[expr_contextType.Load]))?))?) { + exprType s = null; + exprType e = null; + exprType o = null; + if ($Lower != null) { + s = $start.etype; + } + if ($Upper != null) { + e = $end.etype; + } + if ($Step != null) { + if ($SliceOp != null) { + o = $op.etype; + } + } + + if (o != null || e != null) { + subs.add(new Slice($Subscript, s, e, o)); + } + else if (s != null) { + subs.add(new Index($Subscript, s)); + } + } ; classdef Modified: trunk/sandbox/ast/jastlib.py =================================================================== --- trunk/sandbox/ast/jastlib.py 2007-12-30 23:50:02 UTC (rev 3917) +++ trunk/sandbox/ast/jastlib.py 2007-12-31 16:48:20 UTC (rev 3918) @@ -42,12 +42,9 @@ else: if fname in ("ctx", "ops", "op"): yield tuple([str(node)]) - #elif fname == "ops": - # yield ops[node] - #elif fname == "op": - # yield op[node] elif fname == "n": - yield int(node) + #assuming n is BigInteger -- valid for now. + yield node.intValue() else: yield node This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-01-02 01:50:56
|
Revision: 3945 http://jython.svn.sourceforge.net/jython/?rev=3945&view=rev Author: fwierzbicki Date: 2008-01-01 17:50:54 -0800 (Tue, 01 Jan 2008) Log Message: ----------- start of complex and float support Modified Paths: -------------- trunk/sandbox/ast/grammar/PythonWalker.g trunk/sandbox/ast/jastlib.py Modified: trunk/sandbox/ast/grammar/PythonWalker.g =================================================================== --- trunk/sandbox/ast/grammar/PythonWalker.g 2008-01-02 00:18:13 UTC (rev 3944) +++ trunk/sandbox/ast/grammar/PythonWalker.g 2008-01-02 01:50:54 UTC (rev 3945) @@ -196,8 +196,18 @@ return str.substring(start, end); } + Num makeFloat(PythonTree t) { + debug("makeFloat matched " + t.getText()); + return new Num(t, Double.valueOf(t.getText())); + } - Num makeNum(PythonTree t) { + Num makeComplex(PythonTree t) { + String s = t.getText(); + s = s.substring(0, s.length() - 1); + return new Num(t, Double.valueOf(s)); + } + + Num makeInt(PythonTree t) { debug("Num matched " + t.getText()); String s = t.getText(); int radix = 10; @@ -294,12 +304,14 @@ return new For(t, target, iter, b, o); } - //FIXME: only handling Num for now. + //FIXME: only handling Num + BigInteger for now. private exprType negate(exprType o) { if (o instanceof Num) { Num num = (Num)o; - BigInteger b = (BigInteger)num.n; - num.n = b.negate(); + if (num.n instanceof BigInteger) { + BigInteger b = (BigInteger)num.n; + num.n = b.negate(); + } return num; } return o; @@ -1023,12 +1035,15 @@ $etype = new Subscript($SubscriptList, $test.etype, s, ctype); } | ^(Num INT) { - $etype = makeNum($INT); - debug("makeNum output: " + $etype); + $etype = makeInt($INT); + debug("makeInt output: " + $etype); } - | ^(Num LONGINT) {$etype = makeNum($LONGINT);} - | ^(Num FLOAT) - | ^(Num COMPLEX) + | ^(Num LONGINT) {$etype = makeInt($LONGINT);} + | ^(Num FLOAT) { + $etype = makeFloat($FLOAT); + debug("float matched" + $etype); + } + | ^(Num COMPLEX) {$etype = makeComplex($COMPLEX);} | stringlist { $etype = new Str($stringlist.start, extractStrings($stringlist.strings)); } Modified: trunk/sandbox/ast/jastlib.py =================================================================== --- trunk/sandbox/ast/jastlib.py 2008-01-02 00:18:13 UTC (rev 3944) +++ trunk/sandbox/ast/jastlib.py 2008-01-02 01:50:54 UTC (rev 3945) @@ -13,6 +13,8 @@ from types import ArrayType +from java.math import BigInteger + def lispify_ast(node): return tuple(lispify_ast2(node)) @@ -43,8 +45,13 @@ if fname in ("ctx", "ops", "op"): yield tuple([str(node)]) elif fname == "n": - #assuming n is BigInteger -- valid for now. - yield node.intValue() + try: + if isinstance(node, BigInteger): + yield node.intValue() + elif isinstance(node, float): + yield node + except Exception, why: + print "error processing n: %s" % why else: yield node This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |