On Sunday, March 11, 2012 7:00:15 PM UTC+5:30, Joachim Durchholz wrote:
>
> Am 11.03.2012 05:27, schrieb Bharath M R:
> > @Sergiu I was looking at top down operator precedence parsing for the 
> task
>
> That's the technique where the grammar requires the least contortions.
> It also composes well: you can define sublanguages (such as arithmetic 
> and boolean logic), and as long as their operator sets do not overlap, 
> you can combine them without any problems.
>
> It is a bit restricted in what classes of languages it can handle.
> Parsing a*-b is not possible but can be enabled using a hack.
> I don't know how to parse http://en.wikipedia.org/wiki/Bra-ket_notation 
> using operator precedence.
>
> > (http://javascript.crockford.com/tdop/tdop.html) .
>
> Crockford is very wrong that operator-precedence parsing is in any way 
> connected to dynamic languages.
>
> In general, he's not exposing principles but presenting a recipe. I 
> don't think that's easy to transfer to Python code.
>
>  > One of the important task is to
> > come up with the grammar.
>
> Not for operator-precedence grammars!
> You need:
> - a list of precedence levels,
> - for each level:
>    - the list of operators
>    - whether it's left, right, or non-associative
> - a list of left and right parentheses
>
> The problem with unary minus is that it has a different precedence than 
> binary minus. The standard approach is to let the tokenizer detect 
> multiple operator symbols in a row, and emit a different pseudo-minus 
> token whenever it isn't the first.
> I'm pretty sure I could whip up a systematic approach that would cover 
> more operators and hold up in the presence of postfix operators, but I 
> don't know whether that's even relevant in SymPy. (The only postfix 
> operator in widespread use I know about is !, and that isn't used as an 
> infix operator.)
>
Thanks for the reply. The parser is for building the web interface similar 
to 
Wolfram Alpha for SymPy.  Basically I want to parse things like 
integrate x**2 dx
roots x**2==1

Won't the operator precedence parsing be sufficient for this? If it is not, 
can 
you help me with some reading material on some parsing technique which can 
acomplish this.

Thanks,
Bharath M R 

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sympy/-/Xn1LJmMSOJAJ.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to