Questions tagged [grammar-kit]

JetBrains IntelliJ IDEA plugin which adds BNF (Backus-Naur Form) Grammars and JFlex files editing support including parser/PSI code generator

31 questions
12
votes
1 answer

Pin & recoverWhile in a .bnf (Parsing)

I've searched the internet far and wide (for at least half a day now) and I can't seem to find the answers needed. Currently I'm trying to create a .bnf-file for an IntelliJ-Plugin with custom language support. A few tutorials mention the existance…
Fuchs
  • 133
  • 6
8
votes
1 answer

BNF Rule Syntax Highlighting for Custom Language

I'm trying to develop a custom language plugin for IntelliJ using the Grammar-Kit plugin. I am easily able to provide syntax highlighting for tokens defined, but I cannot figure out how to highlight at the element or token-parent level. Here's a…
pyrospade
  • 7,870
  • 4
  • 36
  • 52
7
votes
0 answers

Convert my .g4 to .flex and .bnf for IDEA syntax highlighter

I have never used JFlex before, and I have no idea how it works. Basically, I've built a runtime for a scheme-esque language in Java, and the parser I have for it was generated using Antlr 4, so I have a .g4 file, which looks like this: program:…
michaelsnowden
  • 6,031
  • 2
  • 38
  • 83
5
votes
1 answer

IntelliJ: Grammar-Kit / BNF: how to recover from errors?

I am writing a Custom Language plugin for IntelliJ. Here is a simplified example of the language. Note that the structure is recursive: I have successfully implemented the FLEX and BNF files, but I'm not sure how to add error recovery. I've read…
obe
  • 7,378
  • 5
  • 31
  • 40
5
votes
0 answers

How to exclude the comma operator from an expression in Grammar-Kit?

I'm writing an IntelliJ language plugin for a C-derived language which includes the comma operator. I'm using Grammar-Kit to generate the parser. Where the formal grammar has a lot of nested expression productions, I've rewritten them using…
Dan Hulme
  • 14,779
  • 3
  • 46
  • 95
4
votes
1 answer

Lexing The VHDL ' (tick) Token

In VHDL it the ' character can be used to encapsulate a character token ie '.' or it can as an attribute separator (similarish to CPP's :: token) ie string'("hello"). The issue comes up when parsing an attribute name containing a character ie…
DanChianucci
  • 1,175
  • 2
  • 11
  • 21
3
votes
1 answer

Re-write Parsing Expression Grammar (PEG) without left recursion

Using https://github.com/JetBrains/Grammar-Kit how to rewrite grammar without left recursion? grammar ::= exprs exprs::= (sum_expr (';')?)* private sum_expr::= sum_expr_infix | sum_expr_prefix sum_expr_infix ::= number sum_expr_prefix left…
okigan
  • 1,559
  • 2
  • 18
  • 33
2
votes
0 answers

Intellij Grammar Kit - indent based language

I'm creating a language using the Intellij IDEA Grammar-Kit plugin, and would like the blocks to be indent-based, rather than brace based. The only way I've found to do this so far is to use the <> function from…
SamG101
  • 488
  • 1
  • 7
  • 18
2
votes
0 answers

Grammar-kit tutorial? .bnf and .flex file instrcution?

I'm doing a plugin for other language, with Grammar-Kit. -> https://github.com/JetBrains/Grammar-Kit I'm not sure what .bnf and .flex files are responsible for? From my view, .bnf defines how operations in this language looks like: eg. assign value…
Fan Jia
  • 21
  • 2
2
votes
1 answer

Negative lookaheads in Grammar-Kit

Is there a way to do a negative lookahead in Grammar-kit? Example: I have two tokens defined A and B and would like the define the a rule that matches A if it is not followed by B. I tried to find it in this grammar, but I am not able to read it.
bbnkttp
  • 264
  • 1
  • 11
2
votes
1 answer

Grammar-Kit: how to handle comment tokens

From the documentation provided for grammar-kit, I cannot figure out how I am supposed to correctly handle something like comments. My lexer currently returns TokenType.WHITE_SPACE for any comment blocks, but then no unique IElementType is generated…
FatalCatharsis
  • 3,407
  • 5
  • 44
  • 74
1
vote
1 answer

How to deal with nested expressions in grammar kit?

I'm trying to write BNF file for my custom language intellij plugin. I'm getting confused with the rules for nested expressions. My custom language contains both binary operator expressions and array reference expressions. So I wrote the BNF file…
1
vote
1 answer

String and Character tokens in intellij grammar-kit BNF grammar not recognised in PSI preview mode

I am trying to develop a language plugin for intellij and am using the Grammar-Kit an PSI plugins as per the tutorial. I have developed a simple BNF-based grammar, but it does not work in PSI preview. The grammar is below: { …
Rem
  • 94
  • 6
1
vote
0 answers

How to wrap composite PsiElement on top of Lexer recognized elements in Grammar-Kit

I am new to intellij plugin writing. I started writing a intellij plugin for one of our custom language. I am following the tutorial given in intellij official site. Also I downloaded their Grammar-Kit repo from github to understand the code…
Subhojit
  • 11
  • 1
1
vote
1 answer

Method injection in GrammarKit plugin does not work

I am trying to override the getReference() method in some of my PsiElements by making methods in the PsiImplUtil class, but no methods get injected. Below is the element which needs the method (ValidNameExpr). I'm sure I'm just making a tiny mistake…
user
  • 7,435
  • 3
  • 14
  • 44
1
2 3