2

ＥＢＮＦ如下，但bfactor不知道怎么推导，选(bool-exp)还是(comparison-exp)?

stmt-sequence -> statement { ; statement }

statement -> if-stmt | repeat-stmt | assign-stmt | read-stmt | write-stmt | while-stmt

while-stmt -> while bool-exp do stmt-sequence end

if-stmt -> if bool-exp then stmt-sequence [else stmt-sequence] end

repeat-stmt -> repeat stmt-sequence until bool-exp

assign-stmt -> identifier:=exp

write-stmt -> write exp

exp -> arithmetic-exp | bool-exp | string-exp| comparison-exp

comparison-exp -> arithmetic-exp comparison-op arithmetic-exp

comparison-op -> < | = | > | >= | <=

arithmetic-exp -> term { addop term }

term -> factor { mulop factor }

mulop -> * | /

factor -> (arithmetic-exp) | number | identifier

bool-exp -> bterm { or bterm }

bterm -> bfactor { and bfactor}

bfactor -> true | false | identifier | (bool-exp) | not bfactor | (comparison-exp)

string-exp -> string | identifier

<无标签>

xiangxw

#### 引用来自#2楼“JackPhone”的帖子

bool-exp 是与、或运算，如：1 and 2

comparison-exp 是比较运算，如：1>=2

bool-exp -> bterm { or bterm }

comparison-exp -> arithmetic-exp comparison-op arithmetic-exp