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
88c32f6f
Commit
88c32f6f
authored
Feb 22, 2016
by
Michael Schwarz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
function to move production to the very end and insert threshold if
required
parent
dd218ed2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
CupPlugin/src/de/tum/in/www2/cupplugin/views/ConflictPanel.java
...gin/src/de/tum/in/www2/cupplugin/views/ConflictPanel.java
+4
-0
CupPlugin/src/de/tum/in/www2/cupplugin/views/CupConflictsView.java
.../src/de/tum/in/www2/cupplugin/views/CupConflictsView.java
+40
-0
No files found.
CupPlugin/src/de/tum/in/www2/cupplugin/views/ConflictPanel.java
View file @
88c32f6f
...
...
@@ -565,6 +565,10 @@ class ConflictPanel extends Composite {
public
void
widgetSelected
(
SelectionEvent
e
){
if
(!(
conflict
instanceof
ShiftReduceConflict
))
{
//DEBUG
cupConflictsView
.
moveItemToVeryEnd
(((
ReduceReduceConflict
)
conflict
).
getConflictItem1
());
return
;
}
if
(
resolutionOptions
.
getSelectionIndex
()
==
0
){
...
...
CupPlugin/src/de/tum/in/www2/cupplugin/views/CupConflictsView.java
View file @
88c32f6f
...
...
@@ -33,14 +33,17 @@ import de.in.tum.www2.cup.LALRResult;
import
de.in.tum.www2.cup.Position
;
import
de.in.tum.www2.cup.ReduceReduceConflict
;
import
de.in.tum.www2.cup.ShiftReduceConflict
;
import
de.in.tum.www2.cup.ast.AbstractNode
;
import
de.in.tum.www2.cup.ast.IProductionRightPart
;
import
de.in.tum.www2.cup.ast.ParserResult
;
import
de.in.tum.www2.cup.ast.Precedence
;
import
de.in.tum.www2.cup.ast.Production
;
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.lalr_item
;
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
;
...
...
@@ -587,4 +590,41 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
return
false
;
}
}
public
void
moveItemToVeryEnd
(
lalr_item
item
){
Production
p
=(
Production
)
item
.
the_production
().
getAstNode
().
getParent
();
IDocument
document
=
editor
.
getDocument
();
if
(
p
.
getRightHandSides
().
size
()
==
1
){
// Base case
try
{
String
pString
=
document
.
get
(
p
.
getBegin
().
getOffsetFromStart
(),
p
.
getEnd
().
getOffsetFromStart
()
-
p
.
getBegin
().
getOffsetFromStart
());
ParserResult
r
=
Model
.
getInstanceForDocument
(
document
).
getAstModel
();
int
positionForProd
=
0
;
// Grammar can be assumed to have at least two productions -> safe
positionForProd
=
r
.
productions
.
get
(
r
.
productions
.
size
()-
1
).
getEnd
().
getOffsetFromStart
();
String
toInsert
=
"\n\n//Moved by CUP Eclipse plugin\n"
+
pString
;
if
(
ignoreRRAfterLine
==
-
1
){
toInsert
=
"\n\n// "
+
TRESHOLD_STRING
+
"\n // After this the order of productions matters"
+
toInsert
;
}
document
.
replace
(
positionForProd
,
0
,
toInsert
);
// We have a guarantee that we are moving stuff backwards, so this works
document
.
replace
(
p
.
getBegin
().
getOffsetFromStart
(),
p
.
getEnd
().
getOffsetFromStart
()
-
p
.
getBegin
().
getOffsetFromStart
(),
""
);
return
;
}
catch
(
BadLocationException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
return
;
}
}
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