use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.
the class DefaultAntlrGrammarGenerator method compileRule.
protected CharSequence compileRule(final TerminalRule it, final Grammar grammar, final AntlrOptions options) {
StringConcatenation _builder = new StringConcatenation();
{
boolean _isFragment = it.isFragment();
if (_isFragment) {
_builder.append("fragment ");
}
}
String _ruleName = this._grammarAccessExtensions.ruleName(it);
_builder.append(_ruleName);
_builder.append(" : ");
String _lexerBody = TerminalRuleToLexerBody.toLexerBody(it);
_builder.append(_lexerBody);
{
boolean _shouldBeSkipped = this.shouldBeSkipped(it, grammar);
if (_shouldBeSkipped) {
_builder.append(" {skip();}");
}
}
_builder.append(";");
return _builder;
}
use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.
the class DefaultAntlrGrammarGenerator method _dataTypeEbnf2.
protected String _dataTypeEbnf2(final Alternatives it, final boolean supportActions) {
StringConcatenation _builder = new StringConcatenation();
{
EList<AbstractElement> _elements = it.getElements();
boolean _hasElements = false;
for (final AbstractElement e : _elements) {
if (!_hasElements) {
_hasElements = true;
} else {
_builder.appendImmediate("\n |", "");
}
String _dataTypeEbnf = this.dataTypeEbnf(e, supportActions);
_builder.append(_dataTypeEbnf);
}
}
_builder.newLineIfNotEmpty();
return _builder.toString();
}
use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.
the class DefaultAntlrGrammarGenerator method compileLexerImports.
protected CharSequence compileLexerImports(final Grammar it, final AntlrOptions options) {
StringConcatenation _builder = new StringConcatenation();
_builder.newLine();
_builder.append("// Hack: Use our own Lexer superclass by means of import. ");
_builder.newLine();
_builder.append("// Currently there is no other way to specify the superclass for the lexer.");
_builder.newLine();
_builder.append("import org.eclipse.xtext.parser.antlr.Lexer;");
_builder.newLine();
return _builder;
}
use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.
the class DefaultAntlrGrammarGenerator method dataTypeEbnfPredicate.
protected String dataTypeEbnfPredicate(final AbstractElement it) {
StringConcatenation _builder = new StringConcatenation();
{
if ((this._grammarAccessExtensions.predicated(it) || it.isFirstSetPredicated())) {
_builder.append("(");
{
boolean _predicated = this._grammarAccessExtensions.predicated(it);
if (_predicated) {
String _dataTypeEbnf2 = this.dataTypeEbnf2(this._grammarAccessExtensions.predicatedElement(it), false);
_builder.append(_dataTypeEbnf2);
} else {
{
List<AbstractElement> _firstSet = AntlrGrammarGenUtil.getFirstSet(it);
boolean _hasElements = false;
for (final AbstractElement e : _firstSet) {
if (!_hasElements) {
_hasElements = true;
} else {
_builder.appendImmediate(" | ", "");
}
String _dataTypeEbnf2_1 = this.dataTypeEbnf2(e, false);
_builder.append(_dataTypeEbnf2_1);
}
}
}
}
_builder.append(")=>");
}
}
_builder.newLineIfNotEmpty();
return _builder.toString();
}
use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.
the class DefaultAntlrGrammarGenerator method _dataTypeEbnf2.
protected String _dataTypeEbnf2(final UnorderedGroup it, final boolean supportActions) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("(");
{
EList<AbstractElement> _elements = it.getElements();
boolean _hasElements = false;
for (final AbstractElement e : _elements) {
if (!_hasElements) {
_hasElements = true;
} else {
_builder.appendImmediate("\n |", "");
}
String _dataTypeEbnf2 = this.dataTypeEbnf2(e, supportActions);
_builder.append(_dataTypeEbnf2);
}
}
_builder.append(")*");
_builder.newLineIfNotEmpty();
return _builder.toString();
}
Aggregations