如何在Intellij中在编辑语法后再次生成ANTLR识别器。

huangapple go评论76阅读模式
英文:

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

huangapple
  • 本文由 发表于 2020年9月12日 06:52:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/63855236.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定