Main Page | Packages | Class Hierarchy | Class List | File List | Class Members

xmlexpr.XMLExpressions Class Reference

List of all members.

Detailed Description

An interactive expression interpreter.

An expression (x = a + b * c, for example) is converted to XML and then evaluated. The expression evaluator supports a symbol table that allows assignment and retrieval of symbol values. Only integer expressions are supported.


Static Public Member Functions

void main (String[] argv)

Static Package Attributes

final String TOP_TAG = "EXPRESSION"
final String NAME_SPACE = "http://www.bearcave.com/expression"
final String PREFIX = "ex"


Member Function Documentation

void xmlexpr.XMLExpressions.main String[]  argv  )  [static]
 

00038 { 00039 String line = ""; 00040 int len = 0; 00041 ParseExpToXML xmlParse = new ParseExpToXML(); 00042 EvalXML evalStmtOrExp = new EvalXML(); 00043 DOMParser parser = ParserFactory.newParser( true ); 00044 try { 00045 BufferedReader is = new BufferedReader( new InputStreamReader( System.in ) ); 00046 do { 00047 System.out.print("> "); 00048 line = is.readLine(); 00049 if (line != null ) { 00050 line = line.trim(); 00051 len = line.length(); 00052 if (len > 0) { 00053 try { 00054 String xml = xmlParse.parse( line, 00055 TOP_TAG, 00056 PREFIX, 00057 NAME_SPACE, 00058 "xmlexpr/expression.xsd"); 00059 Integer rslt = evalStmtOrExp.eval(parser, xml.getBytes() ); 00060 if (rslt != null) { 00061 System.out.println( rslt ); 00062 } 00063 } catch (ExpParseException e1) { 00064 System.out.println("Expression parse error: " + e1 ); 00065 } 00066 } 00067 } 00068 } while (line != null && len > 0); 00069 } 00070 catch (IOException e2) { 00071 System.out.println("IOException: " + e2.getMessage()); 00072 } 00073 } // main


Member Data Documentation

final String xmlexpr.XMLExpressions.NAME_SPACE = "http://www.bearcave.com/expression" [static, package]
 

final String xmlexpr.XMLExpressions.PREFIX = "ex" [static, package]
 

final String xmlexpr.XMLExpressions.TOP_TAG = "EXPRESSION" [static, package]
 


The documentation for this class was generated from the following file:
Generated on Sat Aug 28 13:09:44 2004 for XmlExpr by doxygen 1.3.8