문제

I have a rule to match 'FOR "hi" FOR'

rule : id1=ELEMENT STRING id1
{
   // action
} 
 -> ^(Tree rule)

but it fails saying reference to undefined rule: id1 How can I reuse a label to ensure the start and end of the rule are the same identifier

도움이 되었습니까?

해결책

The recommended way to handle this is assume the values match while parsing, and then examine the AST after parsing is complete, issuing error messages at that time for any mismatched elements.

This approach results in a more robust parser and much much understandable error messages in the case of an wrote.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top