use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.
the class AntlrGrammarGenerator method _assignmentEbnf.
@Override
protected String _assignmentEbnf(final RuleCall it, final Assignment assignment, final AntlrOptions options, final boolean supportActions) {
String _xifexpression = null;
if (supportActions) {
String _switchResult = null;
AbstractRule _rule = it.getRule();
boolean _matched = false;
if (_rule instanceof EnumRule) {
_matched = true;
}
if (!_matched) {
if (_rule instanceof ParserRule) {
_matched = true;
}
}
if (_matched) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
CharSequence _newCompositeNode = this.newCompositeNode(it);
_builder.append(_newCompositeNode, "\t");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
String _localVar = this._grammarAccessExtensions.localVar(assignment, it);
_builder.append(_localVar);
_builder.append("=");
String __assignmentEbnf = super._assignmentEbnf(it, assignment, options, supportActions);
_builder.append(__assignmentEbnf);
_builder.newLineIfNotEmpty();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append("if ($current==null) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("$current = ");
CharSequence _createModelElementForParent = this.createModelElementForParent(assignment);
_builder.append(_createModelElementForParent, "\t\t");
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
String _setOrAdd = this._grammarAccessExtensions.setOrAdd(assignment);
_builder.append(_setOrAdd, "\t");
_builder.append("(");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("$current,");
_builder.newLine();
_builder.append("\t\t");
_builder.append("\"");
String _feature = assignment.getFeature();
_builder.append(_feature, "\t\t");
_builder.append("\",");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
{
boolean _isBooleanAssignment = GrammarUtil.isBooleanAssignment(assignment);
if (_isBooleanAssignment) {
_builder.append("true");
} else {
String _localVar_1 = this._grammarAccessExtensions.localVar(assignment, it);
_builder.append(_localVar_1, "\t\t");
}
}
_builder.append(",");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
CharSequence _stringLiteral = this._grammarAccessExtensions.toStringLiteral(it);
_builder.append(_stringLiteral, "\t\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("afterParserOrEnumRuleCall();");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_switchResult = _builder.toString();
}
if (!_matched) {
if (_rule instanceof TerminalRule) {
_matched = true;
StringConcatenation _builder_1 = new StringConcatenation();
String _localVar_2 = this._grammarAccessExtensions.localVar(assignment, it);
_builder_1.append(_localVar_2);
_builder_1.append("=");
String __assignmentEbnf_1 = super._assignmentEbnf(it, assignment, options, supportActions);
_builder_1.append(__assignmentEbnf_1);
_builder_1.newLineIfNotEmpty();
_builder_1.append("{");
_builder_1.newLine();
_builder_1.append("\t");
CharSequence _newLeafNode = this.newLeafNode(it, this._grammarAccessExtensions.localVar(assignment, it));
_builder_1.append(_newLeafNode, "\t");
_builder_1.newLineIfNotEmpty();
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("{");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("if ($current==null) {");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("$current = ");
CharSequence _createModelElement = this.createModelElement(assignment);
_builder_1.append(_createModelElement, "\t\t");
_builder_1.append(";");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t");
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("\t");
String _setOrAdd_1 = this._grammarAccessExtensions.setOrAdd(assignment);
_builder_1.append(_setOrAdd_1, "\t");
_builder_1.append("WithLastConsumed(");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t\t");
_builder_1.append("$current,");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("\"");
String _feature_1 = assignment.getFeature();
_builder_1.append(_feature_1, "\t\t");
_builder_1.append("\",");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t\t");
{
boolean _isBooleanAssignment_1 = GrammarUtil.isBooleanAssignment(assignment);
if (_isBooleanAssignment_1) {
_builder_1.append("true");
} else {
String _localVar_3 = this._grammarAccessExtensions.localVar(assignment, it);
_builder_1.append(_localVar_3, "\t\t");
}
}
_builder_1.append(",");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t\t");
CharSequence _stringLiteral_1 = this._grammarAccessExtensions.toStringLiteral(it);
_builder_1.append(_stringLiteral_1, "\t\t");
_builder_1.append(");");
_builder_1.newLineIfNotEmpty();
_builder_1.append("}");
_builder_1.newLine();
_switchResult = _builder_1.toString();
}
}
if (!_matched) {
throw new IllegalStateException(("assignmentEbnf is not supported for " + it));
}
_xifexpression = _switchResult;
} else {
_xifexpression = super._assignmentEbnf(it, assignment, options, supportActions);
}
return _xifexpression;
}
use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.
the class AntlrGrammarGenerator method _dataTypeEbnf2.
@Override
protected String _dataTypeEbnf2(final RuleCall it, final boolean supportActions) {
String _xifexpression = null;
if (supportActions) {
String _switchResult = null;
AbstractRule _rule = it.getRule();
boolean _matched = false;
if (_rule instanceof EnumRule) {
boolean _isAssigned = GrammarUtil.isAssigned(it);
if (_isAssigned) {
_matched = true;
}
}
if (!_matched) {
if (_rule instanceof ParserRule) {
boolean _isAssigned = GrammarUtil.isAssigned(it);
if (_isAssigned) {
_matched = true;
}
}
}
if (_matched) {
_switchResult = super._dataTypeEbnf2(it, supportActions);
}
if (!_matched) {
if (_rule instanceof EnumRule) {
_matched = true;
}
if (!_matched) {
if (_rule instanceof ParserRule) {
_matched = true;
}
}
if (_matched) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
CharSequence _newCompositeNode = this.newCompositeNode(it);
_builder.append(_newCompositeNode, "\t");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
String _localVar = this._grammarAccessExtensions.localVar(it);
_builder.append(_localVar);
_builder.append("=");
String __dataTypeEbnf2 = super._dataTypeEbnf2(it, supportActions);
_builder.append(__dataTypeEbnf2);
String _argumentList = AntlrGrammarGenUtil.getArgumentList(it, this.isPassCurrentIntoFragment(), (!supportActions));
_builder.append(_argumentList);
_builder.newLineIfNotEmpty();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append("$current.merge(");
String _localVar_1 = this._grammarAccessExtensions.localVar(it);
_builder.append(_localVar_1, "\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append("afterParserOrEnumRuleCall();");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_switchResult = _builder.toString();
}
}
if (!_matched) {
if (_rule instanceof TerminalRule) {
_matched = true;
StringConcatenation _builder_1 = new StringConcatenation();
String _localVar_2 = this._grammarAccessExtensions.localVar(it);
_builder_1.append(_localVar_2);
_builder_1.append("=");
String __dataTypeEbnf2_1 = super._dataTypeEbnf2(it, supportActions);
_builder_1.append(__dataTypeEbnf2_1);
_builder_1.newLineIfNotEmpty();
_builder_1.append("{");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("$current.merge(");
String _localVar_3 = this._grammarAccessExtensions.localVar(it);
_builder_1.append(_localVar_3, "\t");
_builder_1.append(");");
_builder_1.newLineIfNotEmpty();
_builder_1.append("}");
_builder_1.newLine();
_builder_1.append("{");
_builder_1.newLine();
_builder_1.append("\t");
CharSequence _newLeafNode = this.newLeafNode(it, this._grammarAccessExtensions.localVar(it));
_builder_1.append(_newLeafNode, "\t");
_builder_1.newLineIfNotEmpty();
_builder_1.append("}");
_builder_1.newLine();
_switchResult = _builder_1.toString();
}
}
if (!_matched) {
_switchResult = super._dataTypeEbnf2(it, supportActions);
}
_xifexpression = _switchResult;
} else {
_xifexpression = super._dataTypeEbnf2(it, supportActions);
}
return _xifexpression;
}
use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.
the class AntlrGrammarGenerator method _ebnf2.
@Override
protected String _ebnf2(final EnumLiteralDeclaration it, final AntlrOptions options, final boolean supportActions) {
String _xifexpression = null;
if ((!supportActions)) {
_xifexpression = super._ebnf2(it, options, supportActions);
} else {
StringConcatenation _builder = new StringConcatenation();
String _localVar = this._grammarAccessExtensions.localVar(it);
_builder.append(_localVar);
_builder.append("=");
String __ebnf2 = super._ebnf2(it, options, supportActions);
_builder.append(__ebnf2);
_builder.newLineIfNotEmpty();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
CharSequence _newLeafNode = this.newLeafNode(it, this._grammarAccessExtensions.localVar(it));
_builder.append(_newLeafNode, "\t");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
_xifexpression = _builder.toString();
}
return _xifexpression;
}
use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.
the class AntlrGrammarGenerator method _assignmentEbnf.
@Override
protected String _assignmentEbnf(final AbstractElement it, final Assignment assignment, final AntlrOptions options, final boolean supportActions) {
String _xifexpression = null;
if (supportActions) {
StringConcatenation _builder = new StringConcatenation();
String _localVar = this._grammarAccessExtensions.localVar(assignment, it);
_builder.append(_localVar);
_builder.append("=");
String __assignmentEbnf = super._assignmentEbnf(it, assignment, options, supportActions);
_builder.append(__assignmentEbnf);
_builder.newLineIfNotEmpty();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append("if ($current==null) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("$current = ");
CharSequence _createModelElement = this.createModelElement(assignment);
_builder.append(_createModelElement, "\t\t");
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
String _setOrAdd = this._grammarAccessExtensions.setOrAdd(assignment);
_builder.append(_setOrAdd, "\t");
_builder.append("WithLastConsumed($current, \"");
String _feature = assignment.getFeature();
_builder.append(_feature, "\t");
_builder.append("\", ");
{
boolean _isBooleanAssignment = GrammarUtil.isBooleanAssignment(assignment);
if (_isBooleanAssignment) {
_builder.append("true");
} else {
String _localVar_1 = this._grammarAccessExtensions.localVar(assignment, it);
_builder.append(_localVar_1, "\t");
}
}
_builder.append(", ");
CharSequence _stringLiteral = this._grammarAccessExtensions.toStringLiteral(assignment.getTerminal());
_builder.append(_stringLiteral, "\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
_xifexpression = _builder.toString();
} else {
_xifexpression = super._assignmentEbnf(it, assignment, options, supportActions);
}
return _xifexpression;
}
use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.
the class DefaultAntlrGrammarGenerator method compileLexerHeader.
protected CharSequence compileLexerHeader(final Grammar it, final AntlrOptions options) {
StringConcatenation _builder = new StringConcatenation();
_builder.newLine();
_builder.append("@lexer::header {");
_builder.newLine();
_builder.append("package ");
String _packageName = this._naming.toPackageName(this.getGrammarFileName(it));
_builder.append(_packageName);
_builder.append(";");
_builder.newLineIfNotEmpty();
CharSequence _compileLexerImports = this.compileLexerImports(it, options);
_builder.append(_compileLexerImports);
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
return _builder;
}
Aggregations