Java Doc for Rule.java in  » Parser » antlr-3.0.1 » org » antlr » tool » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Parser » antlr 3.0.1 » org.antlr.tool 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.antlr.tool.Rule

Rule
public class Rule (Code)
Combine the info associated with a rule


Field Summary
public  GrammarASTEORNode
    
protected  Map<String, GrammarAST>actions
     Map a name to an action for this rule.
protected  Map<String, List<GrammarAST>>[]altToRuleRefMap
     Each alt has a Map>; range 1..numberOfAlts So, if there are 3 expr refs in a rule's alt number 2, you'll have altToRuleRef[2].get("expr").size()==3.
protected  Map<String, List<GrammarAST>>[]altToTokenRefMap
     Each alt has a Map>; range 1..numberOfAlts. So, if there are 3 ID refs in a rule's alt number 2, you'll have altToTokenRef[2].get("ID").size()==3.
protected  boolean[]altsWithRewrites
     Track which alts have rewrite rules associated with them.
public  GrammarASTargActionAST
    
public  LinkedHashMapcharLabels
    
public  Grammargrammar
    
public  intindex
    
protected  List<GrammarAST>inlineActions
     Track all executable actions other than named actions like @init.
public  booleanisSynPred
    
protected  Map<String, Grammar.LabelElementPair>labelNameSpace
     All labels go in here (plus being split per the above lists) to catch dup label and label type mismatches.
final public static  SetlegalOptions
    
public  Stringmodifier
    
public  Stringname
    
public  intnumberOfAlts
    
protected  Mapoptions
    
public  AttributeScopeparameterScope
    
public  booleanreferencedPredefinedRuleAttributes
     Do not generate start, stop etc...
public  AttributeScopereturnScope
    
public  LinkedHashMapruleLabels
    
public  LinkedHashMapruleListLabels
    
public  AttributeScoperuleScope
    
public  NFAStatestartState
    
public  NFAStatestopState
    
public  LinkedHashMaptokenLabels
    
public  LinkedHashMaptokenListLabels
    
public  GrammarASTtree
    
public  ListuseScopes
    

Constructor Summary
public  Rule(Grammar grammar, String ruleName, int ruleIndex, int numberOfAlts)
    

Method Summary
public  voiddefineLabel(antlr.Token label, GrammarAST elementRef, int type)
    
public  voiddefineNamedAction(GrammarAST ampersandAST, GrammarAST nameAST, GrammarAST actionAST)
     Given @scope::name {action} define it for this grammar.
public  Map<String, GrammarAST>getActions()
    
public  SetgetAllRuleRefsInAltsWithRewrites()
     For use with rewrite rules, we must track all rule AST results on the left-hand-side; so we need Lists.
public  SetgetAllTokenRefsInAltsWithRewrites()
     For use with rewrite rules, we must track all tokens matched on the left-hand-side; so we need Lists.
public  AttributeScopegetAttributeScope(String name)
    
public  StringgetElementLabel(String refdSymbol, int outerAltNum, CodeGenerator generator)
     For references to tokens rather than by label such as $ID, we need to get the existing label for the ID ref or create a new one.
public  booleangetHasMultipleReturnValues()
     If a rule has no user-defined return values and nobody references it's start/stop (predefined attributes), then there is no need to define a struct; otherwise for now we assume a struct.
public  booleangetHasReturnValue()
    
public  booleangetHasSingleReturnValue()
    
public  List<GrammarAST>getInlineActions()
    
public  Grammar.LabelElementPairgetLabel(String name)
    
public  AttributeScopegetLocalAttributeScope(String name)
    
public  Grammar.LabelElementPairgetRuleLabel(String name)
    
public  MapgetRuleLabels()
    
public  Grammar.LabelElementPairgetRuleListLabel(String name)
    
public  MapgetRuleListLabels()
    
public  ListgetRuleRefsInAlt(String ref, int outerAltNum)
    
public  SetgetRuleRefsInAlt(int outerAltNum)
    
public  StringgetSingleValueReturnName()
    
public  StringgetSingleValueReturnType()
    
public  Grammar.LabelElementPairgetTokenLabel(String name)
    
public  Grammar.LabelElementPairgetTokenListLabel(String name)
    
public  ListgetTokenRefsInAlt(String ref, int outerAltNum)
    
public  SetgetTokenRefsInAlt(int altNum)
    
public  booleanhasRewrite(int i)
    
public  voidsetActions(Map<String, GrammarAST> actions)
    
