Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
trs
Commits
dadd40a4
Commit
dadd40a4
authored
Sep 13, 2012
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Further improved special token handling in preprocessor.
parent
492f3b52
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
3 deletions
+5
-3
src/node.py
src/node.py
+1
-1
src/parser.py
src/parser.py
+3
-1
tests/test_parser.py
tests/test_parser.py
+1
-1
No files found.
src/node.py
View file @
dadd40a4
...
@@ -84,7 +84,7 @@ E = 'e'
...
@@ -84,7 +84,7 @@ E = 'e'
PI
=
'pi'
PI
=
'pi'
INFINITY
=
'oo'
INFINITY
=
'oo'
SPECIAL_TOKENS
=
[
E
,
PI
,
INFINITY
]
SPECIAL_TOKENS
=
[
PI
,
INFINITY
]
# Default base to use in parsing 'log(...)'
# Default base to use in parsing 'log(...)'
DEFAULT_LOGARITHM_BASE
=
10
DEFAULT_LOGARITHM_BASE
=
10
...
...
src/parser.py
View file @
dadd40a4
...
@@ -183,10 +183,12 @@ class Parser(BisonParser):
...
@@ -183,10 +183,12 @@ class Parser(BisonParser):
# Replace known keywords with escape sequences.
# Replace known keywords with escape sequences.
words
=
list
(
self
.
words
)
words
=
list
(
self
.
words
)
words
.
insert
(
0xa
,
'
\
n
'
)
words
.
insert
(
0xa
,
'
\
n
'
)
words
.
insert
(
0xc
,
'
\
f
'
)
words
.
insert
(
0xd
,
'
\
r
'
)
words
.
insert
(
0xd
,
'
\
r
'
)
for
i
,
keyword
in
enumerate
(
words
):
for
i
,
keyword
in
enumerate
(
words
):
# FIXME: Why case-insensitivity?
# FIXME: Why case-insensitivity?
# FIXME: good question...
data
=
re
.
sub
(
keyword
,
chr
(
i
),
data
,
flags
=
re
.
I
)
data
=
re
.
sub
(
keyword
,
chr
(
i
),
data
,
flags
=
re
.
I
)
rsv
=
'
\
x00
-
\
x09
\
x0b
-
\
x0c
\
x0e
-
\
x19
'
rsv
=
'
\
x00
-
\
x09
\
x0b
-
\
x0c
\
x0e
-
\
x19
'
...
@@ -214,7 +216,7 @@ class Parser(BisonParser):
...
@@ -214,7 +216,7 @@ class Parser(BisonParser):
# not be written as "sin*x", because that is bogus.
# not be written as "sin*x", because that is bogus.
# Bugfix: omit 0x0c (pi) to prevent "pi a" (should be "pi*a")
# Bugfix: omit 0x0c (pi) to prevent "pi a" (should be "pi*a")
o = ord(left)
o = ord(left)
if o <= 0x9 or
0xb <= o <= 0xc
:
if o <= 0x9 or
o == 0xb
:
return left + '
' + right
return left + '
' + right
# If all characters on the right are numbers. e.g. "a4", the
# If all characters on the right are numbers. e.g. "a4", the
...
...
tests/test_parser.py
View file @
dadd40a4
...
@@ -148,7 +148,7 @@ class TestParser(RulesTestCase):
...
@@ -148,7 +148,7 @@ class TestParser(RulesTestCase):
self
.
assertEqual
(
tree
(
token
),
Leaf
(
token
))
self
.
assertEqual
(
tree
(
token
),
Leaf
(
token
))
a
,
t
=
Leaf
(
'a'
),
Leaf
(
token
)
a
,
t
=
Leaf
(
'a'
),
Leaf
(
token
)
self
.
assertEqual
(
tree
(
'a'
+
token
),
a
*
t
)
self
.
assertEqual
(
tree
(
'a'
+
token
),
a
*
t
)
# FIXME:
self.assertEqual(tree('a' + token + 'a'), a * t * a)
self
.
assertEqual
(
tree
(
'a'
+
token
+
'a'
),
a
*
t
*
a
)
def
test_integral
(
self
):
def
test_integral
(
self
):
x
,
y
,
dx
,
a
,
b
,
l2
,
oo
=
tree
(
'x, y, dx, a, b, 2, oo'
)
x
,
y
,
dx
,
a
,
b
,
l2
,
oo
=
tree
(
'x, y, dx, a, b, 2, oo'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment