Yeah Stefan, you seem to follow what I'm asking. I should have made it clearer that I'm getting this whole function as a string, so here's a little more background. There is no checking on this string to see if its syntactically valid before it gets to my code - the syntax is a from a legacy scripting language. I'm basically having to wrap the funcionality of a number of functions from this scripting language so I can perform the same work in my
java app. I can't use a bridge or native calls to do this, since the java app runs entirely seperatly from the legacy app, and the legacy app requires licence costs, so asking user of my java app to install it too is out of the question (and its Windows only). However, both apps can in theory be run concurrently so I need support the legacy functionality.
Your questions:
- both arithmetic and boolean expressions are allowed (with arithmetic, a positive result == true. My example is acutally pretty pointless, but given a user can validly enter this nonsense code perhaps it isn't
)
- all the common types are allowed (including Dates)
- it needs to support all the common operators you see in most languages (e.g. common logical and arithmetic operators), not quite the full set of Java opertator, but a fairly large subset.
- the syntax is fairly loose. It a bit like VBScript, so functions need not be parentetised, it is case insensetive and uses variants as parameters (which is actually a bit of a help here, since I get everthing a a string so dates, ints, doubles etc. need to be wrapped in int( string ) etc. functions first - otherwise I'd have no idea what datatype the users is using).
Basically what I'm doing so far is creating classes to mimic the functionality of these legacy functions, and writing classes which provide the same sort of behaviour as the JavaScript evaluation function. However most of the work is going in to horrible resursive string manipulation and regular expression matching methods to spilt out the constituent parts of this (possibly infinitely nested) function before I can safely call any of these functions.
This is giving me a headache. Anyone with any ideas?
[ May 21, 2004: Message edited by: Paul Sturrock ]