public  StringsetOption(String key, Object value, antlr.Token optionsStartToken)
     Save the option key/value pair and process it; return the key or null if invalid option.
public  voidsetOptions(Map options, antlr.Token optionsStartToken)
    
public  StringtoString()
    
public  voidtrackAltsWithRewrites(GrammarAST altAST, int outerAltNum)
     Track which rules have rewrite rules.
public  voidtrackInlineAction(GrammarAST actionAST)
    
public  voidtrackRuleReferenceInAlt(GrammarAST refAST, int outerAltNum)
    
public  voidtrackTokenReferenceInAlt(GrammarAST refAST, int outerAltNum)
     Track a token ID or literal like '+' and "void" as having been referenced somewhere within the alts (not rewrite sections) of a rule.

Field Detail
EORNode
public GrammarAST EORNode(Code)



actions
protected Map<String, GrammarAST> actions(Code)
Map a name to an action for this rule. Currently init is only one we use, but we can add more in future. The code generator will use this to fill holes in the rule template. I track the AST node for the action in case I need the line number for errors. A better name is probably namedActions, but I don't want everyone to have to change their code gen templates now.



altToRuleRefMap
protected Map<String, List<GrammarAST>>[] altToRuleRefMap(Code)
Each alt has a Map>; range 1..numberOfAlts So, if there are 3 expr refs in a rule's alt number 2, you'll have altToRuleRef[2].get("expr").size()==3. This is used to see if $expr is ok. There must be only one expr reference in the alt for $expr to be ok in an action--must be unique. Rewrite rules force tracking of all rule result ASTs. 1..n



altToTokenRefMap
protected Map<String, List<GrammarAST>>[] altToTokenRefMap(Code)
Each alt has a Map>; range 1..numberOfAlts. So, if there are 3 ID refs in a rule's alt number 2, you'll have altToTokenRef[2].get("ID").size()==3. This is used to see if $ID is ok. There must be only one ID reference in the alt for $ID to be ok in an action--must be unique. This also tracks '+' and "int" literal token references (if not in LEXER). Rewrite rules force tracking of all tokens.



altsWithRewrites
protected boolean[] altsWithRewrites(Code)
Track which alts have rewrite rules associated with them. 1..n



argActionAST
public GrammarAST argActionAST(Code)
For convenience, track the argument def AST action node if any



charLabels
public LinkedHashMap charLabels(Code)
A list of all LabelElementPair attached to single char literals like x='a'



grammar
public Grammar grammar(Code)
To which grammar does this belong?



index
public int index(Code)



inlineActions
protected List<GrammarAST> inlineActions(Code)
Track all executable actions other than named actions like @init. Also tracks exception handlers, predicates, and rewrite rewrites. We need to examine these actions before code generation so that we can detect refs to $rule.attr etc...



isSynPred
public boolean isSynPred(Code)



labelNameSpace
protected Map<String, Grammar.LabelElementPair> labelNameSpace(Code)
All labels go in here (plus being split per the above lists) to catch dup label and label type mismatches.



legalOptions
final public static Set legalOptions(Code)



modifier
public String modifier(Code)



name
public String name(Code)



numberOfAlts
public int numberOfAlts(Code)



options
protected Map options(Code)
This rule's options



parameterScope
public AttributeScope parameterScope(Code)



referencedPredefinedRuleAttributes
public boolean referencedPredefinedRuleAttributes(Code)
Do not generate start, stop etc... in a return value struct unless somebody references $r.start somewhere.



returnScope
public AttributeScope returnScope(Code)
The return values of a rule and predefined rule attributes



ruleLabels
public LinkedHashMap ruleLabels(Code)
A list of all LabelElementPair attached to rule references like f=field



ruleListLabels
public LinkedHashMap ruleListLabels(Code)
A list of all rule ref list LabelElementPair like ids+=expr



ruleScope
public AttributeScope ruleScope(Code)
the attributes defined with "scope {...}" inside a rule



startState
public NFAState startState(Code)



stopState
public NFAState stopState(Code)



tokenLabels
public LinkedHashMap tokenLabels(Code)
A list of all LabelElementPair attached to tokens like id=ID



tokenListLabels
public LinkedHashMap tokenListLabels(Code)
A list of all Token list LabelElementPair like ids+=ID



tree
public GrammarAST tree(Code)
The AST representing the whole rule



useScopes
public List useScopes(Code)
A list of scope names (String) used by this rule




