Java Doc for DecisionProbe.java in  » Parser » antlr-3.0.1 » org » antlr » analysis » 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.analysis 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.antlr.analysis.DecisionProbe

DecisionProbe
public class DecisionProbe (Code)
Collection of information about what is wrong with a decision as discovered while building the DFA predictor. The information is collected during NFA->DFA conversion and, while some of this is available elsewhere, it is nice to have it all tracked in one spot so a great error message can be easily had. I also like the fact that this object tracks it all for later perusing to make an excellent error message instead of lots of imprecise on-the-fly warnings (during conversion). A decision normally only has one problem; e.g., some input sequence can be matched by multiple alternatives. Unfortunately, some decisions such as a : ( A | B ) | ( A | B ) | A ; have multiple problems. So in general, you should approach a decision as having multiple flaws each one uniquely identified by a DFAState. For example, statesWithSyntacticallyAmbiguousAltsSet tracks the set of all DFAStates where ANTLR has discovered a problem. Recall that a decision is represented internall with a DFA comprised of multiple states, each of which could potentially have problems. Because of this, you need to iterate over this list of DFA states. You'll note that most of the informational methods like getSampleNonDeterministicInputSequence() require a DFAState. This state will be one of the iterated states from stateToSyntacticallyAmbiguousAltsSet. This class is not thread safe due to shared use of visited maps etc... Only one thread should really need to access one DecisionProbe anyway.


Field Summary
final public static  IntegerREACHABLE_BUSY
    
final public static  IntegerREACHABLE_NO
    
final public static  IntegerREACHABLE_YES
    
protected  SetaltsWithProblem
     The overall list of alts within the decision that have at least one conflicting input sequence.
protected  SetdanglingStates
     The set of states w/o emanating edges and w/o resolving sem preds.
public  DFAdfa
    
protected  booleannonLLStarDecision
     If decision with > 1 alt has recursion in > 1 alt, it's nonregular lookahead.
protected  MapstateReachable
     Used to find paths through syntactically ambiguous DFA.
protected  MapstateToAltSetWithSemanticPredicatesMap
     Track the predicates for each alt per DFA state; more than one DFA state might have syntactically ambig alt prediction.
protected  MapstateToIncompletelyCoveredAltsMap
     Map> Tracks alts insufficiently covered. For example, p1||true gets reduced to true and so leaves whole alt uncovered.
protected  MapstateToLeftRecursiveConfigurationsMap
     Left recursion discovered.
protected  MapstateToRecursiveOverflowConfigurationsMap
     Recursion is limited to a particular depth.
protected  MapstateToSyntacticallyAmbiguousTokensRuleAltsMap
     Track just like stateToSyntacticallyAmbiguousAltsMap, but only for nondeterminisms that arise in the Tokens rule such as keyword vs ID rule.
protected  SetstatesResolvedWithSemanticPredicatesSet
     Was a syntactic ambiguity resolved with predicates? Any DFA state that predicts more than one alternative, must be resolved with predicates or it should be reported to the user.
protected  SetstatesVisitedAtInputDepth
     Used while finding a path through an NFA whose edge labels match an input sequence.
protected  SetstatesVisitedDuringSampleSequence
    
protected  SetstatesWithSyntacticallyAmbiguousAltsSet
     Track all DFA states with nondeterministic alternatives. By reaching the same DFA state, a path through the NFA for some input is able to reach the same NFA state by starting at more than one alternative's left edge.
protected  booleanterminated
    
public static  booleanverbose
    

Constructor Summary
public  DecisionProbe(DFA dfa)
    

Method Summary
public  booleananalysisAborted()
    
public  booleananalysisOverflowed()
    
protected  SetgetDFAPathStatesToTarget(DFAState targetState)
    
public  SetgetDFAStatesWithSyntacticallyAmbiguousAlts()
     Return all DFA states in this DFA that have NFA configurations that conflict.
public  SetgetDanglingStates()
     return set of states w/o emanating edges and w/o resolving sem preds.
public  StringgetDescription()
     Return a string like "3:22: ( A {;} | B )" that describes this decision.
public  SetgetDisabledAlternatives(DFAState d)
     Which alts were specifically turned off to resolve nondeterminisms? This is different than the unreachable alts.
public  ListgetIncompletelyCoveredAlts(DFAState d)
     Return a list of alts whose predicate context was insufficient to resolve a nondeterminism for state d.
public  StringgetInputSequenceDisplay(List labels)
     Given List
protected  booleangetNFAPath(NFAState s, int labelIndex, List labels, List path)
     Given a sample input sequence, you usually would like to know the path taken through the NFA.
public  ListgetNFAPathStatesForAlt(int firstAlt, int alt, List labels)
     Given an alternative associated with a nondeterministic DFA state, find the path of NFA states associated with the labels sequence. Useful tracing where in the NFA, a single input sequence can be matched.
