[pypy-svn] r36310 - pypy/dist/pypy/lang/js
antocuni at codespeak.net
antocuni at codespeak.net
Mon Jan 8 19:30:11 CET 2007
Author: antocuni
Date: Mon Jan 8 19:30:10 2007
New Revision: 36310
Modified:
pypy/dist/pypy/lang/js/interpreter.py
pypy/dist/pypy/lang/js/jsparser.py
Log:
More steps in making js rpythonic.
Modified: pypy/dist/pypy/lang/js/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/js/interpreter.py (original)
+++ pypy/dist/pypy/lang/js/interpreter.py Mon Jan 8 19:30:10 2007
@@ -1,5 +1,5 @@
-from pypy.lang.js.jsparser import parse
+from pypy.lang.js.jsparser import parse, parse_bytecode
from pypy.lang.js.jsobj import *
from pypy.rlib.parsing.ebnfparse import Symbol, Nonterminal
@@ -62,6 +62,10 @@
newscript = from_tree(temp_tree)
self.script.append_script(newscript)
+ def load_bytecode(self, bytecode):
+ temp_tree = parse_bytecode(bytecode)
+ self.script = from_tree(temp_tree)
+
def run(self):
"""run the interpreter"""
return self.script.execute(self.global_context)
@@ -486,7 +490,7 @@
return
tp = gettreeitem(t, 'type').additional_info
if tp == 'ARRAY_INIT':
- return Array(getlist(d))
+ return Array(getlist(t))
elif tp == 'ASSIGN':
return Assign(from_tree(gettreeitem(t, '0')), from_tree(gettreeitem(t, '1')))
elif tp == 'BLOCK':
Modified: pypy/dist/pypy/lang/js/jsparser.py
==============================================================================
--- pypy/dist/pypy/lang/js/jsparser.py (original)
+++ pypy/dist/pypy/lang/js/jsparser.py Mon Jan 8 19:30:10 2007
@@ -41,14 +41,19 @@
read_code = read_js_output(code_string)
output = read_code.split(os.linesep)
#print '\n'.join(output)
- t = parse_bytecode(output)
- unquote(t)
+ t = parse_bytecode("\n".join(output))
#print "-----------------\n",t
#print "-----------------\n",t.children[0].children[0].additional_info
return t
-
+
def parse_bytecode(bytecode):
- regexs, rules, ToAST = parse_ebnf("""
+ t = parse_tree(bytecode)
+ #print "0000000",t
+ tree = ToAST().transform(t)
+ unquote(tree)
+ return tree
+
+regexs, rules, ToAST = parse_ebnf("""
QUOTED_STRING: "'[^\\']*'";
IGNORE: " |\n";
data: <dict> | <QUOTED_STRING> | <list>;
@@ -56,8 +61,4 @@
dictentry: QUOTED_STRING [":"] data;
list: ["["] (data [","])* data ["]"];
""")
- parse = make_parse_function(regexs, rules, eof=True)
- t = parse("\n".join(bytecode))
- #print "0000000",t
- return ToAST().transform(t)
-
+parse_tree = make_parse_function(regexs, rules, eof=True)
More information about the Pypy-commit
mailing list