Java Doc for Parser.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.Parser

Parser
public class Parser implements java.io.Serializable(Code)
A Parser can take a string and compile it into an ExpressionProgram. MathObjects, such as variables and functions, can be registered with the Parser. This means that the Parser will recognize them in the strings that it parses. There are a few options that can be set to control certain aspects of the parsing. If a string does not have the correct syntax for an expression, then the Parser will throw a ParseError when it tries to parse that string. A Parser can have a parent. It inherits any MathObjects registered with its parent, but a MathObject registered with a Parser will hide any MathObject of the same name that is registered with its parent. Every parser recognizes the constants pi and e and the operators +, -, *, /, ^, and **. The ** operator is a synonym for ^, the exponentiation operator. Both unary and binary + and - are recognized. The exponentiation operator is right associative. The others are left associative.


Field Summary
final public static  intBOOLEANS
     An option that can be set for this parser. If enabled, the "?" operator can be used in expressions, along with the logical operators &, |, ~, =, <, >, <>, <=, >=. The words "and", "or", and "not" can be used in place of &, |, and ~.
final public static  intBRACES
     An option that can be set for this parser.
final public static  intBRACKETS
     An option that can be set for this parser.
final public static  intCASE_SENSITIVE
     An option that can be set for this parser. If enabled, identifiers are case-sensitive. For example, Sin, sin, and SIN will be treated as separate identifiers.
final public static  intDEFAULT_OPTIONS
     The default options set that is used for a newly created Parser, if none is specified in the Constructor.
final public static  intFACTORIAL
     An option that can be set for this parser. If enabled, the factorial operator, !, is recognized.
final public static  intNO_DIGITS_IN_IDENTIFIERS
     An option that can be set for this parser. Digits 0 through 9, which can usually be used in an identifier after the first character, are not allowed in identifiers.
final public static  intNO_UNDERSCORE_IN_IDENTIFIERS
     An option that can be set for this parser. The character "_", which can usually be used just like a letter, is not allowed in identifers.
final public static  intOPTIONAL_PARENS
     An option that can be set for this parser. If enabled, parentheses are optional around the parameter of a standard function.
final public static  intOPTIONAL_SPACES
     An option that can be set for this parser. If enabled, spaces are not required to separate identifiers.
final public static  intOPTIONAL_STARS
     An that can be set for this parser. If enabled, mutltiplication can be indicated implicitely, as well as with a "*".
final public static  intSTANDARD_FUNCTIONS
     An option that can be set for this parser. When enabled, the standard functions are registered with the parser.
protected  intoptions
     The set of options that have been enabled for this parser.
protected  SymbolTablesymbols
     The symbol table that contains the MathObjects that have been registered with this parser.

Constructor Summary
public  Parser()
     Construct a Parser with no parent and with the default options, BOOLEANS and STANDARD_FUNCTIONS.
public  Parser(Parser parent)
     Create a Parser with the specified parent.
public  Parser(int options)
     Create a Parser with the spedified option set and with no parent.
public  Parser(Parser parent, int options)
     Create a Parser with the specified parent.

Method Summary
public  voidadd(MathObject sym)
     Register the MathObject with the Parser, associating it with its name.
public  voidaddOptions(int newOptions)
     Add the options in the option set newOptions to this Parser's option set.
public  MathObjectget(String name)
     Get the MathObject that has been registered with the parser under the given name.
public  ExpressionProgramparse(String str)
     Parse the string str and create the corresponding expression. The expression must be numeric-valued, not logical.
public  booleanparseExpression(ParserContext context)
     Called as part of the parsing process.
public  booleanparseFactor(ParserContext context)
     Called as part of the parsing process.
public  ExpressionProgramparseLogical(String str)
     Parse the String, str, and create a corresponding logical-valued expression. The expression must be logical-valued, such as "x > 0", not numeric.
public  booleanparseLogicalExpression(ParserContext context)
     Called as part of the parsing process.
public  booleanparseLogicalFactor(ParserContext context)
     Called as part of the parsing process.
public  booleanparseLogicalTerm(ParserContext context)
     Called as part of the parsing process.
public  booleanparsePrimary(ParserContext context)
     Called as part of the parsing process.
public  booleanparseRelation(ParserContext context)
     Called as part of the parsing process.
public  booleanparseTerm(ParserContext context)
     Called as part of the parsing process.
public  voidremove(String name)
     Deregister the MathObject with the given name, if there is one registered with the Parser.

Field Detail
BOOLEANS
final public static int BOOLEANS(Code)
An option that can be set for this parser. If enabled, the "?" operator can be used in expressions, along with the logical operators &, |, ~, =, <, >, <>, <=, >=. The words "and", "or", and "not" can be used in place of &, |, and ~. These words are treated in a case-insensitive way, even if the CASE_SENSITIVE option is on. When this option is set, it is legal to call the parseLogical method to parse a boolean-valued expression. This option is enabled by default.



BRACES
final public static int BRACES(Code)
An option that can be set for this parser. If enabled, braces, { and }, can be used for grouping.



BRACKETS
final public static int BRACKETS(Code)
An option that can be set for this parser. If enabled, brackets, [ and ], can be used for grouping.



CASE_SENSITIVE
final public static int CASE_SENSITIVE(Code)
An option that can be set for this parser. If enabled, identifiers are case-sensitive. For example, Sin, sin, and SIN will be treated as separate identifiers. It really only makes sense to enable this at the time the Parser is first constructed.



DEFAULT_OPTIONS
final public static int DEFAULT_OPTIONS(Code)
The default options set that is used for a newly created Parser, if none is specified in the Constructor. It includes the options BOOLEANS and STANDARD_FUNCTIONS.



