Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CUP Eclipse Plugin
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
Dr. Michael Petter
CUP Eclipse Plugin
Commits
df3d8605
Commit
df3d8605
authored
Feb 21, 2016
by
Michael Schwarz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed speculative edges from PrecedenceTo Insert -> unnecessary
parent
c761c9b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
38 deletions
+13
-38
CupPlugin/src/de/tum/in/www2/cupplugin/views/PrecedenceToInsert.java
...rc/de/tum/in/www2/cupplugin/views/PrecedenceToInsert.java
+13
-38
No files found.
CupPlugin/src/de/tum/in/www2/cupplugin/views/PrecedenceToInsert.java
View file @
df3d8605
...
...
@@ -23,7 +23,7 @@ class PrecedenceToInsert {
private
HashMap
<
terminal
,
Set
<
terminal
>>
edges
=
new
HashMap
<>();
// These need to be inserted whenever an edge that contains the key is to be inserted
private
HashMap
<
terminal
,
Set
<
terminal
>>
speculativeEdges
=
new
HashMap
<>()
;
private
Pair
<
terminal
,
terminal
>
originalEdge
;
private
int
tarjanIndex
;
private
HashMap
<
terminal
,
TarjanNodeInfo
>
tarjanNodeInfos
;
...
...
@@ -77,7 +77,6 @@ class PrecedenceToInsert {
*/
public
boolean
isResolvedInFavorOfShift
(
ShiftReduceDetails
srd
){
if
(!
srd
.
shiftAndReducePrecedenceFromSameTerminal
())
//TODO: Check if precedence set for terminal at all
return
hasPrecedence
(
srd
.
shift
,
srd
.
reduce
);
else
return
precs
.
get
(
srd
.
shift
)
==
Precedence
.
Type
.
Right
;
...
...
@@ -90,7 +89,6 @@ class PrecedenceToInsert {
*/
public
boolean
isResolvedInFavorOfReduce
(
ShiftReduceDetails
srd
)
{
if
(!
srd
.
shiftAndReducePrecedenceFromSameTerminal
())
//TODO: Check if precedence set for terminal at all
return
hasPrecedence
(
srd
.
reduce
,
srd
.
shift
);
else
return
precs
.
get
(
srd
.
shift
)
==
Precedence
.
Type
.
Left
;
...
...
@@ -129,9 +127,7 @@ class PrecedenceToInsert {
precs
.
put
(
t
,
Precedence
.
Type
.
NoPrec
);
edges
.
put
(
t
,
new
HashSet
<>());
HashSet
<
terminal
>
spec
=
new
HashSet
<>();
spec
.
add
(
t
);
speculativeEdges
.
put
(
other
,
spec
);
originalEdge
=
new
Pair
<>(
other
,
t
);
}
/**
...
...
@@ -152,20 +148,16 @@ class PrecedenceToInsert {
addedHigher
=
true
;
}
if
(!
precs
.
containsKey
(
lower
)){
precs
.
put
(
lower
,
Precedence
.
Type
.
NoPrec
);
edges
.
put
(
lower
,
new
HashSet
<>());
// Lower is guaranteed to be part of the current conflict,
// otherwise we would not need to insert prec since
// - not affected
// - resolved the way we want it to be resolved anyway
if
(
originalEdge
.
getFirst
().
equals
(
higher
)){
// We know the for original edge u->v that u is present since u == higher
addedLower
=
true
;
}
Set
<
terminal
>
outgoingSpecEdgesHigher
=
new
HashSet
<>();
if
(
speculativeEdges
.
containsKey
(
higher
)){
// Insert all speculative edges that are outgoing from the node with higher pred
// We don't need to add it it to precs, it is already there
edges
.
get
(
higher
).
addAll
(
speculativeEdges
.
get
(
higher
));
outgoingSpecEdgesHigher
.
addAll
(
speculativeEdges
.
get
(
higher
));
speculativeEdges
.
remove
(
higher
);
// This is a guarantee for cyclic but we let the algorithm run anyway in order to give the user
// the feedback about the cycle
edges
.
get
(
higher
).
add
(
originalEdge
.
getSecond
());
}
// Insert edge
...
...
@@ -175,20 +167,12 @@ class PrecedenceToInsert {
//Do rollback
edges
.
get
(
lower
).
remove
(
higher
);
if
(
outgoingSpecEdgesHigher
.
size
()
!=
0
){
// Remove from real edges
edges
.
get
(
higher
).
removeAll
(
outgoingSpecEdgesHigher
);
// Remove original edge if it was added.
edges
.
get
(
higher
).
remove
(
originalEdge
.
getSecond
());
//Add to spec edges again
speculativeEdges
.
put
(
higher
,
outgoingSpecEdgesHigher
);
}
if
(
addedHigher
){
precs
.
remove
(
higher
);
}
if
(
addedLower
){
precs
.
remove
(
lower
);
}
throw
new
PrecedenceCyclicException
(
""
,
cycle
);
}
...
...
@@ -368,15 +352,6 @@ class PrecedenceToInsert {
}
toCheck
.
addAll
(
edges
.
get
(
over
));
// We need to consider those as well
if
(
speculativeEdges
.
get
(
over
)
!=
null
){
toCheck
.
addAll
(
speculativeEdges
.
get
(
over
));
}
// TODO:Sure ?
if
(
toCheck
.
size
()
==
0
){
return
false
;
}
while
(
toCheck
.
size
()
>
0
){
if
(
toCheck
.
contains
(
t
)){
...
...
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