Comments (7)
I'll check this out this weekend
from bison.
@Xaec6 Would you have a look at this issue?
from bison.
So what's happening here is the identical conflicts are coming from different states. FWIW, the 'warning: 4 shift/reduce conflicts' includes 1, 2, 4, 5. @akimd the conflicts counter is considering 2,3 and 5,6 to be the duplicates here because it doesn't differentiate between different s/r conflicts on the same token. I guess it's up to you which component should change its behavior so they match.
As for this duplicate, perhaps we change
cmDependsJavaParser.y: warning: shift/reduce conflict on token jp_DOT [-Wcounterexamples]
to
cmDependsJavaParser.y: warning: shift/reduce conflict on token jp_DOT in state 475 [-Wcounterexamples]
so it's more obvious these are different. While I could also add some logic to not report duplicates, it would frequently cause the number of counterexamples reported to be lower than the s/r conflict count which would be confusing.
from bison.
Thanks for looking into this - adding the state as you show looks good to me - couple suggestions to improve the output
- report total and duplicate/unique counts
- mark duplicate counterexamples somehow
On the face of it it looks like the duplicates are (2, 5) and (3, 6) - so I'm surprised you found (2, 3) and (5, 6) as duplicates
from bison.
@Xaec6 Thanks a lot for having looked at this into more details. I'm sorry I took so long to answer, but I think I needed a break.
I don't want to report state numbers in the diagnostics, IMHO that's really something that make only sense in the reports. I do agree that this situation is annoying though, and I definitely would like the "duplicate" counterexamples to not be displayed (I don't think it helps to see it several times. After all it is the same set of rules that have the same problem, but in some "duplicate subautomaton"). Maybe we should report when a counterexample applies for several conflicts, something like
cmDependsJavaParser.y: warning: shift/reduce conflict on token jp_DOT (in 2 states) [-Wcounterexamples]
Example: jp_THIS • jp_DOT Identifier
[...]
or (I prefer this one):
cmDependsJavaParser.y: warning: 2 shift/reduce conflicts on token jp_DOT [-Wcounterexamples]
Example: jp_THIS • jp_DOT Identifier
[...]
I had never realized (or I forgot) that we were counting multiple S/R conflicts in the same place as a single one. It would definitely make sense to count each conflict, but I'm afraid we can't change that, given that some people might be relying on this fact in their %expect
requirements. That would break compatibility. I have no idea if some people do indeed rely on the current situation though.
We might have a way out by implementing both ways of counting, and enabling the new one only when %require "3.8"
(or better) is enabled. And in a distant future, we might phase out the old way to counting.
from bison.
Hi @zmajeed
On the face of it it looks like the duplicates are (2, 5) and (3, 6) - so I'm surprised you found (2, 3) and (5, 6) as duplicates
Vincent is referring to something else. 2 and 5 are indeed "twice the same counterexample", but 2 and 3 are actually two SR conflicts in the same state-and-lookahead, and are counted as a single contribution to the overall number of conflicts. That's why the report is about "4 shift/reduce conflicts", and not 6.
I'm not sure what the cutest grammar to show this phenomenon would be, but the following one does it:
$ cat foo.y
%%
exp: a 'x' | 'x'
a: 'x' |
$ LC_ALL=C ∫ foo.y -Wcex
foo.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
foo.y: warning: shift/reduce conflict on token 'x' [-Wcounterexamples]
Example: . 'x'
Shift derivation
exp
`-> . 'x'
Example: . 'x'
Reduce derivation
exp
`-> a 'x'
`-> .
foo.y: warning: shift/reduce conflict on token 'x' [-Wcounterexamples]
First example: 'x'
Shift derivation
exp
`-> 'x'
Second example: 'x'
Reduce derivation
exp
`-> 'x'
foo.y:3.9: warning: rule useless in parser due to conflicts [-Wother]
3 | a: 'x' |
| ^
from bison.
Thanks for elaborating Akim - I think I understand the difference between duplicate counterexamples and two SR conflicts being counted as one - I'll need to go back to the states report to really figure this out
As for the changes you propose I too prefer the second suggestion "2 shift/reduce conflicts on token" - I can see why state numbers should not be referenced outside of the report itself since there's nothing tying the counterexamples output to the states report - also this format calls out duplicate counterexamples - and the multiplicity allows both unique and duplicate counts to be calculated
from bison.
Related Issues (20)
- Escaping dollar sign in a rule action
- Associating %prec with a rule without any occurrences of tokens
- [TC] Problem: Bad Variant Access errors are not explicit
- Request for latest release HOT 9
- Hello, if I want to print the full string content of the current child node, what do I need to do
- How to make the glr parser support multi-threading.
- question
- Cannot use C++ multiline raw strings in grammar file
- Compilation error: No rule to make target 'textstyle.h' HOT 2
- 3.8.2 testsuite segfault on armv6 HOT 3
- D skeleton file breaks recent D compilers with example code from manual HOT 6
- yynerrs unused-but-set-variable warning with Clang 15 HOT 2
- Can't build with conan, using clang compiler, having dependencies as shared libs HOT 4
- [BUG] reachable assertation in string_decode, bison HOT 1
- [BUG] abitset_set is reachable by crafted input, which cause the program abort HOT 1
- How to remove entries from the token list at runtime / from being passed to yysyntax_error? HOT 1
- [NonFetal Error]: use-of-uninitialized-value in bison(version 3.8.2.45, commit 25b3d0e1)
- No example code in the C++ examples HOT 2
- make fails HOT 9
- git shallow clone - error: Server does not allow request for unadvertised object - git.sv.gnu.org - git.savannah.gnu.org
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 bison.