javacc笔记3

来源:互联网 发布:淘宝全球购是正品吗 编辑:程序博客网 时间:2024/05/01 22:02
void Input() :{}{  "a" BC() "c"}void BC() :{}{  "b" [ "c" ]}

有两种输出可能,如果:

void BC() :{}{  "b"  [ LOOKAHEAD( { getToken(1).kind == C && getToken(2).kind != C } )    <C:"c">  ]}

if (next token is "c" and following token is not "c") {  choose the nested expansion (i.e., go into the [...] construct)} else {  go beyond the [...] construct without entering it.}

rewritten 则:

void BC() :{}{  "b"  [ LOOKAHEAD( "c", { getToken(2).kind != C } )    <C:"c">  ]}