Am 05.11.2011 23:43, schrieb Ricardo Martins de Abreu Silva:
So, how i can isolate a grammar just for mathematical expression in sympy,
and consequently in python (because the grammar of sympy extends the
grammar of python in relation to mathematical expressions).

I guess that would be Python expression syntax, limiting the allowable functions to those defined in Sympy. At least that's how I understand your question.

I don't think this is worth it:
1) Sympy expressions can contain arbitrary Python expressions that might provide integers. You'd have to distinguish parameter positions of Sympy functions: those that allow just Sympy objects, those that allow Python numbers (or strings, or just ints), and those that allow a combination. 2) Sympy defines the set of allowable functions as "whatever is defined in Sympy's modules". Tomorrow's Sympy might contain additional functions, so a grammar that enumerates all valid functions will become outdates very quickly. 3) Import statements pull in functions defined in modules, Sympy modules or otherwise. You'd need a different grammar for each combination of import statements. This can be addressed using context-sensitive grammars (van Wijngaarden two-level grammars come to mind), but these are much harder to use and much less widely known than the usual context-free grammars.

It might be a better idea to tell us what you need the syntax for. We might be able to come up with another way to achieve what you're after.

Regards,
Jo

--
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to