Comments (5)
I think the error is because MULT
/HEXDIGIT
et al. don't appear in the grammar itself. However, the error is definitely confusing because the %epp
is suppressing the better error message. If I get rid of the %epp
lines I get this:
Warning: these tokens are defined in the lexer but not referenced in the
grammar:
DIGIT
GT
GTEQ
HEX
HEXDIGIT
HEXDIGITS
LT
LTEQ
MULT
SPACE
Error: these tokens are referenced in the grammar but not defined in the lexer:
GREATER
GREATEREQUAL
HASH
LESS
LESSEQUAL
SLASH
STAR
from grmtools.
this is the error(s) I got, each run can yield different errors lol
Hmm, I knew this was the case with error recovery that it's errors were non-deterministic, but I wasn't aware of it in a case such as this. One other thing we could look at here is whether we should try and emit both the %epp
errors, and the 'unreferenced in the lexer/grammar' warnings here. When I was adding output of multiple errors, I was somewhat conservative in that I was trying to avoid adding new cascading failures.
from grmtools.
One other thing we could look at here is whether we should try and emit both the %epp errors, and the 'unreferenced in the lexer/grammar' warnings here
This would definitely be good, but it's definitely some work.
from grmtools.
I think the error is because
MULT
/HEXDIGIT
et al. don't appear in the grammar itself. However, the error is definitely confusing because the%epp
is suppressing the better error message. If I get rid of the%epp
lines I get this:Warning: these tokens are defined in the lexer but not referenced in the grammar: DIGIT GT GTEQ HEX HEXDIGIT HEXDIGITS LT LTEQ MULT SPACE Error: these tokens are referenced in the grammar but not defined in the lexer: GREATER GREATEREQUAL HASH LESS LESSEQUAL SLASH STAR
@ltratt Thank you sir for your response.
For the first error,
> Warning: these tokens are defined in the lexer but not referenced in the
> grammar:
> DIGIT
How can show me how can I define DIGIT
in tinylang.l
since it is a regex? The Java7
example wasn't helpful to me. Thank you.
from grmtools.
How can show me how can I define
DIGIT
intinylang.l
since it is a regex? TheJava7
example wasn't helpful to me. Thank you.
These errors are a bit difficult to give general repair advice about. Here tinylang.l
produces a token DIGIT
, but the parser has no rules for how to consume one, comparing the linked lexer definitions:
[0-9] "DIGIT"
[0-9]+ "DIGITS"
Here, we have inlined the usage of DIGIT
on the left hand side, in the original this was
digit [0-9]
{digit}+ return tinylang::Parser::token::T_integer_literal;
While doing so we have added to the lexer the ability to produce the DIGIT
token, it may never produce such a token depending on match precedence. But this token never existed in the original tinylang.l
, and has nothing in tinylang.yy
which prepares the parser to consume it, subsequently the lexer could produce a token which the parser does not expect.
So in this case I believe it makes sense to just remove the [0-9] "DIGIT"
rule from the lexer. But in general the solution for either of these types of errors could involve modifying either or both of the lex
and yacc
files. E.g. when I typo the token in both.
hope that helps.
from grmtools.
Related Issues (20)
- %ignore like in flex HOT 8
- Is it possible to perform side effects while parsing? HOT 3
- Would be nice to have an online playground HOT 8
- Order of execution of grammar statements? HOT 7
- Bug in grmtools documentation - traits not displaying required method names HOT 12
- Is there a way to avoid global variables for compile time data structures? HOT 5
- Request for example of handling string literals in lexer HOT 2
- error when using fake UMINUS token in %prec directive HOT 9
- GDB Support? HOT 5
- Add support for comments in lrlex files HOT 3
- Explain why Copy is required for a type specified %parse-param HOT 7
- Nondeterministic generation of Rust code HOT 2
- Support lex-style definitions HOT 1
- Weird that `nimbleparse` works on `java7.y` `java7.l` even though the `GT` symbol in both is different. HOT 1
- Online Yacc/Lex editor/tester HOT 6
- Detailed debug info for reduce/reduce shift/reduce errors? HOT 27
- Docs Question - Optional Prefix to Regular Expressions HOT 5
- lrpar lose info about debug HOT 7
- nimbleparse:Suggestions for outputting information HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grmtools.