diff options
author | Guido van Rossum <guido@python.org> | 1993-05-19 14:50:45 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-05-19 14:50:45 (GMT) |
commit | 25831652fd4c03323066d4cafdc0551c396a993e (patch) | |
tree | 69588df0f98b3280402cad3ed95865d06fa21702 /Grammar | |
parent | 687dd13bfec51849c93db7c538ff41d4c8ecddcb (diff) | |
download | cpython-25831652fd4c03323066d4cafdc0551c396a993e.zip cpython-25831652fd4c03323066d4cafdc0551c396a993e.tar.gz cpython-25831652fd4c03323066d4cafdc0551c396a993e.tar.bz2 |
Several changes in one:
(1) dictionaries/mappings now have attributes values() and items() as
well as keys(); at the C level, use the new function mappinggetnext()
to iterate over a dictionary.
(2) "class C(): ..." is now illegal; you must write "class C: ...".
(3) Class objects now know their own name (finally!); and minor
improvements to the way how classes, functions and methods are
represented as strings.
(4) Added an "access" statement and semantics. (This is still
experimental -- as long as you don't use the keyword 'access' nothing
should be changed.)
Diffstat (limited to 'Grammar')
-rw-r--r-- | Grammar/Grammar | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/Grammar/Grammar b/Grammar/Grammar index 8464cf2..cb4bc27 100644 --- a/Grammar/Grammar +++ b/Grammar/Grammar @@ -2,6 +2,12 @@ # Change log: +# 19-May-93: +# Add access statement + +# 18-May-93: +# Abolish old class header syntax + # 06-Apr-92: # Use only '*' for varargs list @@ -81,7 +87,7 @@ fplist: fpdef (',' fpdef)* [','] stmt: simple_stmt | compound_stmt simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE -small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt +small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | access_stmt expr_stmt: (exprlist '=')* exprlist # For assignments, additional restrictions enforced by the interpreter print_stmt: 'print' (test ',')* [test] @@ -94,6 +100,11 @@ return_stmt: 'return' [testlist] raise_stmt: 'raise' test [',' test] import_stmt: 'import' NAME (',' NAME)* | 'from' NAME 'import' ('*' | NAME (',' NAME)*) global_stmt: 'global' NAME (',' NAME)* +access_stmt: 'access' NAME (',' NAME)* ':' accesstype (',' accesstype)* +accesstype: NAME+ +# accesstype should be ('public' | 'protected' | 'private') ['read'] ['write'] +# but can't be because that would create undesirable reserved words! + compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] while_stmt: 'while' test ':' suite ['else' ':' suite] @@ -122,9 +133,4 @@ exprlist: expr (',' expr)* [','] testlist: test (',' test)* [','] dictmaker: test ':' test (',' test ':' test)* [','] -# New class syntax should be: -# classdef: class NAME ['(' testlist ')'] ':' suite -# but merged with old syntax for compatibility it becomes: -classdef: 'class' NAME ['(' testlist ')' |'(' ')' ['=' baselist]] ':' suite -baselist: atom arguments (',' atom arguments)* -arguments: '(' ')' +classdef: class NAME ['(' testlist ')'] ':' suite |