This commit is contained in:
Calum Grant
2024-05-20 08:49:19 +01:00
parent 89738825ac
commit 8938cd0db8
2 changed files with 24 additions and 2 deletions

View File

@@ -426,11 +426,16 @@ module GLR<grammar/0 g> {
result = "There are " + sr + " shift/reduce conflicts and " + rr + " reduce/reduce conflicts."
)
}
// This should be empty
predicate debugStates(State state1, Symbol s) {
count(state1.getTransition(s))>1
}
}
// Just some debugging information needed to quickeval predicates in modules
string test_input(int i) { result = "I+I".charAt(i) }
string test_input(int i) { result = "I+I-I".charAt(i) }
string test_grammar() { result = ["G -> E", "E -> E + E", "E -> I"] }
string test_grammar() { result = ["G -> E", "E -> E + I", "E -> E - I", "E -> I"] }
module DebugContext = GLR<test_grammar/0>::GLRparser<test_input/1>;

View File

@@ -0,0 +1,17 @@
import glr
string grammar4() {
result = ["G -> E", "E -> E + I", "E -> E - I", "E -> I"]
}
string input4(int i) { result = "I+I-I".charAt(i) }
module Test4 = GLR<grammar4/0>::GLRparser<input4/1>;
query string conflicts() { result = GLR<grammar4/0>::conflicts() }
query int syntax_error() { result = Test4::syntax_error_position() }
from Test4::ParseNode parent, int i, Test4::ParseNode child
where Test4::tree(parent,i,child)
select parent, i, child