public  SetgetNonDeterministicAlts()
    
public  ListgetNonDeterministicAltsForState(DFAState targetState)
     Return the sorted list of alts that conflict within a single state.
public  SetgetNondeterministicStatesResolvedWithSemanticPredicate()
    
public  intgetNumberOfStates()
    
protected  voidgetSampleInputSequenceUsingStateSet(State startState, State targetState, Set states, List labels)
     Given a start state and a final state, find a list of edge labels between the two ignoring epsilon.
public  ListgetSampleNonDeterministicInputSequence(DFAState targetState)
     Return a List
public  SemanticContextgetSemanticContextForAlt(DFAState d, int alt)
     Each state in the DFA represents a different input sequence for an alt of the decision.
protected  StringgetStateLabelIndexKey(int s, int i)
    
public  StringgetTokenNameForTokensRuleAlt(int alt)
     From an alt number associated with artificial Tokens rule, return the name of the token that is associated with that alt.
public  ListgetUnreachableAlts()
     Get a list of all unreachable alternatives for this decision.
public  booleanisCyclic()
    
public  booleanisDeterministic()
     If no states are dead-ends, no alts are unreachable, there are no nondeterminisms unresolved by syn preds, all is ok with decision.
public  booleanisNonLLStarDecision()
    
public  booleanisReduced()
    
protected  voidissueRecursionWarnings()
    
public  voidissueWarnings()
    
protected  booleanreachesState(DFAState startState, DFAState targetState, Set states)
     Given a start state and a target state, return true if start can reach target state.
public  voidremoveRecursiveOverflowState(DFAState d)
     If a recursion overflow is resolve with predicates, then we need to shut off the warning that would be generated.
public  voidreportAltPredicateContext(DFAState d, Map altPredicateContext)
     Report the list of predicates found for each alternative; copy the list because this set gets altered later by the method tryToResolveWithSemanticPredicates() while flagging NFA configurations in d as resolved.
public  voidreportDanglingState(DFAState d)
     Report the fact that DFA state d is not a state resolved with predicates and yet it has no emanating edges.
public  voidreportEarlyTermination()
    
public  voidreportIncompletelyCoveredAlts(DFAState d, List alts)
    
public  voidreportLeftRecursion(DFAState d, NFAConfiguration leftRecursiveNFAConfiguration)
    
public  voidreportLexerRuleNondeterminism(DFAState d, Set nondeterministicAlts)
     Currently the analysis reports issues between token definitions, but we don't print out warnings in favor of just picking the first token definition found in the grammar ala lex/flex.
public  voidreportNonLLStarDecision(DFA dfa)
     Report that at least 2 alts have recursive constructs.
public  voidreportNondeterminism(DFAState d, Set nondeterministicAlts)
    
public  voidreportNondeterminismResolvedWithSemanticPredicate(DFAState d)
    
public  voidreportRecursiveOverflow(DFAState d, NFAConfiguration recursiveNFAConfiguration)
    
protected  voidstripWildCardAlts(Set disabledAlts)
     Get the last disabled alt number and check in the grammar to see if that alt is a simple wildcard.

Field Detail
REACHABLE_BUSY
final public static Integer REACHABLE_BUSY(Code)



REACHABLE_NO
final public static Integer REACHABLE_NO(Code)



REACHABLE_YES
final public static Integer REACHABLE_YES(Code)



altsWithProblem
protected Set altsWithProblem(Code)
The overall list of alts within the decision that have at least one conflicting input sequence.



danglingStates
protected Set danglingStates(Code)
The set of states w/o emanating edges and w/o resolving sem preds.



dfa
public DFA dfa(Code)



nonLLStarDecision
protected boolean nonLLStarDecision(Code)
If decision with > 1 alt has recursion in > 1 alt, it's nonregular lookahead. The decision cannot be made with a DFA. the alts are stored in altsWithProblem.



stateReachable
protected Map stateReachable(Code)
Used to find paths through syntactically ambiguous DFA.



stateToAltSetWithSemanticPredicatesMap
protected Map stateToAltSetWithSemanticPredicatesMap(Code)
Track the predicates for each alt per DFA state; more than one DFA state might have syntactically ambig alt prediction. This is Map>; that is, it maps DFA state to another map, mapping alt number to a SemanticContext (pred(s) to execute to resolve syntactic ambiguity).



stateToIncompletelyCoveredAltsMap
protected Map stateToIncompletelyCoveredAltsMap(Code)
Map> Tracks alts insufficiently covered. For example, p1||true gets reduced to true and so leaves whole alt uncovered. This maps DFA state to the set of alts



stateToLeftRecursiveConfigurationsMap
protected Map stateToLeftRecursiveConfigurationsMap(Code)
Left recursion discovered. The proposed new NFAConfiguration is recorded for the associated DFA state. Map>.



