Java Doc for ParserContext.java in  » Science » jcm1-source » edu » hws » jcm » data » 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 » Science » jcm1 source » edu.hws.jcm.data 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   edu.hws.jcm.data.ParserContext

ParserContext
public class ParserContext implements java.io.Serializable(Code)
A ParserContext holds all the state data for a parsing operation, including the string that is being parsed, a pointer to the current position in that string, and the most recently parsed token from the string. The ParserContext object does the tokenization. Token types are retrieved by calling look() and next(). Attributes of the token are then available in the member variables tokenString, tokenObject, and tokenValue. You will probably only use this if you write a ParserExtension.


Field Summary
final public static  intEND_OF_STRING
     One of the possible token types returned by look() and next().
final public static  intIDENTIFIER
     One of the possible token types returned by look() and next(). The token is a word.
final public static  intNUMBER
     One of the possible token types returned by look() and next(). Indicates aht the token is a number.
final public static  intOPCHARS
     One of the possible token types returned by look() and next(). Any other token besides end-of-string, number, or word. The only information about the token is the tokenString member variable.
public  Stringdata
     The string that is being parsed.
public  intoptions
     The options from the Parser.
public  intpos
     Current position in that string, indicating how many characters have been consumed.
public  ExpressionProgramprog
     The ExpressionProgram that is being generated as the string is parsed.
protected  SymbolTablesymbols
     The Parser's symbol table, which is used for looking up tokens of type IDENTIFIER.
public  inttoken
     The most recently read token type, or NONE if that token has been consumed by a call to next().
public  MathObjecttokenObject
     If the most recently read token was of type IDENTIFIER, then this is the corresponding MathObject from the symbol table, or null if the identifier is not in the symbol table.
public  StringtokenString
     The substring of the parse string that corresponds to the most recently read token.
public  doubletokenValue
     If the most recently read token was of type NUMBER, then this is its numerical value.

Constructor Summary
public  ParserContext(String data, int options, SymbolTable symbols)
     Create a ParserContext for parsing the data String, using the specified options and symbol table.

Method Summary
public  voidadd(MathObject sym)
     Add a new MathObject to the symbol table.
public  MathObjectget(String name)
     Get the MathObject associated with name in the symbol table.
public  intlook()
     Look ahead at the next token in the data string, without consuming it. Successive calls to look() will return the same token.
public  voidmark()
     MathObjects added to the symbol table after a call to mark() will be removed by a later, matching call to revert().
public  intnext()
     Consume one token from the string.
public  voidrevert()
    

Field Detail
END_OF_STRING
final public static int END_OF_STRING(Code)
One of the possible token types returned by look() and next(). Represents the end of the string that is being parsed.



IDENTIFIER
final public static int IDENTIFIER(Code)
One of the possible token types returned by look() and next(). The token is a word. If there is a MathObject in the symbol table associated with this word, then that object is in the tokenObject member variable. If not, tokenObject is null.



NUMBER
final public static int NUMBER(Code)
One of the possible token types returned by look() and next(). Indicates aht the token is a number. The numerical value of the token is in the tokenValue member variable.



OPCHARS
final public static int OPCHARS(Code)
One of the possible token types returned by look() and next(). Any other token besides end-of-string, number, or word. The only information about the token is the tokenString member variable. For some special operators (<> <= <=), the tokenString has two characters, but generally it has only one. Note that ** is translated to ^. Also, the special tokens "and", "or", and "not" are translated to type OPCHARS with tokenString equal to "&", "|", or "~" (but only if options & BOOLEANS is != 0).



data
public String data(Code)
The string that is being parsed.



options
public int options(Code)
The options from the Parser. Some of these options affect tokenization, such as whether BOOLEANS is enabled.



pos
public int pos(Code)
Current position in that string, indicating how many characters have been consumed.



prog
public ExpressionProgram prog(Code)
The ExpressionProgram that is being generated as the string is parsed. Note that while parsing a ConditionalExpression, the value of prog is temporarily changed. ParserExtensions might want to do something similar.



symbols
protected SymbolTable symbols(Code)
The Parser's symbol table, which is used for looking up tokens of type IDENTIFIER.



token
public int token(Code)
The most recently read token type, or NONE if that token has been consumed by a call to next(). The value NONE is never returned by look() or next().



tokenObject
public MathObject tokenObject(Code)
If the most recently read token was of type IDENTIFIER, then this is the corresponding MathObject from the symbol table, or null if the identifier is not in the symbol table.



tokenString
public String tokenString(Code)
The substring of the parse string that corresponds to the most recently read token. This can change when look() or next() is called.



tokenValue
public double tokenValue(Code)
If the most recently read token was of type NUMBER, then this is its numerical value.




Constructor Detail
ParserContext
public ParserContext(String data, int options, SymbolTable symbols)(Code)
Create a ParserContext for parsing the data String, using the specified options and symbol table. A new ExpressionProgram is created to hold the program that will be generated from the string.




Method Detail
add
public void add(MathObject sym)(Code)
Add a new MathObject to the symbol table.



get
public MathObject get(String name)(Code)
Get the MathObject associated with name in the symbol table.



look
public int look()(Code)
Look ahead at the next token in the data string, without consuming it. Successive calls to look() will return the same token. (The token must be consumed by a call to next().) The token type is returned. After a call to look(), attributes of the token can be obtained from the public member variables tokenString, tokenObject, and tokenValue. Can throw a ParseError in the case of an illegal numeric token.



mark
public void mark()(Code)
MathObjects added to the symbol table after a call to mark() will be removed by a later, matching call to revert(). In the meantime, older symbols of the same name will only be hidden, not replaced, so they will still be there after the revert. It is important that a call to this routine is followed by a later call to revert! No error checking is done to make sure that this is true.



next
public int next()(Code)
Consume one token from the string. The token type is returned. After this is called, attributes of the token can be obtained from the public member variables tokenString, tokenObject, and tokenValue. Note that the END_OF_STRING token is never really consumed and can be returned multiple times. Can throw a ParseError in the case of an illegal numeric token.



revert
public void revert()(Code)



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.