[pypy-svn] r44970 - pypy/dist/pypy/lang/scheme
jlg at codespeak.net
jlg at codespeak.net
Thu Jul 12 16:41:57 CEST 2007
Author: jlg
Date: Thu Jul 12 16:41:56 2007
New Revision: 44970
Modified:
pypy/dist/pypy/lang/scheme/object.py
pypy/dist/pypy/lang/scheme/ssparser.py
Log:
(antocuni, jlg) - unquote in ssparse -> RPython; fixnum, float parsing -> RPython
Modified: pypy/dist/pypy/lang/scheme/object.py
==============================================================================
--- pypy/dist/pypy/lang/scheme/object.py (original)
+++ pypy/dist/pypy/lang/scheme/object.py Thu Jul 12 16:41:56 2007
@@ -84,7 +84,7 @@
class W_Fixnum(W_Root):
def __init__(self, val):
- self.fixnumval = int(val)
+ self.fixnumval = val
def to_string(self):
return str(self.fixnumval)
@@ -103,7 +103,7 @@
class W_Float(W_Root):
def __init__(self, val):
- self.floatval = float(val)
+ self.floatval = val
def to_string(self):
return str(self.floatval)
Modified: pypy/dist/pypy/lang/scheme/ssparser.py
==============================================================================
--- pypy/dist/pypy/lang/scheme/ssparser.py (original)
+++ pypy/dist/pypy/lang/scheme/ssparser.py Thu Jul 12 16:41:56 2007
@@ -5,14 +5,24 @@
W_Nil, W_Boolean, W_Float, Literal
def unquote(s):
- return s.replace('\\"', '"')
+ str_lst = []
+ last_ch = ''
+ for c in s[1:]:
+ if last_ch == '\\' and c == '"':
+ pass
+ else:
+ str_lst.append(last_ch)
+
+ last_ch = c
+
+ return ''.join(str_lst)
class SchemeParser(PackratParser):
r"""
STRING:
c = `\"([^\\\"]|\\\"|\\\\)*\"`
IGNORE*
- return {W_String(unquote(c[1:-1]))};
+ return {W_String(unquote(c))};
IDENTIFIER:
c = `[\+\-\*\^\?a-zA-Z!<=>_~/$%&:][\+\-\*\^\?a-zA-Z0-9!<=>_~/$%&:]*`
@@ -22,12 +32,12 @@
FIXNUM:
c = `\-?(0|([1-9][0-9]*))`
IGNORE*
- return {W_Fixnum(c)};
+ return {W_Fixnum(int(c))};
FLOAT:
c = `\-?[0-9]*\.[0-9]*`
IGNORE*
- return {W_Float(c)};
+ return {W_Float(float(c))};
BOOLEAN:
c = `#(t|f)`
More information about the Pypy-commit
mailing list