stateToRecursiveOverflowConfigurationsMap
protected Map stateToRecursiveOverflowConfigurationsMap(Code)
Recursion is limited to a particular depth. If that limit is exceeded the proposed new NFAConfiguration is recorded for the associated DFA state. Map>.



stateToSyntacticallyAmbiguousTokensRuleAltsMap
protected Map stateToSyntacticallyAmbiguousTokensRuleAltsMap(Code)
Track just like stateToSyntacticallyAmbiguousAltsMap, but only for nondeterminisms that arise in the Tokens rule such as keyword vs ID rule. The state maps to the list of Tokens rule alts that are in conflict. Map>



statesResolvedWithSemanticPredicatesSet
protected Set statesResolvedWithSemanticPredicatesSet(Code)
Was a syntactic ambiguity resolved with predicates? Any DFA state that predicts more than one alternative, must be resolved with predicates or it should be reported to the user. Set



statesVisitedAtInputDepth
protected Set statesVisitedAtInputDepth(Code)
Used while finding a path through an NFA whose edge labels match an input sequence. Tracks the input position we were at the last time at this node. If same input position, then we'd have reached same state without consuming input...probably an infinite loop. Stop. Set. The strings look like stateNumber_labelIndex.



statesVisitedDuringSampleSequence
protected Set statesVisitedDuringSampleSequence(Code)



statesWithSyntacticallyAmbiguousAltsSet
protected Set statesWithSyntacticallyAmbiguousAltsSet(Code)
Track all DFA states with nondeterministic alternatives. By reaching the same DFA state, a path through the NFA for some input is able to reach the same NFA state by starting at more than one alternative's left edge. Though, later, we may find that predicates resolve the issue, but track info anyway. Set. Note that from the DFA state, you can ask for which alts are nondeterministic.



terminated
protected boolean terminated(Code)
Did ANTLR have to terminate early on the analysis of this decision?



verbose
public static boolean verbose(Code)




Constructor Detail
DecisionProbe
public DecisionProbe(DFA dfa)(Code)




Method Detail
analysisAborted
public boolean analysisAborted()(Code)
Did the analysis complete it's work?



analysisOverflowed
public boolean analysisOverflowed()(Code)



getDFAPathStatesToTarget
protected Set getDFAPathStatesToTarget(DFAState targetState)(Code)



getDFAStatesWithSyntacticallyAmbiguousAlts
public Set getDFAStatesWithSyntacticallyAmbiguousAlts()(Code)
Return all DFA states in this DFA that have NFA configurations that conflict. You must report a problem for each state in this set because each state represents a different input sequence.



getDanglingStates
public Set getDanglingStates()(Code)
return set of states w/o emanating edges and w/o resolving sem preds. These states come about because the analysis algorithm had to terminate early to avoid infinite recursion for example (due to left recursion perhaps).



getDescription
public String getDescription()(Code)
Return a string like "3:22: ( A {;} | B )" that describes this decision.



getDisabledAlternatives
public Set getDisabledAlternatives(DFAState d)(Code)
Which alts were specifically turned off to resolve nondeterminisms? This is different than the unreachable alts. Disabled doesn't mean that the alternative is totally unreachable necessarily, it just means that for this DFA state, that alt is disabled. There may be other accept states for that alt that make an alt reachable.



getIncompletelyCoveredAlts
public List getIncompletelyCoveredAlts(DFAState d)(Code)
Return a list of alts whose predicate context was insufficient to resolve a nondeterminism for state d.



getInputSequenceDisplay
public String getInputSequenceDisplay(List labels)(Code)
Given List



getNFAPath
protected boolean getNFAPath(NFAState s, int labelIndex, List labels, List path)(Code)
Given a sample input sequence, you usually would like to know the path taken through the NFA. Return the list of NFA states visited while matching a list of labels. This cannot use the usual interpreter, which does a deterministic walk. We need to be able to take paths that are turned off during nondeterminism resolution. So, just do a depth-first walk traversing edges labeled with the current label. Return true if a path was found emanating from state s.



getNFAPathStatesForAlt
public List getNFAPathStatesForAlt(int firstAlt, int alt, List labels)(Code)
Given an alternative associated with a nondeterministic DFA state, find the path of NFA states associated with the labels sequence. Useful tracing where in the NFA, a single input sequence can be matched. For different alts, you should get different NFA paths. The first NFA state for all NFA paths will be the same: the starting NFA state of the first nondeterministic alt. Imagine (A|B|A|A): 5->9-A->o | 6->10-B->o | 7->11-A->o | 8->12-A->o There are 3 nondeterministic alts. The paths should be: 5 9 ... 5 6 7 11 ... 5 6 7 8 12 ... The NFA path matching the sample input sequence (labels) is computed using states 9, 11, and 12 rather than 5, 7, 8 because state 5, for example can get to all ambig paths. Must isolate for each alt (hence, the extra state beginning each alt in my NFA structures). Here, firstAlt=1.



