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
a9dd4d45
Commit
a9dd4d45
authored
Sep 13, 2012
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed preprocessor with updated keyword list.
parent
07aceae5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
src/node.py
src/node.py
+2
-2
src/parser.py
src/parser.py
+8
-6
No files found.
src/node.py
View file @
a9dd4d45
...
@@ -80,11 +80,11 @@ OP_CBRACKETS = 31
...
@@ -80,11 +80,11 @@ OP_CBRACKETS = 31
UNARY_FUNCTIONS
=
[
OP_INT
,
OP_DXDER
,
OP_LOG
]
UNARY_FUNCTIONS
=
[
OP_INT
,
OP_DXDER
,
OP_LOG
]
# Special identifiers
# Special identifiers
PI
=
'pi'
E
=
'e'
E
=
'e'
PI
=
'pi'
INFINITY
=
'oo'
INFINITY
=
'oo'
SPECIAL_TOKENS
=
[
PI
,
E
,
INFINITY
]
SPECIAL_TOKENS
=
[
E
,
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 @
a9dd4d45
...
@@ -182,16 +182,18 @@ class Parser(BisonParser):
...
@@ -182,16 +182,18 @@ 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
(
10
,
'
\
n
'
)
words
.
insert
(
0xa
,
'
\
n
'
)
words
.
insert
(
13
,
'
\
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?
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
'
pattern
=
(
'(?:(
\
))
\
s*([([])'
# )( -> ) * (
pattern
=
(
'(?:(
[)
\
]])
\
s*([([])'
# )( -> ) * (
# )[ -> ) * [
# )[ -> ) * [
# ]( -> [ * (
# ][ -> [ * [
+
'|(['
+
rsv
+
'a-z0-9])
\
s*([([])
'
# a( -> a * (
+
'|(['
+
rsv
+
'a-z0-9])
\
s*([([])
'
# a( -> a * (
# a[ -> a * [
# a[ -> a * [
+ '
|
(
\
))
\
s
*
([
' + rsv + '
a
-
z0
-
9
])
' # )a -> ) * a
+ '
|
(
\
))
\
s
*
([
' + rsv + '
a
-
z0
-
9
])
' # )a -> ) * a
...
@@ -210,9 +212,9 @@ class Parser(BisonParser):
...
@@ -210,9 +212,9 @@ class Parser(BisonParser):
# Make sure there are no multiplication and exponentiation signs
# Make sure there are no multiplication and exponentiation signs
# inserted between a function and its argument(s): "sin x" should
# inserted between a function and its argument(s): "sin x" should
# not be written as "sin*x", because that is bogus.
# not be written as "sin*x", because that is bogus.
# Bugfix: omit 0x0
e
(pi) to prevent "pi a" (should be "pi*a")
# Bugfix: omit 0x0
c
(pi) to prevent "pi a" (should be "pi*a")
o = ord(left)
o = ord(left)
if o <= 0x9 or 0x
0b <= o <= 0x0d or 0x0f <= o <= 0x19
:
if o <= 0x9 or 0x
b <= o <= 0xc
:
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
...
@@ -222,7 +224,7 @@ class Parser(BisonParser):
...
@@ -222,7 +224,7 @@ class Parser(BisonParser):
# return '%s^%s' % (left, right)
# return '%s^%s' % (left, right)
# match: ab | abc | abcd (where left = "a")
# match: ab | abc | abcd (where left = "a")
return
'*'
.
join
([
left
]
+
list
(
r
ight
.
lstrip
(
)))
return
'*'
.
join
([
left
]
+
list
(
r
e
.
sub
(
'^ +'
,
''
,
right
)))
if
self
.
verbose
:
# pragma: nocover
if
self
.
verbose
:
# pragma: nocover
data_before
=
data
data_before
=
data
...
...
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