use of org.eclipse.xtext.UnorderedGroup in project xtext-core by eclipse.
the class AbstractNFAState method collectOutgoingByContainer.
protected void collectOutgoingByContainer(AbstractElement element, Set<AbstractElement> visited, boolean isRuleCall, AbstractElement loopCenter) {
EObject container = element.eContainer();
if (container instanceof Group || container instanceof UnorderedGroup) {
CompoundElement compoundContainer = (CompoundElement) container;
List<AbstractElement> siblings = compoundContainer.getElements();
int i = siblings.indexOf(element);
switch(builder.getDirection()) {
case FORWARD:
if ((i + 1) >= siblings.size()) {
if (GrammarUtil.isMultipleCardinality(compoundContainer))
addOutgoing(compoundContainer, visited, isRuleCall, compoundContainer);
collectOutgoingByContainer(compoundContainer, visited, isRuleCall, loopCenter);
} else {
AbstractElement next = siblings.get(i + 1);
addOutgoing(next, visited, isRuleCall, loopCenter);
if (GrammarUtil.isOptionalCardinality(next))
collectOutgoingByContainer(next, visited, isRuleCall, loopCenter);
}
break;
case BACKWARD:
if (i <= 0) {
if (GrammarUtil.isMultipleCardinality(compoundContainer))
addOutgoing(compoundContainer, visited, isRuleCall, compoundContainer);
collectOutgoingByContainer(compoundContainer, visited, isRuleCall, loopCenter);
} else {
AbstractElement next = siblings.get(i - 1);
addOutgoing(next, visited, isRuleCall, loopCenter);
if (GrammarUtil.isOptionalCardinality(next))
collectOutgoingByContainer(next, visited, isRuleCall, loopCenter);
}
break;
}
} else if (container instanceof AbstractRule)
endState = true;
else if (container instanceof AbstractElement) {
AbstractElement elementContainer = (AbstractElement) container;
if (GrammarUtil.isMultipleCardinality(elementContainer))
addOutgoing(elementContainer, visited, isRuleCall, elementContainer);
collectOutgoingByContainer(elementContainer, visited, isRuleCall, loopCenter);
} else
throw new IllegalStateException("Unknown container: " + container);
}
use of org.eclipse.xtext.UnorderedGroup in project xtext-core by eclipse.
the class XtextSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == XtextPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case XtextPackage.ACTION:
if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
sequence_AbstractTokenWithCardinality_Action(context, (Action) semanticObject);
return;
} else if (rule == grammarAccess.getActionRule()) {
sequence_Action(context, (Action) semanticObject);
return;
} else
break;
case XtextPackage.ALTERNATIVES:
if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
sequence_AbstractTokenWithCardinality_Alternatives(context, (Alternatives) semanticObject);
return;
} else if (rule == grammarAccess.getAssignableTerminalRule() || rule == grammarAccess.getParenthesizedAssignableElementRule() || rule == grammarAccess.getAssignableAlternativesRule() || action == grammarAccess.getAssignableAlternativesAccess().getAlternativesElementsAction_1_0()) {
sequence_AssignableAlternatives(context, (Alternatives) semanticObject);
return;
} else if (rule == grammarAccess.getEnumLiteralsRule()) {
sequence_EnumLiterals(context, (Alternatives) semanticObject);
return;
} else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_TerminalAlternatives_TerminalToken(context, (Alternatives) semanticObject);
return;
} else
break;
case XtextPackage.ANNOTATION:
sequence_Annotation(context, (Annotation) semanticObject);
return;
case XtextPackage.ASSIGNMENT:
if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
sequence_AbstractTokenWithCardinality_Assignment(context, (Assignment) semanticObject);
return;
} else if (rule == grammarAccess.getAssignmentRule()) {
sequence_Assignment(context, (Assignment) semanticObject);
return;
} else
break;
case XtextPackage.CHARACTER_RANGE:
if (rule == grammarAccess.getCharacterRangeRule()) {
sequence_CharacterRange(context, (CharacterRange) semanticObject);
return;
} else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_CharacterRange_TerminalToken(context, (CharacterRange) semanticObject);
return;
} else
break;
case XtextPackage.CONJUNCTION:
sequence_Conjunction(context, (Conjunction) semanticObject);
return;
case XtextPackage.CROSS_REFERENCE:
sequence_CrossReference(context, (CrossReference) semanticObject);
return;
case XtextPackage.DISJUNCTION:
sequence_Disjunction(context, (Disjunction) semanticObject);
return;
case XtextPackage.EOF:
if (rule == grammarAccess.getEOFRule()) {
sequence_EOF(context, (EOF) semanticObject);
return;
} else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_EOF_TerminalToken(context, (EOF) semanticObject);
return;
} else
break;
case XtextPackage.ENUM_LITERAL_DECLARATION:
sequence_EnumLiteralDeclaration(context, (EnumLiteralDeclaration) semanticObject);
return;
case XtextPackage.ENUM_RULE:
sequence_EnumRule(context, (EnumRule) semanticObject);
return;
case XtextPackage.GENERATED_METAMODEL:
sequence_GeneratedMetamodel(context, (GeneratedMetamodel) semanticObject);
return;
case XtextPackage.GRAMMAR:
sequence_Grammar(context, (Grammar) semanticObject);
return;
case XtextPackage.GROUP:
if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
sequence_AbstractTokenWithCardinality_ConditionalBranch_Group_PredicatedGroup(context, (Group) semanticObject);
return;
} else if (rule == grammarAccess.getPredicatedGroupRule()) {
sequence_PredicatedGroup(context, (Group) semanticObject);
return;
} else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_TerminalGroup_TerminalToken(context, (Group) semanticObject);
return;
} else
break;
case XtextPackage.KEYWORD:
if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
sequence_AbstractTokenWithCardinality_Keyword_PredicatedKeyword(context, (Keyword) semanticObject);
return;
} else if (rule == grammarAccess.getKeywordRule() || rule == grammarAccess.getAssignableTerminalRule() || rule == grammarAccess.getParenthesizedAssignableElementRule() || rule == grammarAccess.getAssignableAlternativesRule() || action == grammarAccess.getAssignableAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getCrossReferenceableTerminalRule() || rule == grammarAccess.getCharacterRangeRule() || action == grammarAccess.getCharacterRangeAccess().getCharacterRangeLeftAction_1_0()) {
sequence_Keyword(context, (Keyword) semanticObject);
return;
} else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_Keyword_TerminalToken(context, (Keyword) semanticObject);
return;
} else if (rule == grammarAccess.getPredicatedKeywordRule()) {
sequence_PredicatedKeyword(context, (Keyword) semanticObject);
return;
} else
break;
case XtextPackage.LITERAL_CONDITION:
sequence_LiteralCondition(context, (LiteralCondition) semanticObject);
return;
case XtextPackage.NAMED_ARGUMENT:
sequence_NamedArgument(context, (NamedArgument) semanticObject);
return;
case XtextPackage.NEGATED_TOKEN:
if (rule == grammarAccess.getAbstractNegatedTokenRule() || rule == grammarAccess.getNegatedTokenRule()) {
sequence_NegatedToken(context, (NegatedToken) semanticObject);
return;
} else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_NegatedToken_TerminalToken(context, (NegatedToken) semanticObject);
return;
} else
break;
case XtextPackage.NEGATION:
sequence_Negation(context, (Negation) semanticObject);
return;
case XtextPackage.PARAMETER:
sequence_Parameter(context, (Parameter) semanticObject);
return;
case XtextPackage.PARAMETER_REFERENCE:
sequence_ParameterReference(context, (ParameterReference) semanticObject);
return;
case XtextPackage.PARSER_RULE:
sequence_ParserRule_RuleNameAndParams(context, (ParserRule) semanticObject);
return;
case XtextPackage.REFERENCED_METAMODEL:
sequence_ReferencedMetamodel(context, (ReferencedMetamodel) semanticObject);
return;
case XtextPackage.RULE_CALL:
if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
sequence_AbstractTokenWithCardinality_PredicatedRuleCall_RuleCall(context, (RuleCall) semanticObject);
return;
} else if (rule == grammarAccess.getPredicatedRuleCallRule()) {
sequence_PredicatedRuleCall(context, (RuleCall) semanticObject);
return;
} else if (rule == grammarAccess.getRuleCallRule() || rule == grammarAccess.getAssignableTerminalRule() || rule == grammarAccess.getParenthesizedAssignableElementRule() || rule == grammarAccess.getAssignableAlternativesRule() || action == grammarAccess.getAssignableAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getCrossReferenceableTerminalRule()) {
sequence_RuleCall(context, (RuleCall) semanticObject);
return;
} else if (rule == grammarAccess.getTerminalRuleCallRule()) {
sequence_TerminalRuleCall(context, (RuleCall) semanticObject);
return;
} else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_TerminalRuleCall_TerminalToken(context, (RuleCall) semanticObject);
return;
} else
break;
case XtextPackage.TERMINAL_RULE:
sequence_TerminalRule(context, (TerminalRule) semanticObject);
return;
case XtextPackage.TYPE_REF:
sequence_TypeRef(context, (TypeRef) semanticObject);
return;
case XtextPackage.UNORDERED_GROUP:
sequence_AbstractTokenWithCardinality_UnorderedGroup(context, (UnorderedGroup) semanticObject);
return;
case XtextPackage.UNTIL_TOKEN:
if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_TerminalToken_UntilToken(context, (UntilToken) semanticObject);
return;
} else if (rule == grammarAccess.getAbstractNegatedTokenRule() || rule == grammarAccess.getUntilTokenRule()) {
sequence_UntilToken(context, (UntilToken) semanticObject);
return;
} else
break;
case XtextPackage.WILDCARD:
if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_TerminalToken_Wildcard(context, (Wildcard) semanticObject);
return;
} else if (rule == grammarAccess.getWildcardRule()) {
sequence_Wildcard(context, (Wildcard) semanticObject);
return;
} else
break;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.xtext.UnorderedGroup in project xtext-core by eclipse.
the class XtextValidator method checkCurrentMustBeUnassigned.
private void checkCurrentMustBeUnassigned(final AbstractElement element) {
final ParserRule rule = GrammarUtil.containingParserRule(element);
if (GrammarUtil.isDatatypeRule(rule))
return;
XtextSwitch<Boolean> visitor = new XtextSwitch<Boolean>() {
private boolean isNull = !rule.isFragment();
@Override
public Boolean caseAbstractElement(AbstractElement object) {
return isNull;
}
@Override
public Boolean caseAlternatives(Alternatives object) {
final boolean wasIsNull = isNull;
boolean localIsNull = wasIsNull;
for (AbstractElement element : object.getElements()) {
isNull = wasIsNull;
localIsNull &= doSwitch(element);
}
isNull = localIsNull;
return isNull;
}
@Override
public Boolean caseUnorderedGroup(UnorderedGroup object) {
final boolean wasIsNull = isNull;
boolean localIsNull = wasIsNull;
for (AbstractElement element : object.getElements()) {
isNull = wasIsNull;
localIsNull |= doSwitch(element);
}
isNull = localIsNull;
return isNull;
}
@Override
public Boolean caseAssignment(Assignment object) {
isNull = false;
return isNull;
}
@Override
public Boolean caseGroup(Group object) {
for (AbstractElement element : object.getElements()) doSwitch(element);
return isNull;
}
@Override
public Boolean caseAction(Action object) {
if (object == element) {
if (!(isNull && !isMany(object))) {
error("An unassigned action is not allowed, when the 'current' was already created.", object, null);
checkDone();
}
}
isNull = false;
return isNull;
}
@Override
public Boolean caseRuleCall(RuleCall object) {
if (object == element) {
AbstractRule calledRule = object.getRule();
if (calledRule instanceof ParserRule && ((ParserRule) calledRule).isFragment()) {
isNull = false;
return isNull;
}
if (!(isNull && !isMany(object))) {
error("An unassigned rule call is not allowed, when the 'current' was already created.", object, null);
checkDone();
}
}
return doSwitch(object.getRule());
}
@Override
public Boolean caseParserRule(ParserRule object) {
isNull = GrammarUtil.isDatatypeRule(object);
return isNull;
}
@Override
public Boolean caseTerminalRule(TerminalRule object) {
isNull = true;
return isNull;
}
public boolean isMany(AbstractElement element) {
return GrammarUtil.isMultipleCardinality(element) || ((element.eContainer() instanceof AbstractElement) && isMany((AbstractElement) element.eContainer()));
}
};
visitor.doSwitch(rule.getAlternatives());
}
use of org.eclipse.xtext.UnorderedGroup in project xtext-core by eclipse.
the class XtextValidator method checkAssignedActionAfterAssignment.
@Check
public void checkAssignedActionAfterAssignment(final Action action) {
if (action.getFeature() != null) {
ParserRule rule = GrammarUtil.containingParserRule(action);
if (rule.isFragment() && !rule.isWildcard()) {
error("An action is not allowed in fragments.", action, null);
return;
}
XtextSwitch<Boolean> visitor = new XtextSwitch<Boolean>() {
private boolean assignedActionAllowed = false;
@Override
public Boolean caseAbstractElement(AbstractElement object) {
return assignedActionAllowed;
}
@Override
public Boolean caseAlternatives(Alternatives object) {
boolean wasActionAllowed = assignedActionAllowed;
boolean localActionAllowed = true;
for (AbstractElement element : object.getElements()) {
assignedActionAllowed = wasActionAllowed;
localActionAllowed &= doSwitch(element);
}
assignedActionAllowed = wasActionAllowed || (localActionAllowed && !GrammarUtil.isOptionalCardinality(object));
return assignedActionAllowed;
}
@Override
public Boolean caseUnorderedGroup(UnorderedGroup object) {
boolean wasActionAllowed = assignedActionAllowed;
boolean localActionAllowed = false;
for (AbstractElement element : object.getElements()) {
assignedActionAllowed = wasActionAllowed;
localActionAllowed |= doSwitch(element);
}
assignedActionAllowed = wasActionAllowed || (localActionAllowed && !GrammarUtil.isOptionalCardinality(object));
return assignedActionAllowed;
}
@Override
public Boolean caseAssignment(Assignment object) {
assignedActionAllowed = assignedActionAllowed || !GrammarUtil.isOptionalCardinality(object);
return assignedActionAllowed;
}
@Override
public Boolean caseGroup(Group object) {
boolean wasAssignedActionAllowed = assignedActionAllowed;
for (AbstractElement element : object.getElements()) doSwitch(element);
assignedActionAllowed = wasAssignedActionAllowed || (assignedActionAllowed && !GrammarUtil.isOptionalCardinality(object));
return assignedActionAllowed;
}
@Override
public Boolean caseAction(Action object) {
if (object == action) {
if (!assignedActionAllowed) {
error("An action is not allowed in fragments and when the current may still be unassigned.", null);
checkDone();
}
}
assignedActionAllowed = true;
return assignedActionAllowed;
}
@Override
public Boolean caseRuleCall(RuleCall object) {
if (object.getRule() == null)
return assignedActionAllowed;
assignedActionAllowed = assignedActionAllowed || doSwitch(object.getRule()) && !GrammarUtil.isOptionalCardinality(object);
return assignedActionAllowed;
}
@Override
public Boolean caseParserRule(ParserRule object) {
assignedActionAllowed = !GrammarUtil.isDatatypeRule(object) && !object.isFragment();
return assignedActionAllowed;
}
@Override
public Boolean caseTerminalRule(TerminalRule object) {
return assignedActionAllowed;
}
};
visitor.doSwitch(rule.getAlternatives());
}
}
use of org.eclipse.xtext.UnorderedGroup in project xtext-core by eclipse.
the class AntlrContentAssistGrammarGenerator method _compileRule.
protected CharSequence _compileRule(final UnorderedGroup it, final Grammar grammar, final AntlrOptions options) {
CharSequence _xblockexpression = null;
{
final Function1<AbstractElement, Boolean> _function = (AbstractElement it_1) -> {
boolean _isOptionalCardinality = GrammarUtil.isOptionalCardinality(it_1);
return Boolean.valueOf((!_isOptionalCardinality));
};
final boolean hasMandatoryContent = IterableExtensions.<AbstractElement>exists(it.getElements(), _function);
StringConcatenation _builder = new StringConcatenation();
String _contentAssistRuleName = AntlrGrammarGenUtil.getContentAssistRuleName(GrammarUtil.containingRule(it));
_builder.append(_contentAssistRuleName);
_builder.append("__");
String _gaElementIdentifier = this._grammarAccessExtensions.gaElementIdentifier(AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it));
_builder.append(_gaElementIdentifier);
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("@init {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("int stackSize = keepStackSize();");
_builder.newLine();
_builder.append("\t\t");
_builder.append("getUnorderedGroupHelper().enter(grammarAccess.");
String _gaRuleElementAccessor = this._grammarAccessExtensions.gaRuleElementAccessor(AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it));
_builder.append(_gaRuleElementAccessor, "\t\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append(":");
_builder.newLine();
_builder.append("\t");
String _contentAssistRuleName_1 = AntlrGrammarGenUtil.getContentAssistRuleName(GrammarUtil.containingRule(it));
_builder.append(_contentAssistRuleName_1, "\t");
_builder.append("__");
String _gaElementIdentifier_1 = this._grammarAccessExtensions.gaElementIdentifier(AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it));
_builder.append(_gaElementIdentifier_1, "\t");
_builder.append("__0");
_builder.newLineIfNotEmpty();
{
if (hasMandatoryContent) {
_builder.append("\t");
_builder.append("{getUnorderedGroupHelper().canLeave(grammarAccess.");
String _gaRuleElementAccessor_1 = this._grammarAccessExtensions.gaRuleElementAccessor(AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it));
_builder.append(_gaRuleElementAccessor_1, "\t");
_builder.append(")}?");
_builder.newLineIfNotEmpty();
} else {
_builder.append("\t");
_builder.append("?");
_builder.newLine();
}
}
_builder.append(";");
_builder.newLine();
_builder.append("finally {");
_builder.newLine();
_builder.append("\t");
_builder.append("getUnorderedGroupHelper().leave(grammarAccess.");
String _gaRuleElementAccessor_2 = this._grammarAccessExtensions.gaRuleElementAccessor(AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it));
_builder.append(_gaRuleElementAccessor_2, "\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("restoreStackSize(stackSize);");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
CharSequence _ruleImpl = this.ruleImpl(it, grammar, options);
_builder.append(_ruleImpl);
_builder.newLineIfNotEmpty();
_builder.newLine();
CharSequence _ruleImpl_1 = this.ruleImpl(it, grammar, options, 0);
_builder.append(_ruleImpl_1);
_builder.newLineIfNotEmpty();
_xblockexpression = _builder;
}
return _xblockexpression;
}
Aggregations