getNonDeterministicAlts
public Set getNonDeterministicAlts()(Code)



getNonDeterministicAltsForState
public List getNonDeterministicAltsForState(DFAState targetState)(Code)
Return the sorted list of alts that conflict within a single state. Note that predicates may resolve the conflict.



getNondeterministicStatesResolvedWithSemanticPredicate
public Set getNondeterministicStatesResolvedWithSemanticPredicate()(Code)



getNumberOfStates
public int getNumberOfStates()(Code)
How many states does the DFA predictor have?



getSampleInputSequenceUsingStateSet
protected void getSampleInputSequenceUsingStateSet(State startState, State targetState, Set states, List labels)(Code)
Given a start state and a final state, find a list of edge labels between the two ignoring epsilon. Limit your scan to a set of states passed in. This is used to show a sample input sequence that is nondeterministic with respect to this decision. Return List



getSampleNonDeterministicInputSequence
public List getSampleNonDeterministicInputSequence(DFAState targetState)(Code)
Return a List



getSemanticContextForAlt
public SemanticContext getSemanticContextForAlt(DFAState d, int alt)(Code)
Each state in the DFA represents a different input sequence for an alt of the decision. Given a DFA state, what is the semantic predicate context for a particular alt.



getStateLabelIndexKey
protected String getStateLabelIndexKey(int s, int i)(Code)



getTokenNameForTokensRuleAlt
public String getTokenNameForTokensRuleAlt(int alt)(Code)
From an alt number associated with artificial Tokens rule, return the name of the token that is associated with that alt.



getUnreachableAlts
public List getUnreachableAlts()(Code)
Get a list of all unreachable alternatives for this decision. There may be multiple alternatives with ambiguous input sequences, but this is the overall list of unreachable alternatives (either due to conflict resolution or alts w/o accept states).



isCyclic
public boolean isCyclic()(Code)



isDeterministic
public boolean isDeterministic()(Code)
If no states are dead-ends, no alts are unreachable, there are no nondeterminisms unresolved by syn preds, all is ok with decision.



isNonLLStarDecision
public boolean isNonLLStarDecision()(Code)



isReduced
public boolean isReduced()(Code)



issueRecursionWarnings
protected void issueRecursionWarnings()(Code)



issueWarnings
public void issueWarnings()(Code)



reachesState
protected boolean reachesState(DFAState startState, DFAState targetState, Set states)(Code)
Given a start state and a target state, return true if start can reach target state. Also, compute the set of DFA states that are on a path from start to target; return in states parameter.



removeRecursiveOverflowState
public void removeRecursiveOverflowState(DFAState d)(Code)
If a recursion overflow is resolve with predicates, then we need to shut off the warning that would be generated.



reportAltPredicateContext
public void reportAltPredicateContext(DFAState d, Map altPredicateContext)(Code)
Report the list of predicates found for each alternative; copy the list because this set gets altered later by the method tryToResolveWithSemanticPredicates() while flagging NFA configurations in d as resolved.



reportDanglingState
public void reportDanglingState(DFAState d)(Code)
Report the fact that DFA state d is not a state resolved with predicates and yet it has no emanating edges. Usually this is a result of the closure/reach operations being unable to proceed



reportEarlyTermination
public void reportEarlyTermination()(Code)



reportIncompletelyCoveredAlts
public void reportIncompletelyCoveredAlts(DFAState d, List alts)(Code)



reportLeftRecursion
public void reportLeftRecursion(DFAState d, NFAConfiguration leftRecursiveNFAConfiguration)(Code)



reportLexerRuleNondeterminism
public void reportLexerRuleNondeterminism(DFAState d, Set nondeterministicAlts)(Code)
Currently the analysis reports issues between token definitions, but we don't print out warnings in favor of just picking the first token definition found in the grammar ala lex/flex.



reportNonLLStarDecision
public void reportNonLLStarDecision(DFA dfa)(Code)
Report that at least 2 alts have recursive constructs. There is no way to build a DFA so we terminated.



reportNondeterminism
public void reportNondeterminism(DFAState d, Set nondeterministicAlts)(Code)



reportNondeterminismResolvedWithSemanticPredicate
public void reportNondeterminismResolvedWithSemanticPredicate(DFAState d)(Code)



reportRecursiveOverflow
public void reportRecursiveOverflow(DFAState d, NFAConfiguration recursiveNFAConfiguration)(Code)



stripWildCardAlts
protected void stripWildCardAlts(Set disabledAlts)(Code)
Get the last disabled alt number and check in the grammar to see if that alt is a simple wildcard. If so, treat like an else clause and don't emit the error. Strip out the last alt if it's wildcard.



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.