示例#1
0
 @Override
 public Boolean caseAssignment(Assignment object) {
   if (GrammarUtil.isMultipleAssignment(object)) return Boolean.FALSE;
   checkAssignment(object, object.getFeature());
   if (GrammarUtil.isMultipleCardinality(object)) checkAssignment(object, object.getFeature());
   return Boolean.FALSE;
 }
示例#2
0
 @Override
 public Boolean caseUnorderedGroup(UnorderedGroup object) {
   if (object == this.group) {
     boolean more = true;
     for (AbstractElement element : object.getElements()) {
       if (handledAlternatives == null || !handledAlternatives.contains(element)) {
         this.group = null;
         more = doSwitch(element) && more;
         this.group = object;
       }
     }
     if (more && GrammarUtil.isMultipleCardinality(object)) {
       handledAlternatives = null;
       this.group = null;
       return caseUnorderedGroup(object);
     }
     return more || isOptional(object);
   } else {
     boolean more = true;
     for (AbstractElement element : object.getElements()) {
       more = doSwitch(element) && more;
     }
     return more || isOptional(object);
   }
 }
示例#3
0
 @Override
 public Boolean caseCompoundElement(CompoundElement object) {
   Multimap<String, AbstractElement> prevAssignedFeatures = newMultimap(assignedFeatures);
   for (AbstractElement element : object.getElements()) {
     doSwitch(element);
   }
   if (GrammarUtil.isMultipleCardinality(object)) {
     for (AbstractElement element : object.getElements()) {
       doSwitch(element);
     }
   }
   if (GrammarUtil.isOptionalCardinality(object)) assignedFeatures.putAll(prevAssignedFeatures);
   return Boolean.FALSE;
 }
