How to implement JavaScript/ECMAScript “no LineTerminator here” rule in JavaCC?

后端 未结 2 871
一整个雨季
一整个雨季 2021-01-22 02:23

I continue working on my JavaCC grammar for ECMAScript 5.1. It actually goes quite well, I think I\'ve covered most of the expressions now.

I have now two questions, bot

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-22 03:03

    I think for the "restricted productions" you can do this

    void PostfixExpression() : 
    {} {
         LeftHandSideExpression() 
         (
             LOOKAHEAD( "++", {getToken(0).beginLine == getToken(1).beginLine})
             "++"
         |
             LOOKAHEAD( "--", {getToken(0).beginLine == getToken(1).beginLine})
             "--"
         |
             {}
         )
    }
    

提交回复
热议问题