Search in sources :

Example 36 with StringConcatenation

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;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 37 with StringConcatenation

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();
}
Also used : EList(org.eclipse.emf.common.util.EList) AbstractElement(org.eclipse.xtext.AbstractElement) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 38 with StringConcatenation

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;
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 39 with StringConcatenation

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();
}
Also used : AbstractElement(org.eclipse.xtext.AbstractElement) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) EList(org.eclipse.emf.common.util.EList) List(java.util.List)

Example 40 with StringConcatenation

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();
}
Also used : EList(org.eclipse.emf.common.util.EList) AbstractElement(org.eclipse.xtext.AbstractElement) 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