Search in sources :

Example 41 with StringConcatenation

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

Example 42 with StringConcatenation

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

Example 43 with StringConcatenation

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

Example 44 with StringConcatenation

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

Example 45 with StringConcatenation

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();
}
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