public AttributeScope createParameterScope(String ruleName, Token argAction) { AttributeScope scope = new AttributeScope(this, ruleName, argAction); scope.isParameterScope = true; return scope; }
public Perl5Target() { targetCharValueEscape['$'] = "\\$"; targetCharValueEscape['@'] = "\\@"; targetCharValueEscape['%'] = "\\%"; AttributeScope.tokenScope.addAttribute("self", null); RuleLabelScope.predefinedLexerRulePropertiesScope.addAttribute("self", null); }
/** If you label a rule reference, you can access that rule's * return values as well as any predefined attributes. */ public Attribute getAttribute(String name) { AttributeScope rulePropertiesScope = RuleLabelScope.grammarTypeToRulePropertiesScope[grammar.type]; if ( rulePropertiesScope.getAttribute(name)!=null ) { return rulePropertiesScope.getAttribute(name); } if ( referencedRule.returnScope!=null ) { return referencedRule.returnScope.getAttribute(name); } return null; } }
@Override public String toString() { return (isDynamicGlobalScope?"global ":"")+getName()+":"+attributes; } }
AttributeScope scope = grammar.defineGlobalScope((name!=null?name.getText():null),attrs.getToken()); scope.isDynamicGlobalScope = true; scope.addAttributes((attrs!=null?attrs.getText():null), ';'); for (GrammarAST action : AttributeScopeActions_stack.peek().actions.keySet()) scope.defineNamedAction(action, AttributeScopeActions_stack.peek().actions.get(action));
protected void checkForRuleArgumentAndReturnValueConflicts(Rule r) { if ( r.returnScope!=null ) { Set conflictingKeys = r.returnScope.intersection(r.parameterScope); if (conflictingKeys!=null) { for (Iterator it = conflictingKeys.iterator(); it.hasNext();) { String key = (String) it.next(); ErrorManager.grammarError( ErrorManager.MSG_ARG_RETVAL_CONFLICT, grammar, r.tree.getToken(), key, r.name); } } } }
/** Return the set of keys that collide from * this and other. */ public Set<String> intersection(AttributeScope other) { if ( other==null || other.size()==0 || size()==0 ) { return null; } Set<String> inter = new HashSet<String>(); Set<String> thisKeys = attributes.keySet(); for (String key : thisKeys) { if ( other.attributes.get(key)!=null ) { inter.add(key); } } if ( inter.isEmpty() ) { return null; } return inter; }
List attributes = r.ruleScope.getAttributes(); for (int j = 0; j < attributes.size(); j++) { Attribute attribute = (Attribute) attributes.get(j);
public Collection<String> getNamesFromArgAction(Token t) { AttributeScope returnScope = grammar.createReturnScope("",t); returnScope.addAttributes(t.getText(), ','); return returnScope.attributes.keySet(); }
@Override public String toString() { return (isDynamicGlobalScope?"global ":"")+getName()+":"+attributes; } }
AttributeScope scope = grammar.defineGlobalScope((name!=null?name.getText():null),attrs.getToken()); scope.isDynamicGlobalScope = true; scope.addAttributes((attrs!=null?attrs.getText():null), ';'); for (GrammarAST action : AttributeScopeActions_stack.peek().actions.keySet()) scope.defineNamedAction(action, AttributeScopeActions_stack.peek().actions.get(action));
protected void checkForRuleArgumentAndReturnValueConflicts(Rule r) { if ( r.returnScope!=null ) { Set conflictingKeys = r.returnScope.intersection(r.parameterScope); if (conflictingKeys!=null) { for (Iterator it = conflictingKeys.iterator(); it.hasNext();) { String key = (String) it.next(); ErrorManager.grammarError( ErrorManager.MSG_ARG_RETVAL_CONFLICT, grammar, r.tree.getToken(), key, r.name); } } } }
/** Return the set of keys that collide from * this and other. */ public Set<String> intersection(AttributeScope other) { if ( other==null || other.size()==0 || size()==0 ) { return null; } Set<String> inter = new HashSet<String>(); Set<String> thisKeys = attributes.keySet(); for (String key : thisKeys) { if ( other.attributes.get(key)!=null ) { inter.add(key); } } if ( inter.isEmpty() ) { return null; } return inter; }
List attributes = r.ruleScope.getAttributes(); for (int j = 0; j < attributes.size(); j++) { Attribute attribute = (Attribute) attributes.get(j);
public Collection<String> getNamesFromArgAction(Token t) { AttributeScope returnScope = grammar.createReturnScope("",t); returnScope.addAttributes(t.getText(), ','); return returnScope.attributes.keySet(); }
/** If you label a rule reference, you can access that rule's * return values as well as any predefined attributes. */ public Attribute getAttribute(String name) { AttributeScope rulePropertiesScope = RuleLabelScope.grammarTypeToRulePropertiesScope[grammar.type]; if ( rulePropertiesScope.getAttribute(name)!=null ) { return rulePropertiesScope.getAttribute(name); } if ( referencedRule.returnScope!=null ) { return referencedRule.returnScope.getAttribute(name); } return null; } }
public AttributeScope createReturnScope(String ruleName, Token retAction) { AttributeScope scope = new AttributeScope(this, ruleName, retAction); scope.isReturnScope = true; return scope; }
public String toString() { return (isDynamicGlobalScope?"global ":"")+getName()+":"+attributes; } }
r.ruleScope = grammar.createRuleScope(r.name,attrs.getToken()); r.ruleScope.isDynamicRuleScope = true; r.ruleScope.addAttributes((attrs!=null?attrs.getText():null), ';'); for (GrammarAST action : AttributeScopeActions_stack.peek().actions.keySet()) r.ruleScope.defineNamedAction(action, AttributeScopeActions_stack.peek().actions.get(action));
public Perl5Target() { targetCharValueEscape['$'] = "\\$"; targetCharValueEscape['@'] = "\\@"; targetCharValueEscape['%'] = "\\%"; AttributeScope.tokenScope.addAttribute("self", null); RuleLabelScope.predefinedLexerRulePropertiesScope.addAttribute("self", null); }