[antlr-interest] Is it possible?
Kay Roepke
kroepke at classdump.org
Sat Aug 5 11:05:03 PDT 2006
On 5. Aug 2006, at 19:54 Uhr, vak bottyán wrote:
> What do you suggest, should I write an own expr-evaluator specific
> to my case, or rather use ANTLR?
Yes, and yes ;)
The evaluator you'd have to write anyway, since ANTLR is a(nother)
tool for language recognition. Whether the input ANTLR
breaks up makes sense in problem domain must be checked by some
semantic checker.
ANTLR cannot check if some matrix operation makes sense for the
matrices specified, so in your example
adj(((A + B)*C^-1 - D^3)^T)
it cannot check if the inverse of (A+B)*C is actually computable.
That you must do yourself. But ANTLR provides you
with the structure of the expression so you can hook into your
validity checker at the right spots, and supply the
right information to it.
So, back to your question ;), yes, I'd suggest you use ANTLR for
parsing the expressions, because that's what it's for. There's
no need to write an expression lexer/parser by hand if you have great
tools for doing that for you.
HTH,
-k
--
Kay Röpke <kroepke at classdump.org>
classdump Software
More information about the antlr-interest
mailing list