FACTORIAL
final public static int FACTORIAL(Code)
An option that can be set for this parser. If enabled, the factorial operator, !, is recognized.



NO_DIGITS_IN_IDENTIFIERS
final public static int NO_DIGITS_IN_IDENTIFIERS(Code)
An option that can be set for this parser. Digits 0 through 9, which can usually be used in an identifier after the first character, are not allowed in identifiers.



NO_UNDERSCORE_IN_IDENTIFIERS
final public static int NO_UNDERSCORE_IN_IDENTIFIERS(Code)
An option that can be set for this parser. The character "_", which can usually be used just like a letter, is not allowed in identifers.



OPTIONAL_PARENS
final public static int OPTIONAL_PARENS(Code)
An option that can be set for this parser. If enabled, parentheses are optional around the parameter of a standard function. If the parentheses are omited, then the argument is the term that follows the function name. For example, "sin x + 1" means "sin(x) + 1" while "sin x * cos x" means "sin( x*cos(x) )".



OPTIONAL_SPACES
final public static int OPTIONAL_SPACES(Code)
An option that can be set for this parser. If enabled, spaces are not required to separate identifiers. This only has an effect if one of OPTIONAL_STARS or OPTIONAL_PARENS is also enabled. For example, xsin(x) will be read as x*sin(x), and sine will be read as sin(e).



OPTIONAL_STARS
final public static int OPTIONAL_STARS(Code)
An that can be set for this parser. If enabled, mutltiplication can be indicated implicitely, as well as with a "*". For example, 2x will mean 2*x.



STANDARD_FUNCTIONS
final public static int STANDARD_FUNCTIONS(Code)
An option that can be set for this parser. When enabled, the standard functions are registered with the parser. This option is enabled by default. The standard functions are: sin, cos, tan, cot, sec, csc, arcsin, arccos, arctan, exp, ln, log2, log10, sqrt, cubert, abs, round, floor, ceiling, trunc.



options
protected int options(Code)
The set of options that have been enabled for this parser.



symbols
protected SymbolTable symbols(Code)
The symbol table that contains the MathObjects that have been registered with this parser.




Constructor Detail
Parser
public Parser()(Code)
Construct a Parser with no parent and with the default options, BOOLEANS and STANDARD_FUNCTIONS.



Parser
public Parser(Parser parent)(Code)
Create a Parser with the specified parent. The options for this parser are inherited from the parent, if parent is non-null. If parent is null, the option set is empty.



Parser
public Parser(int options)(Code)
Create a Parser with the spedified option set and with no parent.



Parser
public Parser(Parser parent, int options)(Code)
Create a Parser with the specified parent. The options for this parser consist of the option set from the parent, together with any additional options in the specified options set.
Parameters:
  parent - parent of this Parser, possibly null.
Parameters:
  options - additional options, in addition to ones inherited from parent.




Method Detail
add
public void add(MathObject sym)(Code)
Register the MathObject with the Parser, associating it with its name. An error will occur if the name is null. If the CASE_SENSITIVE option is not set, names are converted to lower case for the purpose of registering and retrieving registered objects.



addOptions
public void addOptions(int newOptions)(Code)
Add the options in the option set newOptions to this Parser's option set. The value of newOptions can be one of the option constants defined in this class, such as OPTIONAL_STARS, or it can consist of several option constants OR-ed together.



get
public MathObject get(String name)(Code)
Get the MathObject that has been registered with the parser under the given name. If the CASE_SENSITIVE option is not set, names are converted to lower case for the purpose of registering and retrieving registered objects.



parse
public ExpressionProgram parse(String str)(Code)
Parse the string str and create the corresponding expression. The expression must be numeric-valued, not logical. There can't be any extra characters in str after the expression. If a syntax error is found, a ParseError will be thrown.
Parameters:
  str - String to parse. the expression defined by the string.



parseExpression
public boolean parseExpression(ParserContext context)(Code)
Called as part of the parsing process. From outside this class, this would probably be called only by a ParserExtension.



parseFactor
public boolean parseFactor(ParserContext context)(Code)
Called as part of the parsing process. From outside this class, this would probably be called only by a ParserExtension.



parseLogical
public ExpressionProgram parseLogical(String str)(Code)
Parse the String, str, and create a corresponding logical-valued expression. The expression must be logical-valued, such as "x > 0", not numeric. There can't be any extra characters in str after the expression. If a syntax error is found, a ParseError will be thrown. It is not legal to call this method if the BOOLEANS option is not set.
Parameters:
  str - String to parse. the logical-valued expression defined by str.



parseLogicalExpression
public boolean parseLogicalExpression(ParserContext context)(Code)
Called as part of the parsing process. From outside this class, this would probably be called only by a ParserExtension.



parseLogicalFactor
public boolean parseLogicalFactor(ParserContext context)(Code)
Called as part of the parsing process. From outside this class, this would probably be called only by a ParserExtension.



parseLogicalTerm
public boolean parseLogicalTerm(ParserContext context)(Code)
Called as part of the parsing process. From outside this class, this would probably be called only by a ParserExtension.



parsePrimary
public boolean parsePrimary(ParserContext context)(Code)
Called as part of the parsing process. From outside this class, this would probably be called only by a ParserExtension.



parseRelation
public boolean parseRelation(ParserContext context)(Code)
Called as part of the parsing process. From outside this class, this would probably be called only by a ParserExtension.



parseTerm
public boolean parseTerm(ParserContext context)(Code)
Called as part of the parsing process. From outside this class, this would probably be called only by a ParserExtension.



remove
public void remove(String name)(Code)
Deregister the MathObject with the given name, if there is one registered with the Parser. If the name is not registered, nothing happens and no error occurs.
Parameters:
  name - MathObject to deregister.



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.