英文:
How to generate ANTLR recognizer again in Intellij after editing grammar
问题
我已经编写了一个用于旋转机器人的语法。
grammar RobotController;
// 解析器
program: statement+;
statement: rotateStatements;
rotateStatements: ROTATE (LPAREN direction RPAREN)? EOS;
direction: STRING;
// 词法分析器
ROTATE: 'rotate';
LPAREN: '(';
RPAREN: ')';
EOS: ';';
STRING: '"' (~[\r\n])* '"';
然后我创建了ANTLR识别器,它可以正常工作,生成了一些带有一些代码的Java文件。
后来,我修改了我的语法:
grammar RobotController;
// 解析器
program: statement+;
statement: rotateStatements;
rotateStatements: ROTATE EOS;
// 词法分析器
ROTATE: 'rotate';
EOS: ';';
现在,我再次创建ANTLR识别器,但之前生成的Java文件在系统中保持不变。没有添加新的代码。
有谁知道如何在修改语法后生成ANTLR识别器吗?
英文:
I have written a grammar to rotate a robot.
grammar RobotController;
//Parser
program: statement+;
statement: rotateStatements;
rotateStatements: ROTATE EOS;
//lexer
ROTATE: 'rotate';
EOS: ';';
Then i created ANTLR recognizer and it worked, It created some Java files with some code.
Later on I modified my grammar
to
grammar RobotController;
//Parser
program: statement+;
statement: rotateStatements;
rotateStatements: ROTATE (LPAREN direction RPAREN)? EOS;
direction: STRING;
//lexer
ROTATE: 'rotate';
LPAREN: '(';
RPAREN: ')';
EOS: ';';
STRING: '"' (~[\r\n])* '"';
Now I am creating ANTLR recognizer again but the previously generated Java files remain the same in the system. No new code is added to them.
Does anyone know how to generate ANTLR recognizer after modifying the grammar?
答案1
得分: 1
INFO:重新启动Intellij并清除缓存解决了这个问题。
英文:
INFO: Restarting Intellij and invalidating cache solved the problem
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论