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
dd218ed2
Commit
dd218ed2
authored
Feb 21, 2016
by
Michael Schwarz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Report if other conflicts are affected by doing Reduce/Reduce resolution
parent
dc29a25d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
18 deletions
+66
-18
CupPlugin/src/de/tum/in/www2/cupplugin/views/ConflictPanel.java
...gin/src/de/tum/in/www2/cupplugin/views/ConflictPanel.java
+18
-2
CupPlugin/src/de/tum/in/www2/cupplugin/views/CupConflictsView.java
.../src/de/tum/in/www2/cupplugin/views/CupConflictsView.java
+48
-16
No files found.
CupPlugin/src/de/tum/in/www2/cupplugin/views/ConflictPanel.java
View file @
dd218ed2
...
...
@@ -35,6 +35,7 @@ import de.in.tum.www2.cup.ast.ProductionSymbolRef;
import
de.in.tum.www2.cup.internal.internal_error
;
import
de.in.tum.www2.cup.internal.lalr_item
;
import
de.in.tum.www2.cup.internal.lalr_state
;
import
de.in.tum.www2.cup.internal.lr_item_core
;
import
de.in.tum.www2.cup.internal.terminal
;
import
de.tum.in.www2.cupplugin.Colors
;
import
de.tum.in.www2.cupplugin.Pair
;
...
...
@@ -396,8 +397,23 @@ class ConflictPanel extends Composite {
resolutionOptions
.
removeAll
();
resolutionOptions
.
add
(
"-- Choose an option --"
);
resolutionOptions
.
select
(
0
);
resolutionOptions
.
add
(
"Reduce with production 1"
);
resolutionOptions
.
add
(
"Reduce with production 2"
);
String
affects
=
""
;
try
{
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
(
cupConflictsView
.
settingOrderAffetsOtherConflicts
(
item1
,
item2
)){
affects
=
"Affects others: "
;
}
}
catch
(
internal_error
e
)
{
e
.
printStackTrace
();
}
resolutionOptions
.
add
(
affects
+
"Reduce with production 1"
);
resolutionOptions
.
add
(
affects
+
"Reduce with production 2"
);
}
/**
...
...
CupPlugin/src/de/tum/in/www2/cupplugin/views/CupConflictsView.java
View file @
dd218ed2
...
...
@@ -40,6 +40,8 @@ import de.in.tum.www2.cup.ast.ProductionRight;
import
de.in.tum.www2.cup.ast.ProductionSymbolRef
;
import
de.in.tum.www2.cup.ast.SymbolDeclaration
;
import
de.in.tum.www2.cup.ast.Terminal
;
import
de.in.tum.www2.cup.internal.internal_error
;
import
de.in.tum.www2.cup.internal.lr_item_core
;
import
de.in.tum.www2.cup.internal.terminal
;
import
de.tum.in.www2.cupplugin.Colors
;
import
de.tum.in.www2.cupplugin.controller.Controller.JobsToDo
;
...
...
@@ -71,6 +73,7 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
private
Composite
list
;
private
HashMap
<
terminal
,
Integer
>
terminalsAffectConflicts
;
private
HashMap
<
lr_item_core
,
Integer
>
ordersAffectConflicts
;
PrecedenceToInsert
currentPrecs
;
private
int
ignoreRRAfterLine
;
...
...
@@ -199,11 +202,13 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
List
<
Conflict
>
conflicts
=
new
ArrayList
<>();
terminalsAffectConflicts
=
new
HashMap
<>();
ordersAffectConflicts
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
crm
.
getAllConflicts
().
size
();
i
++)
{
Conflict
c
=
crm
.
getAllConflicts
().
get
(
i
);
if
(!
isIgnored
(
c
)){
conflicts
.
add
(
c
);
addToTerminalSet
(
crm
,
c
);
addToOrderSet
(
c
);
}
}
int
size
=
conflicts
.
size
();
...
...
@@ -256,26 +261,29 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
}
}
if
(
terminalsAffectConflicts
.
containsKey
(
sourceOfShiftPrec
)){
terminalsAffectConflicts
.
put
(
sourceOfShiftPrec
,
terminalsAffectConflicts
.
get
(
sourceOfShiftPrec
)+
1
);
}
else
{
terminalsAffectConflicts
.
put
(
sourceOfShiftPrec
,
1
);
}
incrementOrSetTo1
(
terminalsAffectConflicts
,
sourceOfShiftPrec
);
// If both precs come from the same terminal, we only need to increment once (every conflict affects itself)
if
(
sourceOfReducePrec
!=
null
&&
!
sourceOfReducePrec
.
equals
(
sourceOfShiftPrec
)){
incrementOrSetTo1
(
terminalsAffectConflicts
,
sourceOfReducePrec
);
}
}
}
private
void
addToOrderSet
(
Conflict
conflict
){
if
(
conflict
instanceof
ReduceReduceConflict
){
ReduceReduceConflict
rrc
=
(
ReduceReduceConflict
)
conflict
;
try
{
//We need this workaround because someone didn't favor composition over inheritance
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
(
sourceOfReducePrec
.
toString
().
equals
(
sourceOfShiftPrec
.
toString
())){
throw
new
IllegalStateException
();
}
if
(
terminalsAffectConflicts
.
containsKey
(
sourceOfReducePrec
)){
terminalsAffectConflicts
.
put
(
sourceOfReducePrec
,
terminalsAffectConflicts
.
get
(
sourceOfReducePrec
)+
1
);
}
else
{
terminalsAffectConflicts
.
put
(
sourceOfReducePrec
,
1
);
}
incrementOrSetTo1
(
ordersAffectConflicts
,
item1
);
incrementOrSetTo1
(
ordersAffectConflicts
,
item2
);
}
catch
(
internal_error
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
}
...
...
@@ -299,6 +307,14 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
this
.
countConflictsLabel
.
setText
(
"Detected "
+
number
+
" conflicts:"
);
}
private
<
X
>
void
incrementOrSetTo1
(
HashMap
<
X
,
Integer
>
table
,
X
key
){
if
(
table
.
containsKey
(
key
)){
table
.
put
(
key
,
table
.
get
(
key
)+
1
);
}
else
{
table
.
put
(
key
,
1
);
}
}
private
void
refreshScrolledLayout
()
{
scrolled
.
layout
(
true
,
true
);
scrolled
.
setMinSize
(
list
.
computeSize
(
SWT
.
DEFAULT
,
SWT
.
DEFAULT
));
...
...
@@ -527,6 +543,22 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
return
affected
!=
1
;
}
}
boolean
settingOrderAffetsOtherConflicts
(
lr_item_core
item1
,
lr_item_core
item2
){
Integer
affected
=
ordersAffectConflicts
.
get
(
item1
);
if
(
affected
!=
null
&&
affected
>
1
){
return
true
;
}
affected
=
ordersAffectConflicts
.
get
(
item2
);
if
(
affected
==
null
){
return
false
;
}
else
{
return
affected
!=
1
;
}
}
private
int
computeIgnoreRRAfter
(){
IDocument
document
=
editor
.
getDocument
();
...
...
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