mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
disabled recursive debugging outputs for testing
This commit is contained in:
parent
ebef309674
commit
a83e3627cc
3 changed files with 38 additions and 13 deletions
|
@ -8,13 +8,25 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.parser.antlr.hoisting;
|
||||
|
||||
import org.eclipse.xtext.Grammar;
|
||||
|
||||
/**
|
||||
* @author overflow - Initial contribution and API
|
||||
*/
|
||||
public class HoistingConfiguration {
|
||||
private final int tokenLimit = 10;
|
||||
private boolean debug = false;
|
||||
|
||||
public HoistingConfiguration(Grammar grammar) {
|
||||
// TODO: get config options from ecore object
|
||||
}
|
||||
|
||||
public int getTokenLimit() {
|
||||
return tokenLimit;
|
||||
}
|
||||
|
||||
public boolean isDebug() {
|
||||
return debug;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -72,10 +72,11 @@ public class HoistingProcessor {
|
|||
|
||||
private Logger log = Logger.getLogger(this.getClass());
|
||||
|
||||
private HoistingConfiguration config = new HoistingConfiguration();
|
||||
private HoistingConfiguration config;
|
||||
private TokenAnalysis analysis;
|
||||
|
||||
public void init(Grammar grammar) {
|
||||
config = new HoistingConfiguration(grammar);
|
||||
analysis = new TokenAnalysis(config, grammar);
|
||||
}
|
||||
|
||||
|
@ -295,9 +296,13 @@ public class HoistingProcessor {
|
|||
// this is very inefficient
|
||||
log.warn("nested prefix alternatives detected");
|
||||
log.warn("avoid these since they can't be handled efficiently");
|
||||
|
||||
if (config.isDebug())
|
||||
log.info(abstractElementToString(alternatives));
|
||||
|
||||
CompoundElement flattened = flattenPaths(alternatives, paths, guards);
|
||||
|
||||
if (config.isDebug())
|
||||
log.info(abstractElementToString(flattened));
|
||||
|
||||
log.info(flattened.getElements().size());
|
||||
|
@ -485,6 +490,7 @@ public class HoistingProcessor {
|
|||
}
|
||||
|
||||
public HoistingGuard findHoistingGuardIgnoreCardinality(AbstractElement element) {
|
||||
if (config.isDebug())
|
||||
log.info("hoisting (trivial) guard of: \n" + abstractElementToString(element));
|
||||
// should only be called for valid AST elements, so element can never be floating
|
||||
|
||||
|
@ -497,7 +503,9 @@ public class HoistingProcessor {
|
|||
}
|
||||
|
||||
public HoistingGuard findHoistingGuard(AbstractElement element) {
|
||||
if (config.isDebug())
|
||||
log.info("hoisting guard of: \n" + abstractElementToString(element));
|
||||
|
||||
// should only be called for valid AST elements, so element can never be floating
|
||||
return findGuardForElement(element, containingParserRule(element));
|
||||
}
|
||||
|
@ -515,6 +523,7 @@ public class HoistingProcessor {
|
|||
}
|
||||
|
||||
private HoistingGuard findGuardForElementWithTrivialCardinality(AbstractElement element, AbstractRule currentRule) {
|
||||
if (config.isDebug())
|
||||
log.info(currentRule.getName() + ": " + abstractElementToShortString(element));
|
||||
|
||||
if (element instanceof Alternatives) {
|
||||
|
|
|
@ -388,12 +388,13 @@ public class TokenAnalysis {
|
|||
}
|
||||
|
||||
private boolean arePathsIdenticalFallback(AbstractElement path1, AbstractElement path2) {
|
||||
// + 1, because otherwise identical paths of length token limit can't be checked
|
||||
|
||||
if (config.isDebug()) {
|
||||
log.info("path1: " + abstractElementToString(path1));
|
||||
log.info("path2: " + abstractElementToString(path2));
|
||||
}
|
||||
|
||||
int i;
|
||||
// + 1, because otherwise identical paths of length token limit can't be checked
|
||||
int limit = config.getTokenLimit() + 1;
|
||||
for (i = 0; i < limit; i++) {
|
||||
TokenAnalysisPaths tokenPaths1;
|
||||
|
@ -525,9 +526,12 @@ public class TokenAnalysis {
|
|||
.map(p -> (List<List<Token>>) null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
if (config.isDebug()) {
|
||||
paths.forEach(p -> {
|
||||
log.info("\n" + abstractElementToString(p));
|
||||
});
|
||||
}
|
||||
|
||||
tokenCombinations(indexList -> {
|
||||
log.info("current index list: " + indexList);
|
||||
|
|
Loading…
Reference in a new issue