Java Grammar To Class声明

时间:2015-04-15 10:20:01

标签: java grammar

我正在阅读5月考试的过去的论文,我不确定如何回答以下问题:

The following grammar describes a simple language of arithmetic expressions:

exp -> lp exp rp | exp op exp | number
op -> plus | minus | times

The symbols, lp, rp, plus, minus and times refer to the lexemes (, ), +, - and *
respectively and the symbol number refers to any non-negative integer
Provide a declaration for a Java class that could be used to store parse trees for this
grammar. The methods of the class do not have to be declared.

我理解语法是什么,例如我可以使用加号,减号或次数作为运算符,我可以使用类似(5)的东西,即lp exp rp。把它转换成一个类丢失,这是我迷路的地方。我已经阅读了教学内容,这是非常轻松的。任何指导都会受到赞赏。

0 个答案:

没有答案