Commits

Waldemar Kornewald committed 1e8b6ce

fixed string parsing

Comments (0)

Files changed (3)

pyvascript/grammar.ometa

 escaped_char = '\\' :x -> ('\\' + x).decode('string_escape')
 string3 :e = match_string(e) (escaped_char | ~(?(len(e) != 3) vspace | match_string(e)) anything)*:c match_string(e) -> ''.join(c)
 string2 = string3('"""') | string3("'''") | string3('"') | string3("'")
-string = (string2:s optspace -> s)+:s -> ['string', ''.join(s)]
+string = string2:s (optspace string2)*:es -> ['string', s + ''.join(es)]
 
 hexdigit     = letterOrDigit:x !(self.hex_digits.find(x.lower())):v ?(v >= 0)  -> v
 hexlit       = hexlit:n hexdigit:d                                             -> (n * 16 + d)

pyvascript/tests.py

         f = function() {
           var a, b;
           a = 5;
-          b = ((a == 5) ? 'gaga' : 'gugu');
+          b = ((a == 5) ? "gaga" : "gugu");
         };
         """)
 

pyvascript/translator.ometa

 hexnumber :n       -> hex(n)
 string    :s       -> json.dumps(s)
 
-call ['name' 'jsnew'] [expr:obj] -> 'new %s' % obj
+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)