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