[Prev][Next][Index][Thread]

Re: Progress on Parsing



Dave,

It would be useful for those of us who don't have prolog on our machines
if you would include the sample output along with your sample input.

I am confused how you deal with parens and functions.
I didn't see any definitions for them, and yet two of your leading examples

y = 1 + integral of sin(x) wrt x * cos(x)
1 + {sin a x} over e^x

involve functions ('integral' also seems to be missing from your precedence
list).

In the first example, it would seem that your grammar (assuming parens were
added) would turn 'sin(x)' into 'sin.(x)'
In the second example, how is 'sin a x' parsed:  'sin.a.x' or '{sin a}.x'
or 'sin {a x}'

The rules you give all seem to be left or right associative.
Operators such as '+' and ',' are treated as n-ary operators by the symbolic
manipulators that I've seen because you can often get expressions that
are thousands of "terms" long, and it is very inefficient to build binary
trees for those expressions.

Also, I didn't see anything in your test grammar for dealing with scripted
operators.  Eg, suppose you define:
prefix operator "sum" (or use '-' in place of 'sum' in the example below).
infix operator "cross" (or some other operator with precedence higher than
    times but less than prefix minus)

Then
-n cross sum _ i i

should group as
{-{n cross {{sum _ i} i}}}

The interesting thing here is that 'sum _ i' must reduce to a prefix operator
with the same precedence as sum, and then this must grab the 'i' operand
as opposed to treating the operand/operand conflict (...i i) as multiplication.

	Neil