@Override public boolean hasAltSpecificContexts() { return super.hasAltSpecificContexts() || getAltLabels()!=null; }
@Override public boolean hasAltSpecificContexts() { return super.hasAltSpecificContexts() || getAltLabels()!=null; }
@Override public boolean hasAltSpecificContexts() { return super.hasAltSpecificContexts() || getAltLabels()!=null; }
@Override public boolean hasAltSpecificContexts() { return super.hasAltSpecificContexts() || getAltLabels()!=null; }
@Override public boolean hasAltSpecificContexts() { return super.hasAltSpecificContexts() || getAltLabels()!=null; }
public void addDispatchMethods(Rule r) { dispatchMethods = new ArrayList<DispatchMethod>(); if ( !r.hasAltSpecificContexts() ) { // no enter/exit for this ruleContext if rule has labels if ( factory.getGrammar().tool.gen_listener ) { dispatchMethods.add(new ListenerDispatchMethod(factory, true)); dispatchMethods.add(new ListenerDispatchMethod(factory, false)); } if ( factory.getGrammar().tool.gen_visitor ) { dispatchMethods.add(new VisitorDispatchMethod(factory)); } } }
public void addDispatchMethods(Rule r) { dispatchMethods = new ArrayList<DispatchMethod>(); if ( !r.hasAltSpecificContexts() ) { // no enter/exit for this ruleContext if rule has labels if ( factory.getGrammar().tool.gen_listener ) { dispatchMethods.add(new ListenerDispatchMethod(factory, true)); dispatchMethods.add(new ListenerDispatchMethod(factory, false)); } if ( factory.getGrammar().tool.gen_visitor ) { dispatchMethods.add(new VisitorDispatchMethod(factory)); } } }
public void addDispatchMethods(Rule r) { dispatchMethods = new ArrayList<DispatchMethod>(); if ( !r.hasAltSpecificContexts() ) { // no enter/exit for this ruleContext if rule has labels if ( factory.getGrammar().tool.gen_listener ) { dispatchMethods.add(new ListenerDispatchMethod(factory, true)); dispatchMethods.add(new ListenerDispatchMethod(factory, false)); } if ( factory.getGrammar().tool.gen_visitor ) { dispatchMethods.add(new VisitorDispatchMethod(factory)); } } }
public void addDispatchMethods(Rule r) { dispatchMethods = new ArrayList<DispatchMethod>(); if ( !r.hasAltSpecificContexts() ) { // no enter/exit for this ruleContext if rule has labels if ( factory.getGrammar().tool.gen_listener ) { dispatchMethods.add(new ListenerDispatchMethod(factory, true)); dispatchMethods.add(new ListenerDispatchMethod(factory, false)); } if ( factory.getGrammar().tool.gen_visitor ) { dispatchMethods.add(new VisitorDispatchMethod(factory)); } } }
public void addDispatchMethods(Rule r) { dispatchMethods = new ArrayList<DispatchMethod>(); if ( !r.hasAltSpecificContexts() ) { // no enter/exit for this ruleContext if rule has labels if ( factory.getGrammar().tool.gen_listener ) { dispatchMethods.add(new ListenerDispatchMethod(factory, true)); dispatchMethods.add(new ListenerDispatchMethod(factory, false)); } if ( factory.getGrammar().tool.gen_visitor ) { dispatchMethods.add(new VisitorDispatchMethod(factory)); } } }
public StructDecl(OutputModelFactory factory, Rule r) { super(factory, factory.getTarget().getRuleFunctionContextStructName(r)); addDispatchMethods(r); derivedFromName = r.name; provideCopyFrom = r.hasAltSpecificContexts(); }
/** Make sure a label doesn't conflict with another symbol. * Labels must not conflict with: rules, tokens, scope names, * return values, parameters, and rule-scope dynamic attributes * defined in surrounding rule. Also they must have same type * for repeated defs. */ public void checkForLabelConflicts(Collection<Rule> rules) { for (Rule r : rules) { checkForAttributeConflicts(r); Map<String, LabelElementPair> labelNameSpace = new HashMap<String, LabelElementPair>(); for (int i=1; i<=r.numberOfAlts; i++) { if (r.hasAltSpecificContexts()) { labelNameSpace.clear(); } Alternative a = r.alt[i]; for (List<LabelElementPair> pairs : a.labelDefs.values() ) { for (LabelElementPair p : pairs) { checkForLabelConflict(r, p.label); String name = p.label.getText(); LabelElementPair prev = labelNameSpace.get(name); if ( prev==null ) labelNameSpace.put(name, p); else checkForTypeMismatch(prev, p); } } } } }
Alternative a = r.alt[i]; for (List<LabelElementPair> pairs : a.labelDefs.values()) { if (r.hasAltSpecificContexts()) {
Alternative a = r.alt[i]; for (List<LabelElementPair> pairs : a.labelDefs.values()) { if (r.hasAltSpecificContexts()) {
Alternative a = r.alt[i]; for (List<LabelElementPair> pairs : a.labelDefs.values()) { if (r.hasAltSpecificContexts()) {
/** Make sure a label doesn't conflict with another symbol. * Labels must not conflict with: rules, tokens, scope names, * return values, parameters, and rule-scope dynamic attributes * defined in surrounding rule. Also they must have same type * for repeated defs. */ public void checkForLabelConflicts(Collection<Rule> rules) { for (Rule r : rules) { checkForAttributeConflicts(r); Map<String, LabelElementPair> labelNameSpace = new HashMap<String, LabelElementPair>(); for (int i=1; i<=r.numberOfAlts; i++) { if (r.hasAltSpecificContexts()) { labelNameSpace.clear(); } Alternative a = r.alt[i]; for (List<LabelElementPair> pairs : a.labelDefs.values() ) { for (LabelElementPair p : pairs) { checkForLabelConflict(r, p.label); String name = p.label.getText(); LabelElementPair prev = labelNameSpace.get(name); if ( prev==null ) labelNameSpace.put(name, p); else checkForTypeMismatch(prev, p); } } } } }
public StructDecl(OutputModelFactory factory, Rule r) { super(factory, factory.getGenerator().getTarget().getRuleFunctionContextStructName(r)); addDispatchMethods(r); derivedFromName = r.name; provideCopyFrom = r.hasAltSpecificContexts(); }
public StructDecl(OutputModelFactory factory, Rule r) { super(factory, factory.getGenerator().getTarget().getRuleFunctionContextStructName(r)); addDispatchMethods(r); derivedFromName = r.name; provideCopyFrom = r.hasAltSpecificContexts(); }
public StructDecl(OutputModelFactory factory, Rule r) { super(factory, factory.getGenerator().getTarget().getRuleFunctionContextStructName(r)); addDispatchMethods(r); derivedFromName = r.name; provideCopyFrom = r.hasAltSpecificContexts(); }
public StructDecl(OutputModelFactory factory, Rule r) { super(factory, factory.getGenerator().getTarget().getRuleFunctionContextStructName(r)); addDispatchMethods(r); derivedFromName = r.name; provideCopyFrom = r.hasAltSpecificContexts(); }