summaryrefslogtreecommitdiffstats
path: root/Grammar
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2000-08-12 18:09:51 (GMT)
committerSkip Montanaro <skip@pobox.com>2000-08-12 18:09:51 (GMT)
commit803d6e5451cbf0416bfb252eedba36ff2e354fac (patch)
treee37c0cf52e141c341e6b8a64a5d7e7691313df41 /Grammar
parentb16b83534d008d45a2917bd2c4fd65010909dff2 (diff)
downloadcpython-803d6e5451cbf0416bfb252eedba36ff2e354fac.zip
cpython-803d6e5451cbf0416bfb252eedba36ff2e354fac.tar.gz
cpython-803d6e5451cbf0416bfb252eedba36ff2e354fac.tar.bz2
list comprehensions. see
http://sourceforge.net/patch/?func=detailpatch&patch_id=100654&group_id=5470 for details.
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/Grammar7
1 files changed, 6 insertions, 1 deletions
diff --git a/Grammar/Grammar b/Grammar/Grammar
index 57a39de..872ec81 100644
--- a/Grammar/Grammar
+++ b/Grammar/Grammar
@@ -74,7 +74,8 @@ arith_expr: term (('+'|'-') term)*
term: factor (('*'|'/'|'%') factor)*
factor: ('+'|'-'|'~') factor | power
power: atom trailer* ('**' factor)*
-atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING+
+atom: '(' [testlist] ')' | '[' [listmaker] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING+
+listmaker: test ( list_iter | (',' test)* [','] )
lambdef: 'lambda' [varargslist] ':' test
trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
subscriptlist: subscript (',' subscript)* [',']
@@ -88,3 +89,7 @@ classdef: 'class' NAME ['(' testlist ')'] ':' suite
arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**' test)
argument: [test '='] test # Really [keyword '='] test
+
+list_iter: list_for | list_if
+list_for: 'for' exprlist 'in' testlist [list_iter]
+list_if: 'if' test [list_iter]