下面这些句子有什么区别:
<stmt-list> ::= empty | <stmt> { <stmt> }
and
<stmt-list> ::= empty | <stmt> <stmt-list>
python中微小语言语法的解决方案是什么?
<stmt-list> ::= empty | <stmt> { <stmt> }
<stmt> ::= id = <expr> ; |
print <expr> ;
<expr> ::= <term> { + <term> | - <term> }
<term> ::= <factor> { * <factor> | / <factor> }
<factor> ::= id | intnum | ( <expr> )
我应该使用输入文件(sample.tiny)来获取输出。
小样本
print 2 + 3 * 4 ;
s = 2 + 3 ;
t = 9 - 2 ;
print s * t ;
print ( s + t ) * ( s - t ) ;
输出
print 2 + 3 * 4 ;
>>> 14
s = 2 + 3 ;
t = 9 - 2 ;
print s * t ;
>>> 35
print ( s + t ) * ( s - t ) ;
>>> -24