示例#4
0
 @Override
 public Boolean caseAlternatives(Alternatives object) {
   Multimap<String, AbstractElement> prevAssignedFeatures = assignedFeatures;
   Multimap<String, AbstractElement> mergedAssignedFeatures = LinkedHashMultimap.create();
   for (AbstractElement element : object.getElements()) {
     assignedFeatures = newMultimap(prevAssignedFeatures);
     doSwitch(element);
     mergedAssignedFeatures.putAll(assignedFeatures);
   }
   if (GrammarUtil.isOptionalCardinality(object)) {
     mergedAssignedFeatures.putAll(prevAssignedFeatures);
   }
   assignedFeatures = mergedAssignedFeatures;
   if (GrammarUtil.isMultipleCardinality(object)) {
     prevAssignedFeatures = assignedFeatures;
     for (AbstractElement element : object.getElements()) {
       assignedFeatures = newMultimap(prevAssignedFeatures);
       doSwitch(element);
       mergedAssignedFeatures.putAll(assignedFeatures);
     }
     assignedFeatures = mergedAssignedFeatures;
   }
   return Boolean.FALSE;
 }
 @Override
 protected String _ebnf2(
     final UnorderedGroup it, final AntlrOptions options, final boolean supportActions) {
   String _xifexpression = null;
   if (supportActions) {
     String _xblockexpression = null;
     {
       EList<AbstractElement> _elements = it.getElements();
       final Function1<AbstractElement, Boolean> _function =
           new Function1<AbstractElement, Boolean>() {
             @Override
             public Boolean apply(final AbstractElement it) {
               boolean _isOptionalCardinality = GrammarUtil.isOptionalCardinality(it);
               return Boolean.valueOf((!_isOptionalCardinality));
             }
           };
       Iterable<AbstractElement> _filter =
           IterableExtensions.<AbstractElement>filter(_elements, _function);
       final int mandatoryContent = IterableExtensions.size(_filter);
       StringConcatenation _builder = new StringConcatenation();
       _builder.append("(");
       _builder.newLine();
       _builder.append("\t");
       _builder.append("{ ");
       _builder.newLine();
       _builder.append("\t  ");
       _builder.append("getUnorderedGroupHelper().enter(grammarAccess.");
       UnorderedGroup _originalElement =
           AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it);
       String _gaRuleElementAccessor = this._grammarAccess.gaRuleElementAccessor(_originalElement);
       _builder.append(_gaRuleElementAccessor, "\t  ");
       _builder.append(");");
       _builder.newLineIfNotEmpty();
       _builder.append("\t");
       _builder.append("}");
       _builder.newLine();
       _builder.append("\t");
       _builder.append("(");
       _builder.newLine();
       _builder.append("\t\t");
       _builder.append("(");
       _builder.newLine();
       {
         EList<AbstractElement> _elements_1 = it.getElements();
         Iterable<Pair<Integer, AbstractElement>> _indexed =
             IterableExtensions.<AbstractElement>indexed(_elements_1);
         boolean _hasElements = false;
         for (final Pair<Integer, AbstractElement> element : _indexed) {
           if (!_hasElements) {
             _hasElements = true;
           } else {
             _builder.appendImmediate("|", "");
           }
           _builder.append("(");
           _builder.newLine();
           _builder.append("\t");
           _builder.append("{getUnorderedGroupHelper().canSelect(grammarAccess.");
           UnorderedGroup _originalElement_1 =
               AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it);
           String _gaRuleElementAccessor_1 =
               this._grammarAccess.gaRuleElementAccessor(_originalElement_1);
           _builder.append(_gaRuleElementAccessor_1, "\t");
           _builder.append(", ");
           Integer _key = element.getKey();
           _builder.append(_key, "\t");
           _builder.append(")}?=>(");
           _builder.newLineIfNotEmpty();
           _builder.append("\t\t");
           _builder.append("{");
           _builder.newLine();
           _builder.append("\t\t\t");
           _builder.append("getUnorderedGroupHelper().select(grammarAccess.");
           UnorderedGroup _originalElement_2 =
               AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it);
           String _gaRuleElementAccessor_2 =
               this._grammarAccess.gaRuleElementAccessor(_originalElement_2);
           _builder.append(_gaRuleElementAccessor_2, "\t\t\t");
           _builder.append(", ");
           Integer _key_1 = element.getKey();
           _builder.append(_key_1, "\t\t\t");
           _builder.append(");");
           _builder.newLineIfNotEmpty();
           _builder.append("\t\t");
           _builder.append("}");
           _builder.newLine();
           _builder.append("\t\t\t\t\t");
           _builder.append("({true}?=>(");
           AbstractElement _value = element.getValue();
           String _ebnf2 = this.ebnf2(_value, options, supportActions);
           _builder.append(_ebnf2, "\t\t\t\t\t");
           _builder.append("))");
           {
             AbstractElement _value_1 = element.getValue();
             boolean _isMultipleCardinality = GrammarUtil.isMultipleCardinality(_value_1);
             if (_isMultipleCardinality) {
               _builder.append("+");
             }
           }
           _builder.newLineIfNotEmpty();
           _builder.append("\t\t");
           _builder.append("{ ");
           _builder.newLine();
           _builder.append("\t\t\t");
           _builder.append("getUnorderedGroupHelper().returnFromSelection(grammarAccess.");
           UnorderedGroup _originalElement_3 =
               AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it);
           String _gaRuleElementAccessor_3 =
               this._grammarAccess.gaRuleElementAccessor(_originalElement_3);
           _builder.append(_gaRuleElementAccessor_3, "\t\t\t");
           _builder.append(");");
           _builder.newLineIfNotEmpty();
           _builder.append("\t\t");
           _builder.append("}");
           _builder.newLine();
           _builder.append("\t");
           _builder.append(")");
           _builder.newLine();
           _builder.append(")");
           _builder.newLine();
         }
       }
       _builder.append("\t\t");
       _builder.append(")");
       {
         if ((mandatoryContent != 0)) {
           _builder.append("+");
           _builder.newLineIfNotEmpty();
           _builder.append("\t\t");
           _builder.append("{getUnorderedGroupHelper().canLeave(grammarAccess.");
           UnorderedGroup _originalElement_4 =
               AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it);
           String _gaRuleElementAccessor_4 =
               this._grammarAccess.gaRuleElementAccessor(_originalElement_4);
           _builder.append(_gaRuleElementAccessor_4, "\t\t");
           _builder.append(")}?");
         } else {
           _builder.append("*");
         }
       }
       _builder.newLineIfNotEmpty();
       _builder.append("\t");
       _builder.append(")");
       _builder.newLine();
       _builder.append(")");
       _builder.newLine();
       _builder.append("\t");
       _builder.append("{ ");
       _builder.newLine();
       _builder.append("\t  ");
       _builder.append("getUnorderedGroupHelper().leave(grammarAccess.");
       UnorderedGroup _originalElement_5 =
           AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it);
       String _gaRuleElementAccessor_5 =
           this._grammarAccess.gaRuleElementAccessor(_originalElement_5);
       _builder.append(_gaRuleElementAccessor_5, "\t  ");
       _builder.append(");");
       _builder.newLineIfNotEmpty();
       _builder.append("\t");
       _builder.append("}");
       _builder.newLine();
       _xblockexpression = _builder.toString();
     }
     _xifexpression = _xblockexpression;
   } else {
     _xifexpression = super._ebnf2(it, options, supportActions);
   }
   return _xifexpression;
 }