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
092de795
Commit
092de795
authored
Feb 23, 2016
by
Michael Schwarz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
further RR + bugfix for SR if prod has no prec
parent
15d50333
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
10 deletions
+93
-10
CupPlugin/src/de/tum/in/www2/cupplugin/views/ConflictPanel.java
...gin/src/de/tum/in/www2/cupplugin/views/ConflictPanel.java
+79
-6
CupPlugin/src/de/tum/in/www2/cupplugin/views/CupConflictsView.java
.../src/de/tum/in/www2/cupplugin/views/CupConflictsView.java
+12
-2
CupPlugin/src/de/tum/in/www2/cupplugin/views/PrecedenceToInsert.java
...rc/de/tum/in/www2/cupplugin/views/PrecedenceToInsert.java
+2
-2
No files found.
CupPlugin/src/de/tum/in/www2/cupplugin/views/ConflictPanel.java
View file @
092de795
...
...
@@ -42,6 +42,7 @@ import de.tum.in.www2.cupplugin.Colors;
import
de.tum.in.www2.cupplugin.Pair
;
import
de.tum.in.www2.cupplugin.views.CupConflictsView.ShiftReduceDetails
;
import
de.tum.in.www2.cupplugin.views.PrecedenceToInsert.PrecedenceCyclicException
;
import
de.tum.in.www2.cupplugin.views.ReordersToDo.OrderCyclicException
;
class
ConflictPanel
extends
Composite
{
private
final
CupConflictsView
cupConflictsView
;
...
...
@@ -591,11 +592,6 @@ class ConflictPanel extends Composite {
}
private
void
resolutionButtonSRClick
(){
if
(
cupConflictsView
.
currentResolution
!=
null
&&
cupConflictsView
.
currentResolution
.
isActive
())
{
// That should not happen, if we are inside a connected conflict, button is disabled
return
;
}
if
(!
srdetails
.
shiftAndReducePrecedenceFromSameTerminal
()){
// The user wants to shift, but shifting affects other conflicts
if
(
srdetails
.
shiftAffectsOthers
&&
resolutionOptions
.
getSelectionIndex
()
==
1
){
...
...
@@ -667,7 +663,22 @@ class ConflictPanel extends Composite {
rrr
.
apply
();
}
else
{
cupConflictsView
.
beginConnectedResolutionRR
();
if
(
resolutionOptions
.
getSelectionIndex
()
==
1
){
try
{
cupConflictsView
.
setOrder
(
item1
,
item2
);
}
catch
(
OrderCyclicException
e
)
{
e
.
printStackTrace
();
}
}
if
(
resolutionOptions
.
getSelectionIndex
()
==
2
){
try
{
cupConflictsView
.
setOrder
(
item2
,
item1
);
}
catch
(
OrderCyclicException
e
)
{
e
.
printStackTrace
();
}
}
}
}
...
...
@@ -679,6 +690,12 @@ class ConflictPanel extends Composite {
if
(
resolutionOptions
.
getSelectionIndex
()
==
0
){
return
;
}
if
(
cupConflictsView
.
currentResolution
!=
null
&&
cupConflictsView
.
currentResolution
.
isActive
())
{
// That should not happen, if we are inside a connected conflict, button is disabled
return
;
}
if
(
conflict
instanceof
ShiftReduceConflict
){
resolutionButtonSRClick
();
}
...
...
@@ -738,6 +755,41 @@ class ConflictPanel extends Composite {
}
}
private
void
resolutionBoxSelectedRR
()
throws
internal_error
{
ReordersToDo
rtd
=
(
ReordersToDo
)
cupConflictsView
.
currentResolution
;
ReduceReduceConflict
rrc
=
(
ReduceReduceConflict
)
conflict
;
lr_item_core
item1
=
new
lr_item_core
(
rrc
.
getConflictItem1
().
the_production
(),
rrc
.
getConflictItem1
().
dot_pos
());
lr_item_core
item2
=
new
lr_item_core
(
rrc
.
getConflictItem2
().
the_production
(),
rrc
.
getConflictItem2
().
dot_pos
());
if
((
resolutionOptions
.
getSelectionIndex
()
==
1
&&
rtd
.
isResolvedInFavorOf1
(
item1
,
item2
))
||
(
resolutionOptions
.
getSelectionIndex
()
==
2
&&
rtd
.
isResolvedInFavorOf2
(
item1
,
item2
)))
{
// Current action is desired -> Do nothing
return
;
}
if
(
resolutionOptions
.
getSelectionIndex
()
==
1
){
//Reduce with 1
try
{
cupConflictsView
.
setOrder
(
item1
,
item2
);
}
catch
(
OrderCyclicException
e1
)
{
showCyclicMessageAndResetDropdown
(
e1
);
return
;
}
}
if
(
resolutionOptions
.
getSelectionIndex
()
==
2
){
// Reduce
try
{
cupConflictsView
.
setOrder
(
item2
,
item1
);
}
catch
(
OrderCyclicException
e1
)
{
showCyclicMessageAndResetDropdown
(
e1
);
return
;
}
}
}
private
SelectionListener
resolutionBoxSelected
=
new
SelectionListener
()
{
@Override
...
...
@@ -756,7 +808,12 @@ class ConflictPanel extends Composite {
resolutionBoxSelectedSR
();
}
else
{
try
{
resolutionBoxSelectedRR
();
}
catch
(
internal_error
e1
)
{
// TODO Auto-generated catch block
e1
.
printStackTrace
();
}
}
}
...
...
@@ -782,4 +839,20 @@ class ConflictPanel extends Composite {
markIfAffected
(
cupConflictsView
.
currentResolution
);
}
/**
* Show the message that the orders were cyclic. Reset the dropdown to the value determined by the
* order
* @param e Exception that caused this. Contains cycle
*/
private
void
showCyclicMessageAndResetDropdown
(
OrderCyclicException
e
){
Shell
shell
=
new
Shell
(
Display
.
getCurrent
());
MessageBox
box
=
new
MessageBox
(
shell
,
SWT
.
ICON_WARNING
|
SWT
.
OK
);
box
.
setText
(
"Information"
);
box
.
setMessage
(
"These orders are inconsistent because they contain a cycle.\n"
+
e
.
cycleToString
()
+
"\n"
+
"The order that was inserted last is undone."
);
box
.
open
();
markIfAffected
(
cupConflictsView
.
currentResolution
);
}
}
\ No newline at end of file
CupPlugin/src/de/tum/in/www2/cupplugin/views/CupConflictsView.java
View file @
092de795
...
...
@@ -68,6 +68,7 @@ import de.tum.in.www2.cupplugin.editors.RevisionManager;
import
de.tum.in.www2.cupplugin.model.ICupParserLaLrChangeObserver
;
import
de.tum.in.www2.cupplugin.model.Model
;
import
de.tum.in.www2.cupplugin.views.PrecedenceToInsert.PrecedenceCyclicException
;
import
de.tum.in.www2.cupplugin.views.ReordersToDo.OrderCyclicException
;
public
class
CupConflictsView
extends
FailableView
implements
ICupEditorPageVisibility
,
ICupParserLaLrChangeObserver
,
IRegisterForControllerChanges
{
...
...
@@ -250,7 +251,7 @@ public class CupConflictsView extends FailableView
int
size
=
conflicts
.
size
();
// Do this less often
updateBuildfile
(
ignored
);
//
updateBuildfile(ignored);
scrolled
.
setLayoutDeferred
(
true
);
...
...
@@ -450,7 +451,11 @@ public class CupConflictsView extends FailableView
return
(
PrecedenceToInsert
)
currentResolution
;
}
void
addFirstPrecedence
(
terminal
t
,
terminal
other
)
{
private
ReordersToDo
getRtd
(){
return
(
ReordersToDo
)
currentResolution
;
}
void
addFirstPrecedence
(
terminal
t
,
terminal
other
)
{
getPti
().
add
(
t
,
other
);
markAllAffected
();
}
...
...
@@ -465,6 +470,11 @@ public class CupConflictsView extends FailableView
markAllAffected
();
}
void
setOrder
(
lr_item_core
higher
,
lr_item_core
lower
)
throws
OrderCyclicException
{
getRtd
().
insertOrder
(
higher
,
lower
);
markAllAffected
();
}
/**
* Set currentPrecs Doesn't mark affected conflicts
*/
...
...
CupPlugin/src/de/tum/in/www2/cupplugin/views/PrecedenceToInsert.java
View file @
092de795
...
...
@@ -114,8 +114,8 @@ class PrecedenceToInsert extends GraphHelper<terminal> implements ResolutionStra
* @return true iff it can be changed
*/
public
boolean
canChangeDefaultResolution
(
ShiftReduceDetails
srd
){
return
!((
precs
.
containsKey
(
srd
.
shift
)
||
(
originalEdge
!=
null
&&
originalEdge
.
getFirst
().
equals
(
srd
.
shift
)))
&&
(
precs
.
containsKey
(
srd
.
reduce
)
||
(
originalEdge
!=
null
&&
originalEdge
.
getFirst
().
equals
(
srd
.
reduce
))));
return
!((
precs
.
containsKey
(
srd
.
shift
)
||
(
originalEdge
!=
null
&&
originalEdge
.
getFirst
()
!=
null
&&
originalEdge
.
getFirst
()
.
equals
(
srd
.
shift
)))
&&
(
precs
.
containsKey
(
srd
.
reduce
)
||
(
originalEdge
!=
null
&&
originalEdge
.
getFirst
()
!=
null
&&
originalEdge
.
getFirst
()
.
equals
(
srd
.
reduce
))));
}
/**
...
...
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