Search in sources :

Example 81 with AbstractElement

use of org.eclipse.xtext.AbstractElement in project xtext-core by eclipse.

the class AbstractAntlrGrammarGenerator 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 82 with AbstractElement

use of org.eclipse.xtext.AbstractElement in project xtext-core by eclipse.

the class AbstractAntlrGrammarGenerator method _ebnf2.

protected String _ebnf2(final Group it, final AntlrOptions options, final boolean supportActions) {
    StringConcatenation _builder = new StringConcatenation();
    {
        EList<AbstractElement> _elements = it.getElements();
        for (final AbstractElement element : _elements) {
            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 83 with AbstractElement

use of org.eclipse.xtext.AbstractElement in project xtext-core by eclipse.

the class AbstractAntlrGrammarGenerator method _assignmentEbnf.

protected String _assignmentEbnf(final Alternatives it, final Assignment assignment, 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 _assignmentEbnf = this.assignmentEbnf(element, assignment, options, supportActions);
            _builder.append(_assignmentEbnf);
        }
    }
    _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 84 with AbstractElement

use of org.eclipse.xtext.AbstractElement in project xtext-core by eclipse.

the class AbstractAntlrGrammarGenerator 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) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) List(java.util.List)

Example 85 with AbstractElement

use of org.eclipse.xtext.AbstractElement in project xtext-core by eclipse.

the class AbstractAntlrGrammarGenerator method _ebnf2.

protected String _ebnf2(final UnorderedGroup it, final AntlrOptions options, final boolean supportActions) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("(");
    {
        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.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

AbstractElement (org.eclipse.xtext.AbstractElement)126 EObject (org.eclipse.emf.ecore.EObject)39 AbstractRule (org.eclipse.xtext.AbstractRule)34 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)31 RuleCall (org.eclipse.xtext.RuleCall)26 ParserRule (org.eclipse.xtext.ParserRule)18 Grammar (org.eclipse.xtext.Grammar)17 EList (org.eclipse.emf.common.util.EList)15 Assignment (org.eclipse.xtext.Assignment)15 Test (org.junit.Test)14 Group (org.eclipse.xtext.Group)13 UnorderedGroup (org.eclipse.xtext.UnorderedGroup)13 List (java.util.List)12 ArrayList (java.util.ArrayList)11 XtextResource (org.eclipse.xtext.resource.XtextResource)11 Action (org.eclipse.xtext.Action)10 TerminalRule (org.eclipse.xtext.TerminalRule)10 Alternatives (org.eclipse.xtext.Alternatives)9 EClassifier (org.eclipse.emf.ecore.EClassifier)8 InternalEObject (org.eclipse.emf.ecore.InternalEObject)8