mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
removed java code delimiters
This commit is contained in:
parent
aae59c9805
commit
7154bf276c
6 changed files with 31 additions and 29 deletions
|
@ -335,10 +335,7 @@ abstract class AbstractAntlrGrammarGenerator {
|
|||
protected dispatch def String dataTypeEbnf2(AbstractElement it, boolean supportActions) '''ERROR «eClass.name» not matched'''
|
||||
|
||||
protected dispatch def String dataTypeEbnf2(Alternatives it, boolean supportActions) '''
|
||||
// «elements.size»
|
||||
«FOR e:elements SEPARATOR '\n |'»
|
||||
// «e.toString»
|
||||
«e.findGuardForElement.renderPredicate»«e.dataTypeEbnf(supportActions)»«ENDFOR»
|
||||
«FOR e:elements SEPARATOR '\n |'»«e.findGuardForElement.renderPredicate»«e.dataTypeEbnf(supportActions)»«ENDFOR»
|
||||
'''
|
||||
|
||||
protected dispatch def String dataTypeEbnf2(Group it, boolean supportActions) '''
|
||||
|
@ -360,10 +357,7 @@ abstract class AbstractAntlrGrammarGenerator {
|
|||
protected dispatch def String ebnf2(AbstractElement it, AntlrOptions options, boolean supportActions) '''ERROR «eClass.name» not matched'''
|
||||
|
||||
protected dispatch def String ebnf2(Alternatives it, AntlrOptions options, boolean supportActions) '''
|
||||
// «elements.size»
|
||||
«FOR element:elements SEPARATOR '\n |'»
|
||||
// «element.toString»
|
||||
«element.findGuardForElement.renderPredicate»«element.ebnf(options, supportActions)»«ENDFOR»
|
||||
«FOR element:elements SEPARATOR '\n |'»«element.findGuardForElement.renderPredicate»«element.ebnf(options, supportActions)»«ENDFOR»
|
||||
'''
|
||||
|
||||
protected dispatch def String ebnf2(Group it, AntlrOptions options, boolean supportActions) '''
|
||||
|
@ -383,7 +377,7 @@ abstract class AbstractAntlrGrammarGenerator {
|
|||
}
|
||||
|
||||
protected dispatch def String ebnf2(AbstractSemanticPredicate it, AntlrOptions options, boolean supportActions) '''
|
||||
{«it.code.source»}?=>
|
||||
{«JavaCodeUtils.getSource(it.code)»}?=>
|
||||
'''
|
||||
|
||||
protected def String ebnf(Keyword it) {
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2021 itemis AG (http://www.itemis.eu) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.generator.parser.antlr;
|
||||
|
||||
import org.eclipse.xtext.JavaCode;
|
||||
|
||||
/**
|
||||
* @author overflow - Initial contribution and API
|
||||
*/
|
||||
public class JavaCodeUtils {
|
||||
static public String getSource(JavaCode code) {
|
||||
String source = code.getSource();
|
||||
return source.substring(2, source.length() - 2);
|
||||
}
|
||||
}
|
|
@ -200,7 +200,9 @@ public class HoistingProcessor {
|
|||
return getTokenForIndexesAlternatives((Alternatives) path, prefix, needsLength);
|
||||
} else if (path instanceof Group) {
|
||||
return getTokenForIndexesGroup((Group) path, prefix, needsLength);
|
||||
} else if (path instanceof Action) {
|
||||
} else if (path instanceof Action ||
|
||||
path instanceof AbstractSemanticPredicate
|
||||
) {
|
||||
// TODO: make sure empty token analysis paths don't cause problems down the line
|
||||
return TokenAnalysisPaths.empty();
|
||||
} else {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
package org.eclipse.xtext.xtext.generator.parser.antlr.hoisting;
|
||||
|
||||
import org.eclipse.xtext.AbstractSemanticPredicate;
|
||||
import org.eclipse.xtext.xtext.generator.parser.antlr.JavaCodeUtils;
|
||||
|
||||
/**
|
||||
* @author overflow - Initial contribution and API
|
||||
|
@ -28,7 +29,7 @@ public class PredicateGuard implements HoistingGuard {
|
|||
|
||||
@Override
|
||||
public String render() {
|
||||
return element.getCode().getSource();
|
||||
return JavaCodeUtils.getSource(element.getCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,7 +11,6 @@ package org.eclipse.xtext.xtext.generator.parser.antlr.hoisting;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.xtext.AbstractElement;
|
||||
|
|
|
@ -50,6 +50,7 @@ import org.eclipse.xtext.xtext.generator.parser.antlr.AntlrGrammarGenUtil;
|
|||
import org.eclipse.xtext.xtext.generator.parser.antlr.AntlrOptions;
|
||||
import org.eclipse.xtext.xtext.generator.parser.antlr.CombinedGrammarMarker;
|
||||
import org.eclipse.xtext.xtext.generator.parser.antlr.GrammarNaming;
|
||||
import org.eclipse.xtext.xtext.generator.parser.antlr.JavaCodeUtils;
|
||||
import org.eclipse.xtext.xtext.generator.parser.antlr.KeywordHelper;
|
||||
import org.eclipse.xtext.xtext.generator.parser.antlr.TerminalRuleToLexerBody;
|
||||
import org.eclipse.xtext.xtext.generator.parser.antlr.hoisting.HoistingProcessor;
|
||||
|
@ -806,10 +807,6 @@ public abstract class AbstractAntlrGrammarGenerator {
|
|||
|
||||
protected String _dataTypeEbnf2(final Alternatives it, final boolean supportActions) {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("// ");
|
||||
int _size = it.getElements().size();
|
||||
_builder.append(_size);
|
||||
_builder.newLineIfNotEmpty();
|
||||
{
|
||||
EList<AbstractElement> _elements = it.getElements();
|
||||
boolean _hasElements = false;
|
||||
|
@ -819,10 +816,6 @@ public abstract class AbstractAntlrGrammarGenerator {
|
|||
} else {
|
||||
_builder.appendImmediate("\n |", "");
|
||||
}
|
||||
_builder.append("// ");
|
||||
String _string = e.toString();
|
||||
_builder.append(_string);
|
||||
_builder.newLineIfNotEmpty();
|
||||
String _renderPredicate = this._hoistingProcessor.findGuardForElement(e).renderPredicate();
|
||||
_builder.append(_renderPredicate);
|
||||
String _dataTypeEbnf = this.dataTypeEbnf(e, supportActions);
|
||||
|
@ -886,10 +879,6 @@ public abstract class AbstractAntlrGrammarGenerator {
|
|||
|
||||
protected String _ebnf2(final Alternatives it, final AntlrOptions options, final boolean supportActions) {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("// ");
|
||||
int _size = it.getElements().size();
|
||||
_builder.append(_size);
|
||||
_builder.newLineIfNotEmpty();
|
||||
{
|
||||
EList<AbstractElement> _elements = it.getElements();
|
||||
boolean _hasElements = false;
|
||||
|
@ -899,10 +888,6 @@ public abstract class AbstractAntlrGrammarGenerator {
|
|||
} else {
|
||||
_builder.appendImmediate("\n |", "");
|
||||
}
|
||||
_builder.append("// ");
|
||||
String _string = element.toString();
|
||||
_builder.append(_string);
|
||||
_builder.newLineIfNotEmpty();
|
||||
String _renderPredicate = this._hoistingProcessor.findGuardForElement(element).renderPredicate();
|
||||
_builder.append(_renderPredicate);
|
||||
String _ebnf = this.ebnf(element, options, supportActions);
|
||||
|
@ -962,7 +947,7 @@ public abstract class AbstractAntlrGrammarGenerator {
|
|||
protected String _ebnf2(final AbstractSemanticPredicate it, final AntlrOptions options, final boolean supportActions) {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("{");
|
||||
String _source = it.getCode().getSource();
|
||||
String _source = JavaCodeUtils.getSource(it.getCode());
|
||||
_builder.append(_source);
|
||||
_builder.append("}?=>");
|
||||
_builder.newLineIfNotEmpty();
|
||||
|
|
Loading…
Reference in a new issue