Commits

Waldemar Kornewald committed 95080c8

removed "new" keyword and replaced it with "jsnew" fake-function, so Python parsers can parse PyvaScript files (unless you use multi-line lambdas)

Comments (0)

Files changed (2)

pyvascript/grammar.ometa

       | callable
 
 callable = optspace
-         ( new
-         | lambda
+         ( lambda
          | deflambda
          | get
          )
           | name
           | '(' !(self.enter_paren()) expr:ix optspace ')' !(self.leave_paren()) -> ix
 
-new = "new" mandspace get:c -> ['new', c]
-
 name_start   = letter | '$' | '_'
 name_rest    = name_start | digit
 iname        = name_start:s name_rest*:r   -> s + ''.join(r)

pyvascript/translator.ometa

 hexnumber :n       -> hex(n)
 string    :s       -> json.dumps(s)
 
-new  expr:c                  -> 'new %s' % c
-
+call ['name' 'jsnew'] [expr:obj] -> 'new %s' % obj
 call ['name' 'len'] [expr:obj] -> '%s.length' % obj
 call ['name' 'hasattr'] [expr:obj expr:attr] -> '(typeof %s[%s] != "undefined")' % (obj, attr)
 call ['name' 'getattr'] [expr:obj expr:attr] -> '%s[%s]' % (obj, attr)