Python 1.0.1: a snapshot of history, and how programming languages grow

Python 1.0.1: a snapshot of history, and how programming languages grow

the goal of the post is not to be exaustive but just list some changes in the grammer of the language, and to do so we need to go back to a really early version of python

This post will be a little more advanced than my normal ones.

But the message I'm makes can be applied broadly.

Prerequisite for this post:

- familiar with python

- know what programming grammers are

- are familiar with how programming langs are designed

python 1.0.1

Lets have a look at the grammer file

Index of /ftp/python/src/

Here is the whole grammer deffintion

this file was created: 1993-12-20

Take note of how short it is its only 62 lines of actual grammer rules

I was supprised to learn that lambda's are actually a really old feature!

nearly.js grammer version of python 1.0.1's grammer file

@builtin "number.ne"
@builtin "whitespace.ne"
@builtin "string.ne"
main -> atom
#single_input -> NEWLINE | simple_stmt | compound_stmt NEWLINE
# file_input -> (NEWLINE | stmt)* ENDMARKER
# eval_input -> testlist NEWLINE* ENDMARKER
# 
# funcdef -> 'def' NAME parameters ':' suite
# parameters -> '(' [varargslist] ')'
# varargslist -> (fpdef ',')* '*' NAME | fpdef (',' fpdef)* [',']
# fpdef -> NAME | '(' fplist ')'
# 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 | access_stmt | exec_stmt
# expr_stmt -> (testlist '=')* testlist
# 
# print_stmt -> 'print' (test ',')* [test]
# del_stmt -> 'del' exprlist
# pass_stmt -> 'pass'
# flow_stmt -> break_stmt | continue_stmt | return_stmt | raise_stmt
# break_stmt -> 'break'
# continue_stmt -> 'continue'
# 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+
# 
# exec_stmt -> 'exec' expr ['in' test [',' test]]
# 
#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]
# for_stmt -> 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
# try_stmt -> 'try' ':' suite (except_clause ':' suite)+ | 'try' ':' suite 'finally' ':' suite
# 
# except_clause -> 'except' [test [',' test]]
#suite -> simple_stmt | NEWLINE INDENT stmt+ DEDENT
# 
##test -> and_test ('or' and_test)* | lambdef
#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 -> 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*
#atom -> '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING
atom ->  NAME# | NUMBER | STRING

#lambdef -> 'lambda' [varargslist] ':' test
#trailer -> '(' [testlist] ')' | '[' subscript ']' | '.' NAME
#subscript -> test | [test] ':' [test]
#exprlist -> expr (',' expr)* [',']
#testlist -> test (',' test)* [',']
#dictmaker -> test ':' test (',' test ':' test)* [',']
# 
# classdef -> 'class' NAME ['(' testlist ')'] ':' suite
#DEDENT -> 
NEWLINE -> [\n]
NUMBER -> %decimal  
STRING -> %dqstring 
NAME -> [a-zA-z]:+
\
Index of /ftp/python/src/
A Brief Timeline of Python
The development of Python occurred at a time when many other dynamic (and open-source) programming languages such as Tcl, Perl, and (much la...

Author

by oran collins
github.com/wisehackermonkey

If you want to help me out and give some donations here's my monero address: 432ZNGoNLjTXZHz7UCJ8HLQQsRGDHXRRVLJi5yoqu719Mp31x4EQWKaQ9DCQ5p2FvjQ8mJSQHbD9WVmFNhctJsjkLVHpDEZ I use a tracker that is pravicy focused so if you block its cool, im big on blocking stuff on my own machine. im doing it to see if anyone is actualy reading my blog posts...:)