Am 05.09.2012 02:14, schrieb David Li:
Yes, what I was thinking is that there would be a "whitespace expansion"
step (probably after tokenization) that would convert statements like 2xy
into "2 x y" and then tokenize again

Multiple tokenization steps are usually not worth it.
Make it so that there's a token boundary between 2 and xy.

Splitting xy would be one of those things that need to be syntax-dependent.
SymPy allows defining variable names, so if there's an "x" and a "y", you can split, and if there's an "xy", you wouldn't want to split. If there are all three of "x", "y", and "xy", you have an ambiguous parse; report that as something that the user needs to decide (ambiguous parses are a fact of life for ad-hoc grammars, and in fact we need to deal with these for other reasons anyway).

If SymPy provides you with a variable named "xy", add a temporary grammar rule
  xy ::= x y
and make each letter a separate token. (Temporary grammar rules and ambiguities are anathema in the parser generators used for programming languages, but they are no problem in the parser generators used for natural languages. Different parsing technology.)

--
You received this message because you are subscribed to the Google Groups 
"sympy" group.
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