antlr / antlr/jetbrains-plugin-sample
Adding new custom keywords leads to errors
- Dominant language
- Java
- Stars
- 120
- Forks
- 35
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
Today I have been trying to use this plugin to create a new language for a JetBrains product.
I however can't extend the plugin with new keywords.
I keep getting errors such as:


While the ANTLR preview works just fine:

I have tried to add a block keywords (e.g. 'class') that works very similar to a func definition:
```g4
script
: vardef* define_class* function* statement* EOF
;
define_class
: 'class' ID block
;
// ...
CLASS : 'class' ;
```
---
And I have tried to copy the `print()` definition to `log()`, which also leads to errors in the IDE (but not in the preview):


```g4
| 'print' '(' expr? ')' # Print
| 'log' '(' expr? ')' # Log
// ...
PRINT : 'print' ;
LOG : 'log' ;
```
---
When replacing print with log, it does work:

---
I have tried editing and copying Java files/classes and cases/rules to match my new keywords, but this did not help at all.
What am I missing/supposed to be doing in order to create new keywords?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the errors in the JetBrains IDE with the shown grammar changes and compare them with the working ANTLR preview. Then inspect the Java files/classes and cases/rules involved in the sample plugin; the issue is done when distinct keywords such as class and log work in the IDE without errors, as they do in the preview.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100