Search in sources :

Example 31 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.

the class DefaultAntlrGrammarGenerator method _ebnf2.

protected String _ebnf2(final Assignment it, final AntlrOptions options, final boolean supportActions) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("(");
    _builder.newLine();
    _builder.append("\t");
    String _assignmentEbnf = this.assignmentEbnf(it.getTerminal(), it, options, supportActions);
    _builder.append(_assignmentEbnf, "\t");
    _builder.newLineIfNotEmpty();
    _builder.append(")");
    _builder.newLine();
    return _builder.toString();
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 32 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.

the class DefaultAntlrGrammarGenerator method _dataTypeEbnf2.

protected String _dataTypeEbnf2(final AbstractElement it, 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();
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 33 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.

the class DefaultAntlrGrammarGenerator method dataTypeEbnf.

protected String dataTypeEbnf(final AbstractElement it, final boolean supportActions) {
    StringConcatenation _builder = new StringConcatenation();
    {
        boolean _mustBeParenthesized = this._grammarAccessExtensions.mustBeParenthesized(it);
        if (_mustBeParenthesized) {
            _builder.append("(");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            String _dataTypeEbnfPredicate = this.dataTypeEbnfPredicate(it);
            _builder.append(_dataTypeEbnfPredicate, "\t");
            String _dataTypeEbnf2 = this.dataTypeEbnf2(it, supportActions);
            _builder.append(_dataTypeEbnf2, "\t");
            _builder.newLineIfNotEmpty();
            _builder.append(")");
        } else {
            String _dataTypeEbnf2_1 = this.dataTypeEbnf2(it, supportActions);
            _builder.append(_dataTypeEbnf2_1);
        }
    }
    String _cardinality = it.getCardinality();
    _builder.append(_cardinality);
    _builder.newLineIfNotEmpty();
    return _builder.toString();
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 34 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.

the class DefaultAntlrGrammarGenerator method _ebnf2.

protected String _ebnf2(final Alternatives it, final AntlrOptions options, final boolean supportActions) {
    StringConcatenation _builder = new StringConcatenation();
    {
        EList<AbstractElement> _elements = it.getElements();
        boolean _hasElements = false;
        for (final AbstractElement element : _elements) {
            if (!_hasElements) {
                _hasElements = true;
            } else {
                _builder.appendImmediate("\n    |", "");
            }
            String _ebnf = this.ebnf(element, options, supportActions);
            _builder.append(_ebnf);
        }
    }
    _builder.newLineIfNotEmpty();
    return _builder.toString();
}
Also used : EList(org.eclipse.emf.common.util.EList) AbstractElement(org.eclipse.xtext.AbstractElement) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 35 with StringConcatenation

use of org.eclipse.xtend2.lib.StringConcatenation in project xtext-eclipse by eclipse.

the class DefaultAntlrGrammarGenerator method compile.

protected CharSequence compile(final Grammar it, final AntlrOptions options) {
    StringConcatenation _builder = new StringConcatenation();
    String _fileHeader = this._naming.fileHeader();
    _builder.append(_fileHeader);
    _builder.newLineIfNotEmpty();
    _builder.append("grammar ");
    String _simpleName = this._naming.toSimpleName(this.getGrammarFileName(it));
    _builder.append(_simpleName);
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    String _compileOptions = this.compileOptions(it, options);
    _builder.append(_compileOptions);
    _builder.newLineIfNotEmpty();
    String _compileTokens = this.compileTokens(it, options);
    _builder.append(_compileTokens);
    _builder.newLineIfNotEmpty();
    CharSequence _compileLexerHeader = this.compileLexerHeader(it, options);
    _builder.append(_compileLexerHeader);
    _builder.newLineIfNotEmpty();
    CharSequence _compileParserHeader = this.compileParserHeader(it, options);
    _builder.append(_compileParserHeader);
    _builder.newLineIfNotEmpty();
    String _compileParserMembers = this.compileParserMembers(it, options);
    _builder.append(_compileParserMembers);
    _builder.newLineIfNotEmpty();
    String _compileRuleCatch = this.compileRuleCatch(it, options);
    _builder.append(_compileRuleCatch);
    _builder.newLineIfNotEmpty();
    CharSequence _compileRules = this.compileRules(it, options);
    _builder.append(_compileRules);
    _builder.newLineIfNotEmpty();
    return _builder;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Aggregations

StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)5377 Test (org.junit.Test)4633 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)384 ContentAssistProcessorTestBuilder (org.eclipse.xtext.ui.testing.ContentAssistProcessorTestBuilder)202 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)135 CompilationUnitImpl (org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl)132 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)131 IFile (org.eclipse.core.resources.IFile)123 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)117 AbstractXtendCompilerTest (org.eclipse.xtend.core.tests.compiler.AbstractXtendCompilerTest)103 MutableClassDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration)101 MapBasedPreferenceValues (org.eclipse.xtext.preferences.MapBasedPreferenceValues)99 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)89 XExpression (org.eclipse.xtext.xbase.XExpression)82 CompilationTestHelper (org.eclipse.xtext.xbase.testing.CompilationTestHelper)80 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)76 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)73 EList (org.eclipse.emf.common.util.EList)67 List (java.util.List)66 Ignore (org.junit.Ignore)60