grammar-kit | Recognition Grammar Toolkit for Julius : Instruction | Code Quality library
kandi X-RAY | grammar-kit Summary
kandi X-RAY | grammar-kit Summary
Recognition Grammar Toolkit for Julius: Instruction and Samples
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of grammar-kit
grammar-kit Key Features
grammar-kit Examples and Code Snippets
% NS_B
sil
% NS_E
sil
% HMM
FILLER f m
FILLER w eh l
% TAKE_V
I'lltake ay l t ey k
I'llhave ay l hh ar v
% PLEASE
please p l iy z
% FRUIT_N_1
apple ae p ax l
orange ao r ax n jh
orange ao r ix n jh
grape g r ey p
banana b ax n ae n a
% generate fruit
Reading in dictionary...
31 words...done
Reading in DFA grammar...done
Mapping dict item <-> DFA terminal (category)...done
Reading in term file (optional)...done
8 categories, 31 words
DFA has 10 nodes and 18 arcs
-----
FILL
% mkdfa.pl fruit
fruit.grammar has 8 rules
fruit.voca has 8 categories and 31 words
---
Now parsing grammar file
Now modifying grammar to minimize states[0]
Now parsing vocabulary file
Now making nondeterministic finite automaton[10/10]
Now making
Community Discussions
Trending Discussions on grammar-kit
QUESTION
I'm working on IntelliJ support for a DSL using the Grammar-Kit. I have a rule in the bnf file which requires an EOF (end of file) token at the end:
rule ::= ( object | (( LCURL EOL* properties EOL* RCURL ) | properties ) ) EOL* EOF
I assumed I can simpy create a lexer rule in the flex file <> { return EOF;}
and that's it..
Unfortunately somewhere deeper in the IntelliJ code the logic which handles lexer's advance()
method does not finish unless it gets a null from the lexer causing an infinite loop as the end of file returns a not-null token.
Is there any elegant (simple) way to handle an End Of File in the Grammar-Kit allowing the 'end of file' to be used in the Parser definition (the bnf)?
...ANSWER
Answered 2019-Jun-10 at 12:24In the end I've simply put an adapter between the generated lexer and its consumer which replaces functionality of the lexer's advance() method. If the EOF has been reached then the next time it will return null. Something like this:
QUESTION
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.
...ANSWER
Answered 2017-Aug-26 at 22:51Grammar-Kit is based on PEG (Parsing Expression Grammars).
- Positive lookahead:
&XXX
- Negative lookahead:
!XXX
QUESTION
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 for me to do syntax highlighting on.
If I create an IElementType
and tell flex to return that for comments, I can perform syntax highlighting, but then that token is not a part of my language spec in the BNF, and so it is considered invalid.
What is the correct way to pass comments through as white space, but perform syntax highlighting on them in Intellij/grammar-kit/jflex?
...ANSWER
Answered 2017-May-19 at 13:05You can use Grammar-Kit implementation as a reference:
Using TokenType.WHITE_SPACE
for comments is a bad idea.
More details can be found here.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install grammar-kit
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page