Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
trs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
trs
Commits
f319783e
Commit
f319783e
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Removed prototype function grammar.
parent
b9aea94e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/node.py
+0
-2
0 additions, 2 deletions
src/node.py
src/parser.py
+2
-45
2 additions, 45 deletions
src/parser.py
with
2 additions
and
47 deletions
src/node.py
+
0
−
2
View file @
f319783e
...
...
@@ -98,8 +98,6 @@ TOKEN_MAP = {
OP_REWRITE
:
'
REWRITE
'
,
}
FUNCTIONS
=
[
OP_SQRT
,
OP_SIN
,
OP_COS
,
OP_TAN
,
OP_INT
,
OP_SOLVE
]
def
to_expression
(
obj
):
return
obj
if
isinstance
(
obj
,
ExpressionBase
)
else
ExpressionLeaf
(
obj
)
...
...
This diff is collapsed.
Click to expand it.
src/parser.py
+
2
−
45
View file @
f319783e
...
...
@@ -314,7 +314,6 @@ class Parser(BisonParser):
"""
exp : NUMBER
| IDENTIFIER
| function
| LPAREN exp RPAREN
| unary
| binary
...
...
@@ -330,13 +329,10 @@ class Parser(BisonParser):
if
option
==
1
:
# rule: IDENTIFIER
return
Leaf
(
values
[
0
])
if
option
==
2
:
# rule: function
return
values
[
0
]
if
option
==
3
:
# rule: LPAREN exp RPAREN
if
option
==
2
:
# rule: LPAREN exp RPAREN
return
values
[
1
]
if
option
in
[
4
,
5
,
6
]:
# rule: unary | binary | nary
if
option
in
[
3
,
4
,
5
]:
# rule: unary | binary | nary
return
values
[
0
]
raise
BisonSyntaxError
(
'
Unsupported option %d in target
"
%s
"
.
'
...
...
@@ -409,45 +405,6 @@ class Parser(BisonParser):
raise
BisonSyntaxError
(
'
Unsupported option %d in target
"
%s
"
.
'
%
(
option
,
target
))
# pragma: nocover
def
on_function
(
self
,
target
,
option
,
names
,
values
):
"""
function : function_name LPAREN arglist RPAREN
"""
if
option
==
0
:
# rule: function_name LPAREN arglist RPAREN
print
'
FUNCTION:
'
,
values
[
0
],
values
[
2
]
return
Node
(
values
[
0
],
*
values
[
2
])
raise
BisonSyntaxError
(
'
Unsupported option %d in target
"
%s
"
.
'
%
(
option
,
target
))
# pragma: nocover
def
on_function_name
(
self
,
target
,
option
,
names
,
values
):
"""
function_name : SQRT | SIN | COS | TAN | INT | SOLVE
"""
if
0
<=
option
<=
5
:
# rule: SQRT | SIN | COS | TAN | INT | SOLVE
return
values
[
0
]
#return TOKEN_OP_MAP[values[0]]
raise
BisonSyntaxError
(
'
Unsupported option %d in target
"
%s
"
.
'
%
(
option
,
target
))
# pragma: nocover
def
on_arglist
(
self
,
target
,
option
,
names
,
values
):
"""
arglist : arglist COMMA exp
| exp
"""
if
option
==
0
:
# rule: arglist COMMA exp
return
values
[
0
]
+
[
values
[
2
]]
if
option
==
1
:
# rule: exp
return
[
values
[
0
]]
raise
BisonSyntaxError
(
'
Unsupported option %d in target
"
%s
"
.
'
%
(
option
,
target
))
# pragma: nocover
# -----------------------------------------
# operator tokens
# -----------------------------------------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment