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
b2ddec59
Commit
b2ddec59
authored
Mar 25, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolved shift/reduce conflict for integrals.
parent
cbd37711
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
7 deletions
+27
-7
src/parser.py
src/parser.py
+27
-7
No files found.
src/parser.py
View file @
b2ddec59
...
...
@@ -93,7 +93,7 @@ class Parser(BisonParser):
(
'left'
,
(
'EQ'
,
)),
(
'left'
,
(
'NEG'
,
)),
(
'right'
,
(
'POW'
,
)),
(
'
righ
t'
,
(
'SUB'
,
)),
(
'
lef
t'
,
(
'SUB'
,
)),
(
'right'
,
(
'FUNCTION_LPAREN'
,
)),
)
...
...
@@ -397,11 +397,12 @@ class Parser(BisonParser):
| DERIVATIVE exp
| bracket_derivative
| INTEGRAL exp
|
INTEGRAL bounds
exp %prec INTEGRAL
|
integral_bounds TIMES
exp %prec INTEGRAL
"""
if
option
==
0
:
# rule: NEG exp
node
=
values
[
1
]
# Add negation to the left-most child
if
node
.
is_leaf
or
(
node
.
op
!=
OP_MUL
and
node
.
op
!=
OP_DIV
):
node
.
negated
+=
1
...
...
@@ -453,8 +454,8 @@ class Parser(BisonParser):
return
Node
(
OP_INT
,
fx
,
x
)
if
option
==
6
:
# rule:
INTEGRAL bounds
exp
lbnd
,
ubnd
=
values
[
1
]
if
option
==
6
:
# rule:
integral_bounds TIMES
exp
lbnd
,
ubnd
=
values
[
0
]
fx
,
x
=
find_integration_variable
(
values
[
2
])
return
Node
(
OP_INT
,
fx
,
x
,
lbnd
,
ubnd
)
...
...
@@ -462,12 +463,31 @@ class Parser(BisonParser):
raise
BisonSyntaxError
(
'Unsupported option %d in target "%s".'
%
(
option
,
target
))
# pragma: nocover
def
on_bounds
(
self
,
target
,
option
,
names
,
values
):
def
on_
integral_
bounds
(
self
,
target
,
option
,
names
,
values
):
"""
bounds : SUB power TIMES
integral_bounds : INTEGRAL lbnd rbnd
"""
if
option
==
0
:
# rule: INTEGRAL lbnd rbnd
return
values
[
1
],
values
[
2
]
raise
BisonSyntaxError
(
'Unsupported option %d in target "%s".'
%
(
option
,
target
))
# pragma: nocover
if
option
==
0
:
# rule: SUB power
def
on_lbnd
(
self
,
target
,
option
,
names
,
values
):
"""
lbnd : SUB exp
"""
if
option
==
0
:
# rule: SUB exp
return
values
[
1
]
raise
BisonSyntaxError
(
'Unsupported option %d in target "%s".'
%
(
option
,
target
))
# pragma: nocover
def
on_rbnd
(
self
,
target
,
option
,
names
,
values
):
"""
rbnd : POW exp
"""
if
option
==
0
:
# rule: POW exp
return
values
[
1
]
raise
BisonSyntaxError
(
'Unsupported option %d in target "%s".'
...
...
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