, if . , IF- . .
a) BNF. , if
ifstmnt ::= IF <condiftion> THEN <trueblock> [ ELSE <elseblock> ]
statment ::= ifstmnt | assignstment | whilestmnt | forstmnt
..
b) , . IF , THEN.
c) getNextToken, , . - - IF, THEN, A number, . , , . , , - . .
d) , . IF, , , , .. , . , , AND, OR .., THEN. THEN , , IF recoogniser , THEN, ( BEGIN, END).
e) - , trueblock, falseblock . - . .
f) , , ,
g) - , - . , , - . , . .
Check out YACC and LEX. These are tools designed to complete individual parts of a task and save you time. Terms that will help your research are “lexical analysis”, “parser” and the like.
And good luck. Your project is non-trivial!
See also http://nedbatchelder.com/text/python-parsers.html
source
share