Constructor Detail
Rule
public Rule(Grammar grammar, String ruleName, int ruleIndex, int numberOfAlts)(Code)




Method Detail
defineLabel
public void defineLabel(antlr.Token label, GrammarAST elementRef, int type)(Code)



defineNamedAction
public void defineNamedAction(GrammarAST ampersandAST, GrammarAST nameAST, GrammarAST actionAST)(Code)
Given @scope::name {action} define it for this grammar. Later, the code generator will ask for the actions table.



getActions
public Map<String, GrammarAST> getActions()(Code)



getAllRuleRefsInAltsWithRewrites
public Set getAllRuleRefsInAltsWithRewrites()(Code)
For use with rewrite rules, we must track all rule AST results on the left-hand-side; so we need Lists. This is a unique list of all rule results for which the rule needs a list of results.



getAllTokenRefsInAltsWithRewrites
public Set getAllTokenRefsInAltsWithRewrites()(Code)
For use with rewrite rules, we must track all tokens matched on the left-hand-side; so we need Lists. This is a unique list of all token types for which the rule needs a list of tokens. This is called from the rule template not directly by the code generator.



getAttributeScope
public AttributeScope getAttributeScope(String name)(Code)
Return the scope containing name



getElementLabel
public String getElementLabel(String refdSymbol, int outerAltNum, CodeGenerator generator)(Code)
For references to tokens rather than by label such as $ID, we need to get the existing label for the ID ref or create a new one.



getHasMultipleReturnValues
public boolean getHasMultipleReturnValues()(Code)
If a rule has no user-defined return values and nobody references it's start/stop (predefined attributes), then there is no need to define a struct; otherwise for now we assume a struct. A rule also has multiple return values if you are building trees or templates.



getHasReturnValue
public boolean getHasReturnValue()(Code)



getHasSingleReturnValue
public boolean getHasSingleReturnValue()(Code)



getInlineActions
public List<GrammarAST> getInlineActions()(Code)



getLabel
public Grammar.LabelElementPair getLabel(String name)(Code)



getLocalAttributeScope
public AttributeScope getLocalAttributeScope(String name)(Code)
Get the arg, return value, or predefined property for this rule



getRuleLabel
public Grammar.LabelElementPair getRuleLabel(String name)(Code)



getRuleLabels
public Map getRuleLabels()(Code)



getRuleListLabel
public Grammar.LabelElementPair getRuleListLabel(String name)(Code)



getRuleListLabels
public Map getRuleListLabels()(Code)



getRuleRefsInAlt
public List getRuleRefsInAlt(String ref, int outerAltNum)(Code)



getRuleRefsInAlt
public Set getRuleRefsInAlt(int outerAltNum)(Code)



getSingleValueReturnName
public String getSingleValueReturnName()(Code)



getSingleValueReturnType
public String getSingleValueReturnType()(Code)



getTokenLabel
public Grammar.LabelElementPair getTokenLabel(String name)(Code)



getTokenListLabel
public Grammar.LabelElementPair getTokenListLabel(String name)(Code)



getTokenRefsInAlt
public List getTokenRefsInAlt(String ref, int outerAltNum)(Code)



getTokenRefsInAlt
public Set getTokenRefsInAlt(int altNum)(Code)



hasRewrite
public boolean hasRewrite(int i)(Code)



setActions
public void setActions(Map<String, GrammarAST> actions)(Code)



setOption
public String setOption(String key, Object value, antlr.Token optionsStartToken)(Code)
Save the option key/value pair and process it; return the key or null if invalid option.



setOptions
public void setOptions(Map options, antlr.Token optionsStartToken)(Code)



toString
public String toString()(Code)



trackAltsWithRewrites
public void trackAltsWithRewrites(GrammarAST altAST, int outerAltNum)(Code)
Track which rules have rewrite rules. Pass in the ALT node for the alt so we can check for problems when output=template, rewrite=true, and grammar type is tree parser.



trackInlineAction
public void trackInlineAction(GrammarAST actionAST)(Code)



trackRuleReferenceInAlt
public void trackRuleReferenceInAlt(GrammarAST refAST, int outerAltNum)(Code)



trackTokenReferenceInAlt
public void trackTokenReferenceInAlt(GrammarAST refAST, int outerAltNum)(Code)
Track a token ID or literal like '+' and "void" as having been referenced somewhere within the alts (not rewrite sections) of a rule. This differs from Grammar.altReferencesTokenID(), which tracks all token IDs to check for token IDs without corresponding lexer rules.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.