Java Doc for Annotator.java in  » Parser » Rats-Parser-Generators » xtc » parser » 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 » Rats Parser Generators » xtc.parser 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   xtc.tree.Visitor
      xtc.parser.Annotator

Annotator
public class Annotator extends Visitor (Code)
Visitor to inject source code annotations into a grammar.

This visitor distinguishes between bindable elements, i.e., elements that would contribute to the value of a generic production, and valuable element, i.e., elements that can be rewritten to have a semantic value. The latter include voided elements and references to void productions that consume the input.

For directly left-recursive alternatives in generic productions, this visitor may annotate the last sequence with the Properties.FORMATTING property, indicating valuable elements that need to be captured in the promise generated by DirectLeftRecurser .

This visitor assumes that the entire grammar is contained in a single module, that the grammar has been tokenized, and that productions that may consume the input have been marked.
See Also:   Tokenizer
See Also:   Analyzer.consumesInput(Element)
author:
   Robert Grimm
version:
   $Revision: 1.30 $


Inner Class :public static class Index
Inner Class :public static class IndexPair
Inner Class :public class Detector extends Visitor
Inner Class :public class Rewriter extends Visitor

Field Summary
final public static  StringMARKER
     The marker for synthetic variables.
protected  List<List<Binding>>after
     The list of bindings for valuable elements after the regular, bindable value, organized as a stack of copies.
final protected  Analyzeranalyzer
     The analyzer.
protected  List<List<Binding>>before
     The list of bindings for valuable elements before the regular, bindable value, organized as a stack of copies.
protected  List<Index>elementIdx
     The index of the regular, bindable value, organized as a stack of copies.
protected  booleanisGeneric
     The flag for whether the current production is generic.
protected  booleanisList
     The flag for whether the current production is list-valued.
protected  booleanisRecursive
     The flag for whether the current production or sequence is directly left-recursive.
protected  booleanisTopLevel
     The flag for whether the current choice is top-level.
final protected  Runtimeruntime
     The runtime.
protected  List<Index>sequenceIdx
     The index of the sequence with the regular, bindable value, organized as a stack of copies.
protected  List<Sequence>sequences
     The elements as a list of sequences.
protected  inttoProcessIdx
     The index of the next sequence to process.

Constructor Summary
public  Annotator(Runtime runtime, Analyzer analyzer)
     Create a new annotator.

Method Summary
protected  List<Binding>after()
     Get the current list of bindings after the regular value.
protected  voidannotate()
     Process all elements in the current list of sequences.
protected  List<Binding>before()
     Get the current list of bindings before the regular value.
protected  VoidedElementbindAndVoid(Element e)
     Bind and void the specified element.
protected  BindingbindAndVoid()
     Bind and void the current regular, bindable element.
protected  IndexelementIndex()
     Get the current element index of the regular value.
protected  booleanhasBindable()
     Determine whether a bindable element has been processed.
protected  booleanhasValuable()
     Determine whether any valuable elements have been processed.
protected  booleanisBoundAndVoided(Element e)
     Determine whether the specified element already is bound and voided.
Parameters:
  e - The element.
public static  booleanisGeneric(FullProduction p)
     Determine whether the specified production effectively is generic.
public static  booleanisList(Type type)
     Determine whether the specified type is a list type that can be processed by this visitor.
Parameters:
  type - The type.
protected  booleanisParseTreeNode(Element e)
     Determine whether the specified element is a possibly bound or voided parse tree node.
Parameters:
  e - The element.
public static  booleanisSingleRepetition(FullProduction p)
     Determine whether the specified production recognizes only a single repetition.
protected  booleanisValuable(Element e)
     Determine whether the specified element is valuable.
public static  booleanisValuable(FullProduction p)
     Determine whether the specified production can have a semantic value.
protected  voidpop()
     Pop the top elements from the state for tracking bindable and valuable elements.
protected  voidpush()
     Push a copy of the state for tracking bindable and valuable elements.
protected  voidrecurse(Element e)
     Recursively process the specified element.
protected  voidreset()
     Reset the current state for tracking bindable and valuable elements.
protected  IndexsequenceIndex()
     Get the current sequence index of the regular value.
public  voidvisit(Module m)
     Visit the specified grammar.
public  voidvisit(FullProduction p)
     Visit the specified production.
public  voidvisit(OrderedChoice c)
     Visit the specified choice.
public  voidvisit(Sequence s)
     Visit the specified sequence.

Field Detail
MARKER
final public static String MARKER(Code)
The marker for synthetic variables.



after
protected List<List<Binding>> after(Code)
The list of bindings for valuable elements after the regular, bindable value, organized as a stack of copies.
See Also:   Annotator.toProcessIdx



analyzer
final protected Analyzer analyzer(Code)
The analyzer.



before
protected List<List<Binding>> before(Code)
The list of bindings for valuable elements before the regular, bindable value, organized as a stack of copies.
See Also:   Annotator.toProcessIdx



elementIdx
protected List<Index> elementIdx(Code)
The index of the regular, bindable value, organized as a stack of copies. A value of -1 indicates no bindable value.
See Also:   Annotator.toProcessIdx



isGeneric
protected boolean isGeneric(Code)
The flag for whether the current production is generic.



