I think Prashant Sharma wrote: [Charset iso-8859-1 unsupported, filtering to ASCII...] > Hi, > Is there a way to parse a mathematical expression using jess,such that my >function (parseMathExpression(xxxx)) will throw an Exception.Ideally i would not like >to pass numerical values into the mathematical expression, just checking for proper >syntax( no invalid characters , brackets properly matched kinda stuff). > Any tip's-n-tricks will be helpful.
Parsing expressions is tricky business. It's got to be done relative to specific syntax, which varies by language. Java and Jess have very different syntaxes, and there are many other possibilities. In the general case, the only reall alternative would be to write a parser in Java (perhaps using a tool like ANTLR, which I have used and like) and then invoke it from Jess. In the specific case of Jess syntax, however, you could simply use the "eval" function: (eval "(+ a b" ) will throw an exception due to the missing parenthesis. > > Thanks in advance > Prashant > --------------------------------------------------------- Ernest Friedman-Hill Distributed Systems Research Phone: (925) 294-2154 Sandia National Labs FAX: (925) 294-2234 Org. 8920, MS 9012 [EMAIL PROTECTED] PO Box 969 http://herzberg.ca.sandia.gov Livermore, CA 94550 -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------
