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
Michael Schwarz
CUP Eclipse Plugin
Commits
3eef45a1
Commit
3eef45a1
authored
Feb 23, 2016
by
Michael Schwarz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restructering for Reduce/Reduce
parent
69166194
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
736 additions
and
613 deletions
+736
-613
CupPlugin/src/de/tum/in/www2/cupplugin/views/ConflictPanel.java
...gin/src/de/tum/in/www2/cupplugin/views/ConflictPanel.java
+630
-590
CupPlugin/src/de/tum/in/www2/cupplugin/views/CupConflictsView.java
.../src/de/tum/in/www2/cupplugin/views/CupConflictsView.java
+47
-14
CupPlugin/src/de/tum/in/www2/cupplugin/views/GraphHelper.java
...lugin/src/de/tum/in/www2/cupplugin/views/GraphHelper.java
+4
-3
CupPlugin/src/de/tum/in/www2/cupplugin/views/PrecedenceToInsert.java
...rc/de/tum/in/www2/cupplugin/views/PrecedenceToInsert.java
+15
-5
CupPlugin/src/de/tum/in/www2/cupplugin/views/ReordersToDo.java
...ugin/src/de/tum/in/www2/cupplugin/views/ReordersToDo.java
+20
-1
CupPlugin/src/de/tum/in/www2/cupplugin/views/ResolutionStrategy.java
...rc/de/tum/in/www2/cupplugin/views/ResolutionStrategy.java
+20
-0
No files found.
CupPlugin/src/de/tum/in/www2/cupplugin/views/ConflictPanel.java
View file @
3eef45a1
This diff is collapsed.
Click to expand it.
CupPlugin/src/de/tum/in/www2/cupplugin/views/CupConflictsView.java
View file @
3eef45a1
...
...
@@ -87,8 +87,8 @@ public class CupConflictsView extends FailableView
private
HashMap
<
terminal
,
Integer
>
terminalsAffectConflicts
;
private
HashMap
<
lr_item_core
,
Integer
>
ordersAffectConflicts
;
PrecedenceToInsert
currentPrecs
;
ResolutionStrategy
currentResolution
;
public
int
ignoreRRAfterLine
;
class
ShiftReduceDetails
{
...
...
@@ -261,7 +261,7 @@ public class CupConflictsView extends FailableView
panel
.
update
(
crm
,
conflict
);
}
if
(
current
Precs
!=
null
&&
currentPrecs
.
isActive
())
{
if
(
current
Resolution
!=
null
&&
currentResolution
.
isActive
())
{
markAllAffected
();
}
...
...
@@ -401,7 +401,7 @@ public class CupConflictsView extends FailableView
@Override
public
void
modelChanged
(
Model
model
)
{
if
(
current
Precs
!=
null
&&
currentPrecs
.
isActive
())
{
if
(
current
Resolution
!=
null
&&
currentResolution
.
isActive
())
{
// Connected resolution does no longer make sense
abortConnectedResolution
(
false
);
}
...
...
@@ -437,7 +437,7 @@ public class CupConflictsView extends FailableView
void
markAllAffected
()
{
int
affected
=
0
;
for
(
ConflictPanel
c
:
conflictPanels
)
{
if
(
c
.
markIfAffected
(
current
Precs
))
{
if
(
c
.
markIfAffected
(
current
Resolution
))
{
affected
++;
}
}
...
...
@@ -446,25 +446,29 @@ public class CupConflictsView extends FailableView
+
affected
+
" conflicts involved)."
);
}
private
PrecedenceToInsert
getPti
(){
return
(
PrecedenceToInsert
)
currentResolution
;
}
void
addFirstPrecedence
(
terminal
t
,
terminal
other
)
{
currentPrecs
.
add
(
t
,
other
);
getPti
()
.
add
(
t
,
other
);
markAllAffected
();
}
void
addFurtherPrecedence
(
terminal
higher
,
terminal
lower
)
throws
PrecedenceCyclicException
{
currentPrecs
.
addPrecedence
(
higher
,
lower
);
getPti
()
.
addPrecedence
(
higher
,
lower
);
markAllAffected
();
}
void
setTerminalAssoc
(
terminal
t
,
Precedence
.
Type
p
)
{
currentPrecs
.
setAssoc
(
t
,
p
);
getPti
()
.
setAssoc
(
t
,
p
);
markAllAffected
();
}
/**
* Set currentPrecs Doesn't mark affected conflicts
*/
void
beginConnectedResolution
()
{
void
beginConnectedResolution
SR
()
{
Shell
shell
=
new
Shell
(
Display
.
getCurrent
());
MessageBox
box
=
new
MessageBox
(
shell
,
SWT
.
ICON_WARNING
|
SWT
.
OK
);
box
.
setText
(
"Information"
);
...
...
@@ -472,7 +476,7 @@ public class CupConflictsView extends FailableView
+
"The effects if no further precedences are inserted are simulated right now."
);
box
.
open
();
current
Precs
=
new
PrecedenceToInsert
();
current
Resolution
=
new
PrecedenceToInsert
();
// Text of label already set in the markAllAffected()
this
.
connectedResolutionLabel
.
setVisible
(
true
);
this
.
connectedResolutionAbort
.
setVisible
(
true
);
...
...
@@ -480,15 +484,31 @@ public class CupConflictsView extends FailableView
refreshScrolledLayout
();
}
void
beginConnectedResolutionRR
(){
Shell
shell
=
new
Shell
(
Display
.
getCurrent
());
MessageBox
box
=
new
MessageBox
(
shell
,
SWT
.
ICON_WARNING
|
SWT
.
OK
);
box
.
setText
(
"Information"
);
box
.
setMessage
(
"This affects some other conflicts. These are marked now. Please resolve all those as well.\n"
+
"The effects if no further orderings are inserted are simulated right now."
);
box
.
open
();
currentResolution
=
new
ReordersToDo
();
// Text of label already set in the markAllAffected()
this
.
connectedResolutionLabel
.
setVisible
(
true
);
this
.
connectedResolutionAbort
.
setVisible
(
true
);
this
.
connectedResolutionApply
.
setVisible
(
true
);
refreshScrolledLayout
();
}
/**
* Abort connected resolution and reset all panels
* Abort connected resolution
(regardless of SR or RR)
and reset all panels
*
* @param refresh
* Refresh UI to make changes visible (true unless panels will
* change later anyway)
*/
private
void
abortConnectedResolution
(
boolean
refresh
)
{
current
Precs
=
new
PrecedenceToInsert
()
;
current
Resolution
=
null
;
this
.
connectedResolutionLabel
.
setVisible
(
false
);
this
.
connectedResolutionAbort
.
setVisible
(
false
);
this
.
connectedResolutionApply
.
setVisible
(
false
);
...
...
@@ -521,12 +541,25 @@ public class CupConflictsView extends FailableView
return
;
}
}
if
(
currentResolution
instanceof
PrecedenceToInsert
){
applyConnectedResolutionSR
();
}
else
{
applyConnectedResolutionRR
();
}
}
private
void
applyConnectedResolutionRR
(){
}
private
void
applyConnectedResolutionSR
(){
try
{
IDocument
document
=
editor
.
getDocument
();
ParserResult
r
=
Model
.
getInstanceForDocument
(
document
).
getAstModel
();
String
toInsert
=
currentPrecs
.
precsToInsert
();
String
toInsert
=
getPti
()
.
precsToInsert
();
int
positionForPrec
=
0
;
if
(
r
.
precedences
.
size
()
==
0
)
{
...
...
CupPlugin/src/de/tum/in/www2/cupplugin/views/GraphHelper.java
View file @
3eef45a1
...
...
@@ -8,14 +8,16 @@ import java.util.Set;
import
java.util.Stack
;
import
java.util.Map.Entry
;
import
de.in.tum.www2.cup.Conflict
;
import
de.in.tum.www2.cup.internal.terminal
;
import
de.tum.in.www2.cupplugin.views.CupConflictsView.ShiftReduceDetails
;
public
class
GraphHelper
<
X
>
{
public
abstract
class
GraphHelper
<
X
>
{
// Edges are stored in reverse order (i.e. there is a edge from a to b iff b has a explicit
// higher precedence / order in general than a
protected
HashMap
<
X
,
Set
<
X
>>
edges
;
p
ublic
class
TarjanNodeInfo
{
p
rotected
class
TarjanNodeInfo
{
public
int
index
;
public
boolean
onStack
;
public
int
lowlink
;
...
...
@@ -124,5 +126,4 @@ public class GraphHelper<X> {
return
false
;
}
}
\ No newline at end of file
CupPlugin/src/de/tum/in/www2/cupplugin/views/PrecedenceToInsert.java
View file @
3eef45a1
...
...
@@ -9,13 +9,16 @@ import java.util.Set;
import
java.util.Stack
;
import
java.util.Map.Entry
;
import
de.in.tum.www2.cup.Conflict
;
import
de.in.tum.www2.cup.ReduceReduceConflict
;
import
de.in.tum.www2.cup.ShiftReduceConflict
;
import
de.in.tum.www2.cup.ast.Precedence
;
import
de.in.tum.www2.cup.internal.terminal
;
import
de.tum.in.www2.cupplugin.Pair
;
import
de.tum.in.www2.cupplugin.views.CupConflictsView.ShiftReduceDetails
;
import
de.tum.in.www2.cupplugin.views.GraphHelper.TarjanNodeInfo
;
class
PrecedenceToInsert
extends
GraphHelper
<
terminal
>{
class
PrecedenceToInsert
extends
GraphHelper
<
terminal
>
implements
ResolutionStrategy
{
private
HashMap
<
terminal
,
Precedence
.
Type
>
precs
=
new
HashMap
<>();
// These need to be inserted whenever an edge that contains the key is to be inserted
...
...
@@ -294,11 +297,18 @@ class PrecedenceToInsert extends GraphHelper<terminal>{
}
}
/**
* Check if active (i.e. more than 0 precedences)
* @return
*/
@Override
public
boolean
isActive
(){
return
precs
.
size
()
!=
0
;
}
@Override
public
boolean
isAffected
(
Conflict
c
,
ShiftReduceDetails
details
)
{
if
(
c
instanceof
ShiftReduceConflict
&&
isAffected
(
details
)){
return
true
;
}
else
{
return
false
;
}
}
}
\ No newline at end of file
CupPlugin/src/de/tum/in/www2/cupplugin/views/ReordersToDo.java
View file @
3eef45a1
...
...
@@ -7,6 +7,9 @@ import java.util.List;
import
java.util.Stack
;
import
java.util.Map.Entry
;
import
de.in.tum.www2.cup.Conflict
;
import
de.in.tum.www2.cup.ReduceReduceConflict
;
import
de.in.tum.www2.cup.ShiftReduceConflict
;
import
de.in.tum.www2.cup.ast.Precedence
;
import
de.in.tum.www2.cup.internal.internal_error
;
import
de.in.tum.www2.cup.internal.lalr_item
;
...
...
@@ -14,9 +17,10 @@ import de.in.tum.www2.cup.internal.lr_item_core;
import
de.in.tum.www2.cup.internal.terminal
;
import
de.tum.in.www2.cupplugin.Pair
;
import
de.tum.in.www2.cupplugin.views.GraphHelper.TarjanNodeInfo
;
import
de.tum.in.www2.cupplugin.views.CupConflictsView.ShiftReduceDetails
;
import
de.tum.in.www2.cupplugin.views.PrecedenceToInsert.PrecedenceCyclicException
;
public
class
ReordersToDo
extends
GraphHelper
<
lr_item_core
>{
public
class
ReordersToDo
extends
GraphHelper
<
lr_item_core
>
implements
ResolutionStrategy
{
private
LinkedList
<
lr_item_core
>
result
;
public
ReordersToDo
(){
...
...
@@ -190,6 +194,21 @@ public class ReordersToDo extends GraphHelper<lr_item_core>{
return
result
;
}
@Override
public
boolean
isAffected
(
Conflict
c
,
ShiftReduceDetails
details
)
{
if
(
c
instanceof
ReduceReduceConflict
){
ReduceReduceConflict
rrc
=
(
ReduceReduceConflict
)
c
;
return
isAffected
(
rrc
.
getConflictItem1
(),
rrc
.
getConflictItem2
());
}
else
{
return
false
;
}
}
@Override
public
boolean
isActive
(){
return
edges
.
keySet
().
size
()
!=
0
;
}
}
CupPlugin/src/de/tum/in/www2/cupplugin/views/ResolutionStrategy.java
0 → 100644
View file @
3eef45a1
package
de.tum.in.www2.cupplugin.views
;
import
de.in.tum.www2.cup.Conflict
;
import
de.tum.in.www2.cupplugin.views.CupConflictsView.ShiftReduceDetails
;
public
interface
ResolutionStrategy
{
/**
* return true iff the conflict is affected
* @param c Conflict
* @param details details if conflict is Shiftreduce, null otherwise
* @return true iff conflict is affected
*/
public
abstract
boolean
isAffected
(
Conflict
c
,
ShiftReduceDetails
details
);
/**
* Check if active (i.e. more than 0 item)
* @return
*/
public
abstract
boolean
isActive
();
}
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