summaryrefslogtreecommitdiffstats
path: root/Grammar
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-10-24 14:54:25 (GMT)
committerGuido van Rossum <guido@python.org>1991-10-24 14:54:25 (GMT)
commit9eb4f535aa66ab78057fb553c1a3428967d46646 (patch)
tree149868662f908d9800cea39e7319a631e809601c /Grammar
parent1242f1da6734c4660b3e557a4764d93783d85d51 (diff)
downloadcpython-9eb4f535aa66ab78057fb553c1a3428967d46646.zip
cpython-9eb4f535aa66ab78057fb553c1a3428967d46646.tar.gz
cpython-9eb4f535aa66ab78057fb553c1a3428967d46646.tar.bz2
Added shifting and masking operators.
Diffstat (limited to 'Grammar')
-rw-r--r--Grammar/Grammar14
1 files changed, 11 insertions, 3 deletions
diff --git a/Grammar/Grammar b/Grammar/Grammar
index 90a43f5..6de1312 100644
--- a/Grammar/Grammar
+++ b/Grammar/Grammar
@@ -1,4 +1,8 @@
-# Grammar for Python, version 6
+# Grammar for Python, version 7
+
+# Changes since version 6:
+# Add logical operators '|', '^', '&' and '~'
+# Add shift operators '<<' and '>>'
# Changes since version 5:
# Comparison operators '<=' '>' '<>' are now 1 token
@@ -73,9 +77,13 @@ and_test: not_test ('and' not_test)*
not_test: 'not' not_test | comparison
comparison: expr (comp_op expr)*
comp_op: '<'|'>'|'='|'>='|'<='|'<>'|'!='|'=='|'in'|'not' 'in'|'is'|'is' 'not'
-expr: term (('+'|'-') term)*
+expr: xor_expr ('|' xor_expr)*
+xor_expr: and_expr ('^' and_expr)*
+and_expr: shift_expr ('&' shift_expr)*
+shift_expr: arith_expr (('<<'|'>>') arith_expr)*
+arith_expr: term (('+'|'-') term)*
term: factor (('*'|'/'|'%') factor)*
-factor: ('+'|'-') factor | atom trailer*
+factor: ('+'|'-'|'~') factor | atom trailer*
atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING
trailer: '(' [testlist] ')' | '[' subscript ']' | '.' NAME
subscript: test | [test] ':' [test]