From: <fwi...@us...> - 2009-01-14 01:04:11
|
Revision: 5926 http://jython.svn.sourceforge.net/jython/?rev=5926&view=rev Author: fwierzbicki Date: 2009-01-14 01:03:58 +0000 (Wed, 14 Jan 2009) Log Message: ----------- A first cut at some 2.6 parsing. Modified Paths: -------------- trunk/sandbox/wierzbicki/grammar26/grammar/Python.g trunk/sandbox/wierzbicki/grammar26/src/org/python/antlr/GrammarActions.java Modified: trunk/sandbox/wierzbicki/grammar26/grammar/Python.g =================================================================== --- trunk/sandbox/wierzbicki/grammar26/grammar/Python.g 2009-01-13 22:10:24 UTC (rev 5925) +++ trunk/sandbox/wierzbicki/grammar26/grammar/Python.g 2009-01-14 01:03:58 UTC (rev 5926) @@ -942,9 +942,9 @@ } ; -//except_clause: 'except' [test [',' test]] +//except_clause: 'except' [test [('as' | ',') test]] except_clause - : EXCEPT (t1=test[expr_contextType.Load] (COMMA t2=test[expr_contextType.Store])?)? COLON suite[!$suite.isEmpty() && $suite::continueIllegal] + : EXCEPT (t1=test[expr_contextType.Load] ((COMMA | AS) t2=test[expr_contextType.Store])?)? COLON suite[!$suite.isEmpty() && $suite::continueIllegal] -> ^(EXCEPT<ExceptHandler>[$EXCEPT, actions.castExpr($t1.tree), actions.castExpr($t2.tree), actions.castStmts($suite.stypes)]) ; @@ -1487,7 +1487,7 @@ } : argument[arguments, kws, gens, true] (COMMA argument[arguments, kws, gens, false])* (COMMA - ( STAR s=test[expr_contextType.Load] (COMMA DOUBLESTAR k=test[expr_contextType.Load])? + ( STAR s=test[expr_contextType.Load] (COMMA argument[arguments, kws, gens, false])* (COMMA DOUBLESTAR k=test[expr_contextType.Load])? | DOUBLESTAR k=test[expr_contextType.Load] )? )? @@ -1741,8 +1741,12 @@ INT : // Hex '0' ('x' | 'X') ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+ | // Octal - '0' ( '0' .. '7' )* - | '1'..'9' DIGITS* + '0' ('o' | 'O') ( '0' .. '7' )* + | '0' ( '0' .. '7' )* + | // Binary + '0' ('b' | 'B') ( '0' .. '1' )* + | // Decimal + '1'..'9' DIGITS* ; COMPLEX @@ -1761,7 +1765,7 @@ * should make us exit loop not continue. */ STRING - : ('r'|'u'|'ur'|'R'|'U'|'UR'|'uR'|'Ur')? + : ('r'|'u'|'b'|'ur'|'R'|'U'|'B'|'UR'|'uR'|'Ur')? ( '\'\'\'' (options {greedy=false;}:TRIAPOS)* '\'\'\'' | '"""' (options {greedy=false;}:TRIQUOTE)* '"""' | '"' (ESC|~('\\'|'\n'|'"'))* '"' @@ -1775,7 +1779,7 @@ ; STRINGPART - : {partial}?=> ('r'|'u'|'ur'|'R'|'U'|'UR'|'uR'|'Ur')? + : {partial}?=> ('r'|'u'|'b'|'ur'|'R'|'U'|'B'|'UR'|'uR'|'Ur')? ( '\'\'\'' ~('\'\'\'')* | '"""' ~('"""')* ) Modified: trunk/sandbox/wierzbicki/grammar26/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/sandbox/wierzbicki/grammar26/src/org/python/antlr/GrammarActions.java 2009-01-13 22:10:24 UTC (rev 5925) +++ trunk/sandbox/wierzbicki/grammar26/src/org/python/antlr/GrammarActions.java 2009-01-14 01:03:58 UTC (rev 5926) @@ -350,6 +350,12 @@ if (s.startsWith("0x") || s.startsWith("0X")) { radix = 16; s = s.substring(2, s.length()); + } else if (s.startsWith("0o") || s.startsWith("0O")) { + radix = 8; + s = s.substring(2, s.length()); + } else if (s.startsWith("0b") || s.startsWith("0B")) { + radix = 2; + s = s.substring(2, s.length()); } else if (s.startsWith("0")) { radix = 8; } @@ -415,6 +421,10 @@ int end; boolean ustring = false; + if (quoteChar == 'b' || quoteChar == 'B') { + start++; + } + if (quoteChar == 'u' || quoteChar == 'U') { ustring = true; start++; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |