编写了路径控制脚本后,准备尝试编写一个比它稍微复杂一点的脚本,该脚本具有变量定义,流程控制语句,和比较完善的布尔逻辑和混合四则表达式运算的功能.
// Unnamed simple script language products define as the flowing:
program ::= declaration_list
declaration_list ::= var_declaration | fun_declaration
var_declaration ::= DECLARE type_specifier_list ID; END
type_specifier_list ::= type_specifier type_specifier_list | EMPTY
type_specifier ::= VAR
fun_declaration ::= BEGIN statement_list END
statement_list ::= statement statement_list | EMPTY
statement ::= expression_stmt | compund_list | selection_stmt | iteration_stmt
expression_stmt ::= expression; | ;
compund_list ::= { statement_list }
selection_stmt :: IF ( expression ) statement | IF ( expression ) statement ELSE statement
ireation_stmt ::= WHILE ( expression ) statement
expression ::= var = expression | simple_expression
var ::= ID
simple_expression ::= additive_expression relop additive_expression | additive_expression
relop ::= <= | < | > | >= | == | !=
additive_expression ::= additive_expression addop term | term
addop ::= + | -
term ::= term mulop factor | factor
mulop ::= * | /
factor ::= ( expression ) | var | NUM