How can i disable backtracking ? [message #1801151] |
Mon, 14 January 2019 16:52  |
Eclipse User |
|
|
|
I thought that using the code mentioned below in mwe2 code the backtracking will be disabled.
But after debugging the InternalDSLParser class in antlr.internal package, i found that state.backtrack = 2
And i found this comment in RecognizerSharedState class :
/** If 0, no backtracking is going on. Safe to exec actions etc...
* If >0 then it's the level of backtracking.
*/
public int backtracking = 0;
so backtrack is enabled, right?
how can i disable it?
mew2 file :
fragment = parser.antlr.ex.rt.AntlrGeneratorFragment {
options = {
backtrack = false
classSplitting = true
fieldsPerClass = "500"
ignoreCase = true
//kAsString="1"
memoize=true
}
}
fragment = org.eclipse.xtext.generator.parser.antlr.ex.ca.ContentAssistParserGeneratorFragment {
options ={
backtrack = false
classSplitting = true
fieldsPerClass = "500"
memoize=true
ignoreCase = true
//kAsString="5"
}
}
|
|
|
|
Re: How can i disable backtracking ? [message #1801158 is a reply to message #1801153] |
Mon, 14 January 2019 17:17   |
Eclipse User |
|
|
|
by debugging in InternalDSLParser.java i found that state.backtracking = 2 not zero
so i think there is something i am missing in disabling the backtracking
I know that zero means no backtracking but the value is not equal to zero!!
public final EObject entryRuleprimary() throws RecognitionException {
EObject current = null;
int entryRuleprimary_StartIndex = input.index();
EObject iv_ruleprimary = null;
try {
if ( state.backtracking>0 && alreadyParsedRule(input, 409) ) { return current; }
[Updated on: Mon, 14 January 2019 17:18] by Moderator Report message to a moderator
|
|
|
|
Re: How can i disable backtracking ? [message #1801162 is a reply to message #1801160] |
Mon, 14 January 2019 18:11   |
Eclipse User |
|
|
|
that what i am asking about, is there is something known in xtext that will enable the backtracking and i wrote it by mistake given that i disabled it in mwe2?
are you sure that if "state.backtracing" variable in InternalDSLParser class equals 2 means that backtracking is enabled?
|
|
|
|
Re: How can i disable backtracking ? [message #1801170 is a reply to message #1801164] |
Mon, 14 January 2019 20:02   |
Eclipse User |
|
|
|
Yes i am suffering from performance problem, and i am really frustrated because i think i am disabling backtracking while its seems its enabled.
the comment in the code is clear,since backtracking variable is not equal zero so it means i am enabling backtracking.
Do you know how to disable it?
|
|
|
|
|
|
|
Re: How can i disable backtracking ? [message #1801224 is a reply to message #1801177] |
Tue, 15 January 2019 15:46   |
Eclipse User |
|
|
|
I found the modification in state.baacktracking happens in functions with this name
public final boolean synpred27_InternalDSLParser() {
state.backtracking++;
int start = input.mark();
try {
synpred27_InternalDSLParser_fragment(); // can never throw exception
} catch (RecognitionException re) {
System.err.println("impossible: "+re);
}
boolean success = !state.failed;
input.rewind(start);
state.backtracking--;
state.failed=false;
return success;
}
also it happens in many functions start with the same prefix "synpred".
Do you know what does it means?
[Updated on: Tue, 15 January 2019 15:50] by Moderator Report message to a moderator
|
|
|
|
|
|
Re: How can i disable backtracking ? [message #1861604 is a reply to message #1801239] |
Sat, 21 October 2023 21:18  |
Eclipse User |
|
|
|
I don't know how this tale turned out in the end, but I just banged my head against a very similar problem where my backtracking setting had no effect.
After hours of debugging I realized that further down in my MWE2 configuration there was another parserGenerator = {debugGrammar=true} entry that overwrote the parser generator configuration that enabled the backtracking.
So keep in mind that there is no checking for duplicate entries, and that entries further down apparently overwrite earlier entries (so there is no merging of configurations either; this is as of Xtext 2.30/MWE2 2.14, not sure if this was fixed in the meantime).
|
|
|
Powered by
FUDForum. Page generated in 0.04974 seconds