On Aug 22, 11:17 pm, Chris Seberino <cseber...@gmail.com> wrote:
> In order to deal with this situation, as well as the conditional
> "(this) or (that)", my simple regex would need to be
> changed to only trigger when a *VARIABLE* was followed by a space and
> left parens.

Unfortunately you don't have that information. This happens at
_pre_parsing. At this stage you only have strings. You don't have
access to the bound value. What you *can* do is search back from your
" (", find what is in front of it and if it's not an operator (these
are reserved words and special symbols, so you *can* recognize those
without looking at bindings), replace the space with a "*".

(pre)parsing and execution can be separated in time and bindings in
force at parsing may be different from those in force at execution.
Consider:

x = function("x")

def mul_or_call( c ):
  return x (c)  # is this an implicit multiplication?

x = var("x")

mull_or_call(10)

As you can see, when mul_or_call is parsed, x is bound to a symbolic
function. In the subsequent execution of mul_or_call, x is bound to a
symbolic variable. There are very good reasons to keep (pre)parsing
independent of bindings that are in force.

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to