isList
protected boolean isList(Code)
The flag for whether the current production is list-valued.



isRecursive
protected boolean isRecursive(Code)
The flag for whether the current production or sequence is directly left-recursive.



isTopLevel
protected boolean isTopLevel(Code)
The flag for whether the current choice is top-level.



runtime
final protected Runtime runtime(Code)
The runtime.



sequenceIdx
protected List<Index> sequenceIdx(Code)
The index of the sequence with the regular, bindable value, organized as a stack of copies. A value of -1 indicates no bindable value.
See Also:   Annotator.toProcessIdx



sequences
protected List<Sequence> sequences(Code)
The elements as a list of sequences.



toProcessIdx
protected int toProcessIdx(Code)
The index of the next sequence to process. The stacks capturing the state for tracking bindable and valuable must have as many elements as indicated by this index.




Constructor Detail
Annotator
public Annotator(Runtime runtime, Analyzer analyzer)(Code)
Create a new annotator.
Parameters:
  runtime - The runtime.
Parameters:
  analyzer - The analyzer utility.




Method Detail
after
protected List<Binding> after()(Code)
Get the current list of bindings after the regular value. The current list of bindings.



annotate
protected void annotate()(Code)
Process all elements in the current list of sequences.



before
protected List<Binding> before()(Code)
Get the current list of bindings before the regular value. The current list of bindings.



bindAndVoid
protected VoidedElement bindAndVoid(Element e)(Code)
Bind and void the specified element. The specified element must be valuable, i.e., can be rewritten to yield a semantic value.
See Also:   Annotator.isValuable(Element)
Parameters:
  e - The element. The voided, bound element.



bindAndVoid
protected Binding bindAndVoid()(Code)
Bind and void the current regular, bindable element. The binding.



elementIndex
protected Index elementIndex()(Code)
Get the current element index of the regular value. The current element index.



hasBindable
protected boolean hasBindable()(Code)
Determine whether a bindable element has been processed.
See Also:   Analyzer.isBindable(Element) true if a bindable element has beenprocessed.



hasValuable
protected boolean hasValuable()(Code)
Determine whether any valuable elements have been processed.
See Also:   Annotator.isValuable(Element) true if any valuable elements have beenprocessed.



isBoundAndVoided
protected boolean isBoundAndVoided(Element e)(Code)
Determine whether the specified element already is bound and voided.
Parameters:
  e - The element. true if the specified element already isbound and voided.



isGeneric
public static boolean isGeneric(FullProduction p)(Code)
Determine whether the specified production effectively is generic. This method returns true if the specified production is, in fact, generic or it is a void production that also is non-lexical and consumes the input.
See Also:   Generifier.isGeneric(FullProduction)
Parameters:
  p - The production. true if the specified production should betreated as generic.



isList
public static boolean isList(Type type)(Code)
Determine whether the specified type is a list type that can be processed by this visitor.
Parameters:
  type - The type. true if the specified type is a list typethat can be processed by this visitor.



isParseTreeNode
protected boolean isParseTreeNode(Element e)(Code)
Determine whether the specified element is a possibly bound or voided parse tree node.
Parameters:
  e - The element. true if the specified element is a parsetree node.



isSingleRepetition
public static boolean isSingleRepetition(FullProduction p)(Code)
Determine whether the specified production recognizes only a single repetition. This method returns true if the specified production returns a list of objects, nodes, generic nodes, tokens, or strings and each alternative consists of only a single, optionally bound repetition.
Parameters:
  p - The production. true if the specified production recognizesonly a single repetition.



isValuable
protected boolean isValuable(Element e)(Code)
Determine whether the specified element is valuable. This method returns true if the specified element has a semantic value or can be rewritten to yield a semantic value. Rewriting includes eliminating any voided element or converting a void production into a production returning a semantic value.
Parameters:
  e - The element. true if the specified element is valuable.



isValuable
public static boolean isValuable(FullProduction p)(Code)
Determine whether the specified production can have a semantic value. Any production that is not void or that consumes the input can have a semantic value. This method assumes that productions have been correctly annotated with the Properties.INPUT property.
Parameters:
  p - The production. true if the specified production can have asemantic value.



pop
protected void pop()(Code)
Pop the top elements from the state for tracking bindable and valuable elements.



push
protected void push()(Code)
Push a copy of the state for tracking bindable and valuable elements. This method pushes copies of the top elemens of the tracking state onto the respective stacks. If the stacks are empty, it initializes the lists of bindings with empty lists and the indices with -1.



recurse
protected void recurse(Element e)(Code)
Recursively process the specified element.
Parameters:
  e - The element.



reset
protected void reset()(Code)
Reset the current state for tracking bindable and valuable elements. This method replaces the current lists of bindings with new, empty lists and sets the current indices to -1.



sequenceIndex
protected Index sequenceIndex()(Code)
Get the current sequence index of the regular value. The current sequence index.



visit
public void visit(Module m)(Code)
Visit the specified grammar.



visit
public void visit(FullProduction p)(Code)
Visit the specified production.



visit
public void visit(OrderedChoice c)(Code)
Visit the specified choice.



visit
public void visit(Sequence s)(Code)
Visit the specified sequence.



Methods inherited from xtc.tree.Visitor
public Object dispatch(Node node)(Code)(Java Doc)

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.