use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.
the class DefaultAntlrGrammarGenerator method compileEBNF.
protected String compileEBNF(final AbstractRule it, final AntlrOptions options) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("// Rule ");
String _name = AntlrGrammarGenUtil.<AbstractRule>getOriginalElement(it).getName();
_builder.append(_name);
_builder.newLineIfNotEmpty();
String _ruleName = this._grammarAccessExtensions.ruleName(it);
_builder.append(_ruleName);
String _compileInit = this.compileInit(it, options);
_builder.append(_compileInit);
_builder.append(":");
_builder.newLineIfNotEmpty();
{
if (((it instanceof ParserRule) && GrammarUtil.isDatatypeRule(AntlrGrammarGenUtil.<AbstractRule>getOriginalElement(it)))) {
_builder.append("\t");
String _dataTypeEbnf = this.dataTypeEbnf(it.getAlternatives(), true);
_builder.append(_dataTypeEbnf, "\t");
_builder.newLineIfNotEmpty();
} else {
_builder.append("\t");
String _ebnf = this.ebnf(it.getAlternatives(), options, true);
_builder.append(_ebnf, "\t");
_builder.newLineIfNotEmpty();
}
}
_builder.append(";");
_builder.newLine();
String _compileFinally = this.compileFinally(it, options);
_builder.append(_compileFinally);
_builder.newLineIfNotEmpty();
return _builder.toString();
}
use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.
the class DefaultAntlrGrammarGenerator method ebnf.
protected String ebnf(final AbstractElement it, final AntlrOptions options, final boolean supportActions) {
StringConcatenation _builder = new StringConcatenation();
{
boolean _mustBeParenthesized = this._grammarAccessExtensions.mustBeParenthesized(it);
if (_mustBeParenthesized) {
_builder.append("(");
_builder.newLineIfNotEmpty();
_builder.append("\t");
String _ebnfPredicate = this.ebnfPredicate(it, options);
_builder.append(_ebnfPredicate, "\t");
String _ebnf2 = this.ebnf2(it, options, supportActions);
_builder.append(_ebnf2, "\t");
_builder.newLineIfNotEmpty();
_builder.append(")");
} else {
String _ebnf2_1 = this.ebnf2(it, options, supportActions);
_builder.append(_ebnf2_1);
}
}
String _cardinality = it.getCardinality();
_builder.append(_cardinality);
_builder.newLineIfNotEmpty();
return _builder.toString();
}
use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.
the class DefaultAntlrGrammarGenerator method compileParserHeader.
protected CharSequence compileParserHeader(final Grammar it, final AntlrOptions options) {
StringConcatenation _builder = new StringConcatenation();
_builder.newLine();
_builder.append("@parser::header {");
_builder.newLine();
_builder.append("package ");
String _packageName = this._naming.toPackageName(this.getGrammarFileName(it));
_builder.append(_packageName);
_builder.append(";");
_builder.newLineIfNotEmpty();
String _compileParserImports = this.compileParserImports(it, options);
_builder.append(_compileParserImports);
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
return _builder;
}
use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.
the class DefaultAntlrGrammarGenerator method _ebnf2.
protected String _ebnf2(final AbstractElement it, final AntlrOptions options, final boolean supportActions) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("ERROR ");
String _name = it.eClass().getName();
_builder.append(_name);
_builder.append(" not matched");
return _builder.toString();
}
use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.
the class NamingExtensions method getGrammarFileName.
public String getGrammarFileName(final Grammar it, final String prefix) {
StringConcatenation _builder = new StringConcatenation();
String _parserPackage = this.getParserPackage(it);
_builder.append(_parserPackage);
_builder.append(".");
_builder.append(prefix);
_builder.append("Internal");
String _simpleName = GrammarUtil.getSimpleName(it);
_builder.append(_simpleName);
return _builder.toString();
}
Aggregations