Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
finesse
finesse3
Commits
d8f43f0d
Commit
d8f43f0d
authored
Apr 28, 2020
by
Phil Jones
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trial improved expression parsing.
parent
e0b5bc04
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
finesse/script/parser.py
finesse/script/parser.py
+12
-3
playground/expression_test.ipynb
playground/expression_test.ipynb
+0
-0
No files found.
finesse/script/parser.py
View file @
d8f43f0d
...
...
@@ -407,8 +407,6 @@ class _KatInstructionLEX(Lexer):
FUNCTION_NAME
=
"cos|sin"
PARAMETER
=
"&[a-zA-Z_][a-zA-Z0-9_.]*"
PLUS
=
TOKEN_MAP
[
"PLUS"
]
MINUS
=
TOKEN_MAP
[
"MINUS"
]
TIMES
=
TOKEN_MAP
[
"TIMES"
]
DIVIDE
=
TOKEN_MAP
[
"DIVIDE"
]
COMMA
=
TOKEN_MAP
[
"COMMA"
]
...
...
@@ -426,7 +424,10 @@ class _KatInstructionLEX(Lexer):
return
t
# Number token including scientific notation, float, or +/- inf.
@
_
(
r
"[+-]?inf"
,
r
"[+-]?(\d+\.\d*|\d*\.\d+|\d+)([eE]-?\d*\.?\d*)?j?([pnumkMGT])?"
)
@
_
(
r
"(\B[+-])?inf"
,
r
"(\B[+-])?(\d+\.\d*|\d*\.\d+|\d+)([eE]-?\d*\.?\d*)?j?([pnumkMGT])?"
,
)
def
NUMBER
(
self
,
t
):
if
re
.
match
(
".*[pnumkMGT]$"
,
t
.
value
):
t
.
value
=
t
.
value
.
replace
(
"p"
,
"e-12"
)
...
...
@@ -450,6 +451,14 @@ class _KatInstructionLEX(Lexer):
t
.
value
=
int
(
t
.
value
)
return
t
@
_
(
r
"-"
)
def
MINUS
(
self
,
t
):
return
t
@
_
(
r
"\+"
)
def
PLUS
(
self
,
t
):
return
t
@
_
(
r
"[a-zA-Z_][a-zA-Z0-9_.]*\*?"
,
"inf"
)
def
STRING
(
self
,
t
):
if
t
.
value
==
"inf"
:
...
...
playground/expression_test.ipynb
0 → 100644
View file @
d8f43f0d
This diff was suppressed by a .gitattributes entry.
Sean Leavey
@sean-leavey
mentioned in issue
#105 (closed)
·
Apr 29, 2020
mentioned in issue
#105 (closed)
mentioned in issue #105
Toggle commit list
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