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
d7d181a4
Commit
d7d181a4
authored
Nov 28, 2014
by
Sebastian Pretscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a first draft of the ActionTableView
parent
ef5fa565
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
264 additions
and
16 deletions
+264
-16
CupPlugin/META-INF/MANIFEST.MF
CupPlugin/META-INF/MANIFEST.MF
+2
-1
CupPlugin/src/de/tum/in/www2/cupplugin/controller/Controller.java
...n/src/de/tum/in/www2/cupplugin/controller/Controller.java
+1
-0
CupPlugin/src/de/tum/in/www2/cupplugin/controller/DocumentDidChangeJob.java
...um/in/www2/cupplugin/controller/DocumentDidChangeJob.java
+15
-9
CupPlugin/src/de/tum/in/www2/cupplugin/editors/MultiPageEditor.java
...src/de/tum/in/www2/cupplugin/editors/MultiPageEditor.java
+1
-1
CupPlugin/src/de/tum/in/www2/cupplugin/views/CupActionTableView.java
...rc/de/tum/in/www2/cupplugin/views/CupActionTableView.java
+226
-3
CupPlugin/src/de/tum/in/www2/cupplugin/views/CupConflictGraphView.java
.../de/tum/in/www2/cupplugin/views/CupConflictGraphView.java
+18
-1
CupPlugin/src/de/tum/in/www2/cupplugin/views/CupReduceGraphView.java
...rc/de/tum/in/www2/cupplugin/views/CupReduceGraphView.java
+1
-1
No files found.
CupPlugin/META-INF/MANIFEST.MF
View file @
d7d181a4
...
...
@@ -23,7 +23,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.jdt.core;bundle-version="3.10.0",
org.eclipse.jdt.ui;bundle-version="3.10.1",
org.eclipse.ant.core;bundle-version="3.3.0",
org.eclipse.text
org.eclipse.text,
org.eclipse.jface
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
CupPlugin/src/de/tum/in/www2/cupplugin/controller/Controller.java
View file @
d7d181a4
...
...
@@ -287,6 +287,7 @@ public class Controller {
.
getLaLrRevisionNumber
();
if
(
modelLaLrRev
!=
RevisionManager
.
get
(
document
))
{
addJobToDo
(
job
);
addJobToDo
(
JobsToDo
.
parseCode
);
}
break
;
default
:
...
...
CupPlugin/src/de/tum/in/www2/cupplugin/controller/DocumentDidChangeJob.java
View file @
d7d181a4
...
...
@@ -106,11 +106,11 @@ public class DocumentDidChangeJob extends Job {
return
Status
.
CANCEL_STATUS
;
IFile
file
=
((
FileEditorInput
)
myEditor
.
getEditorInput
()).
getFile
();
CupEditorErrorReporter
errorReporter
=
new
CupEditorErrorReporter
(
file
);
CupEditorErrorReporter
errorReporter
=
new
CupEditorErrorReporter
(
file
);
errorReporter
.
resetOnNextPush
();
CupParser
parser
=
null
;
if
(
jobs
.
contains
(
JobsToDo
.
parseCode
))
{
InputStream
in
=
new
ByteArrayInputStream
(
codeText
.
getBytes
());
...
...
@@ -121,7 +121,7 @@ public class DocumentDidChangeJob extends Job {
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
}
context
=
parser
.
getContext
();
errorReporter
.
pushToUIThread
();
...
...
@@ -145,11 +145,17 @@ public class DocumentDidChangeJob extends Job {
lalrResult
=
null
;
try
{
if
(
parser
!=
null
&&
!
parser
.
hasParseErrors
())
{
lalrResult
=
LALRResult
.
Compute
(
context
,
context
.
start_production
);
lalrResult
=
LALRResult
.
Compute
(
context
,
context
.
start_production
);
}
else
{
System
.
out
.
println
(
"LALRResult.Compute was not called, "
+
"because the parser has reported errors."
);
System
.
out
.
println
(
"LALRResult.Compute was not called, "
+
"because the parser has reported errors."
);
if
(
parser
==
null
)
{
System
.
out
.
println
(
"Null parser"
);
}
else
{
System
.
out
.
println
(
"Parser has Errors: "
+
parser
.
hasParseErrors
());
}
}
}
catch
(
internal_error
e
)
{
...
...
@@ -171,7 +177,7 @@ public class DocumentDidChangeJob extends Job {
return
Status
.
CANCEL_STATUS
;
}
}
errorReporter
.
pushToUIThread
();
System
.
out
.
println
(
jobs
);
...
...
CupPlugin/src/de/tum/in/www2/cupplugin/editors/MultiPageEditor.java
View file @
d7d181a4
...
...
@@ -112,7 +112,7 @@ public class MultiPageEditor extends MultiPageEditorPart implements
Composite
composite
=
new
Composite
(
getContainer
(),
SWT
.
NONE
);
IDocument
doc
=
editor
.
getDocumentProvider
().
getDocument
(
editor
.
getEditorInput
());
actionTableView
=
new
CupActionTableView
(
composite
,
doc
);
actionTableView
=
new
CupActionTableView
(
composite
,
editor
);
addPage
(
ACTION_TABLE_PAGE_INDEX
,
composite
);
setPageText
(
ACTION_TABLE_PAGE_INDEX
,
"Action Table"
);
}
...
...
CupPlugin/src/de/tum/in/www2/cupplugin/views/CupActionTableView.java
View file @
d7d181a4
package
de.tum.in.www2.cupplugin.views
;
import
java.util.EnumSet
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.eclipse.jface.text.IDocument
;
import
org.eclipse.jface.viewers.ITreeContentProvider
;
import
org.eclipse.jface.viewers.StyledCellLabelProvider
;
import
org.eclipse.jface.viewers.TableViewer
;
import
org.eclipse.jface.viewers.TreeViewer
;
import
org.eclipse.jface.viewers.Viewer
;
import
org.eclipse.jface.viewers.ViewerCell
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.events.SelectionAdapter
;
import
org.eclipse.swt.events.SelectionEvent
;
import
org.eclipse.swt.layout.FillLayout
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Table
;
import
org.eclipse.swt.widgets.Tree
;
import
org.eclipse.swt.widgets.TreeItem
;
import
de.in.tum.www2.cup.CupContext
;
import
de.in.tum.www2.cup.LALRResult
;
import
de.in.tum.www2.cup.internal.lalr_state
;
import
de.in.tum.www2.cup.internal.parse_action
;
import
de.in.tum.www2.cup.internal.parse_action_row
;
import
de.in.tum.www2.cup.internal.parse_action_table
;
import
de.tum.in.www2.cupplugin.controller.Controller
;
import
de.tum.in.www2.cupplugin.controller.Controller.JobsToDo
;
import
de.tum.in.www2.cupplugin.controller.IRegisterForControllerChanges
;
import
de.tum.in.www2.cupplugin.editors.CupTextEditor
;
import
de.tum.in.www2.cupplugin.editors.ICupEditorPageVisibility
;
import
de.tum.in.www2.cupplugin.model.ICupParserLaLrChangeObserver
;
import
de.tum.in.www2.cupplugin.model.Model
;
public
class
CupActionTableView
implements
ICupEditorPageVisibility
,
ICupParserLaLrChangeObserver
,
IRegisterForControllerChanges
{
private
CupTextEditor
editor
;
private
IDocument
doc
;
private
TreeViewer
treeViewer
;
private
boolean
isVisible
=
false
;
private
List
<
ActionNode
>
stateList
;
public
CupActionTableView
(
Composite
parent
,
CupTextEditor
editor
)
{
this
.
editor
=
editor
;
this
.
doc
=
editor
.
getDocumentProvider
().
getDocument
(
editor
.
getEditorInput
());
this
.
stateList
=
new
LinkedList
<
ActionNode
>();
Controller
.
getInstance
(
editor
).
registerObserver
(
this
);
Model
.
getInstanceForDocument
(
doc
).
registerModelObserver
(
this
);
public
class
CupActionTableView
{
parent
.
setLayout
(
new
FillLayout
());
public
CupActionTableView
(
Composite
parent
,
IDocument
doc
)
{
this
.
treeViewer
=
new
TreeViewer
(
parent
,
SWT
.
H_SCROLL
|
SWT
.
BORDER
);
treeViewer
.
setContentProvider
(
new
ActionNodeContentProvider
());
treeViewer
.
setLabelProvider
(
new
ActionNodeLabelProvider
());
// the viewer field is an already configured TreeViewer
Tree
tree
=
(
Tree
)
treeViewer
.
getControl
();
tree
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
TreeItem
item
=
(
TreeItem
)
e
.
item
;
if
(
item
.
getItemCount
()
>
0
)
{
item
.
setExpanded
(!
item
.
getExpanded
());
// update the viewer
treeViewer
.
refresh
();
}
}
});
treeViewer
.
setInput
(
stateList
);
}
@Override
public
void
willBecomeVisible
()
{
System
.
out
.
println
(
"CupActionTableView will become visible."
);
isVisible
=
true
;
if
(!
Controller
.
getInstance
(
editor
).
requestJobRun
())
{
ModelChange
(
Model
.
getInstanceForDocument
(
doc
));
}
}
@Override
public
void
becameHidden
()
{
System
.
out
.
println
(
"CupActionTableView became hidden."
);
isVisible
=
false
;
}
@Override
public
EnumSet
<
JobsToDo
>
getRequiredJobs
()
{
EnumSet
<
JobsToDo
>
requestedJobs
=
EnumSet
.
noneOf
(
JobsToDo
.
class
);
if
(
isVisible
)
{
requestedJobs
=
EnumSet
.
of
(
JobsToDo
.
buildTable
);
}
return
requestedJobs
;
}
@Override
public
void
ModelChange
(
Model
model
)
{
if
(!
isVisible
)
{
return
;
}
stateList
.
clear
();
LALRResult
lalrResult
=
model
.
getLaLrResult
();
System
.
out
.
println
(
lalrResult
.
getActionTable
().
toString
());
parse_action_table
table
=
lalrResult
.
getActionTable
();
CupContext
context
=
model
.
getLaLrContext
();
for
(
int
row
=
0
;
row
<
table
.
num_states
();
row
++)
{
ActionNode
n
=
new
ActionNode
(
row
,
"State "
+
row
);
stateList
.
add
(
n
);
for
(
int
col
=
0
;
col
<
parse_action_row
.
size
(
context
);
col
++)
{
n
.
getChildren
().
add
(
new
ActionNodeChild
(
n
,
(
table
.
under_state
[
row
].
under_term
[
col
]).
toString
()));
}
}
treeViewer
.
refresh
();
}
static
class
ActionNode
{
private
final
int
index
;
private
final
String
name
;
private
final
List
<
ActionNodeChild
>
children
;
public
ActionNode
(
int
index
,
String
name
)
{
this
.
index
=
index
;
this
.
name
=
name
;
this
.
children
=
new
LinkedList
<
ActionNodeChild
>();
}
public
int
getIndex
()
{
return
index
;
}
public
String
getName
()
{
return
name
;
}
public
List
<
ActionNodeChild
>
getChildren
()
{
return
children
;
}
}
static
class
ActionNodeChild
{
private
final
ActionNode
parent
;
private
final
String
name
;
public
ActionNodeChild
(
ActionNode
parent
,
String
name
)
{
this
.
parent
=
parent
;
this
.
name
=
name
;
}
public
ActionNode
getParent
()
{
return
parent
;
}
public
String
getName
()
{
return
name
;
}
}
class
ActionNodeContentProvider
implements
ITreeContentProvider
{
@Override
public
void
dispose
()
{
// TODO Auto-generated method stub
}
@Override
public
void
inputChanged
(
Viewer
viewer
,
Object
oldInput
,
Object
newInput
)
{
// TODO Auto-generated method stub
}
@Override
public
Object
[]
getElements
(
Object
inputElement
)
{
if
(
inputElement
instanceof
ActionNode
)
{
return
new
ActionNode
[]
{
(
ActionNode
)
inputElement
};
}
else
if
(
inputElement
instanceof
ActionNode
[])
{
return
(
ActionNode
[])
inputElement
;
}
else
if
(
inputElement
instanceof
List
)
{
return
((
List
)
inputElement
).
toArray
();
}
return
new
Object
[
0
];
}
@Override
public
Object
[]
getChildren
(
Object
parentElement
)
{
if
(
parentElement
instanceof
ActionNode
)
{
ActionNode
n
=
(
ActionNode
)
parentElement
;
return
n
.
getChildren
().
toArray
();
}
return
null
;
}
@Override
public
Object
getParent
(
Object
element
)
{
if
(
element
instanceof
ActionNodeChild
)
{
ActionNodeChild
c
=
(
ActionNodeChild
)
element
;
return
c
.
getParent
();
}
return
null
;
}
@Override
public
boolean
hasChildren
(
Object
element
)
{
if
(
element
instanceof
ActionNode
)
{
ActionNode
n
=
(
ActionNode
)
element
;
return
!
n
.
getChildren
().
isEmpty
();
}
return
false
;
}
}
class
ActionNodeLabelProvider
extends
StyledCellLabelProvider
{
@Override
public
void
update
(
ViewerCell
cell
)
{
Object
element
=
cell
.
getElement
();
if
(
element
instanceof
ActionNode
)
{
ActionNode
n
=
(
ActionNode
)
element
;
cell
.
setText
(
n
.
getName
());
}
if
(
element
instanceof
ActionNodeChild
)
{
ActionNodeChild
c
=
(
ActionNodeChild
)
element
;
cell
.
setText
(
c
.
getName
());
}
}
public
void
setFocus
()
{
treeViewer
.
getControl
().
setFocus
();
}
}
}
CupPlugin/src/de/tum/in/www2/cupplugin/views/CupConflictGraphView.java
View file @
d7d181a4
...
...
@@ -468,6 +468,7 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
private
final
String
name
;
private
List
<
ParserConflictNode
>
connections
;
private
String
description
;
private
boolean
isNonTerm
=
false
;
public
ParserConflictNode
(
int
id
,
String
name
)
{
this
.
id
=
id
;
...
...
@@ -495,6 +496,14 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
boolean
getIsNonTerm
()
{
return
isNonTerm
;
}
public
void
setIsNonTerm
(
boolean
isNonTerm
)
{
this
.
isNonTerm
=
isNonTerm
;
}
}
static
class
ParserConflictConnection
{
...
...
@@ -573,6 +582,7 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
ParserConflictNode
n
=
new
ParserConflictNode
(
dfsNode
.
getState
().
index
(),
"State "
+
dfsNode
.
getState
().
index
());
n
.
setIsNonTerm
(
dfsNode
.
getPredTransition
().
on_symbol
().
is_non_term
());
nodes
.
add
(
n
);
ParserConflictConnection
con
=
new
ParserConflictConnection
(
""
+
counter
,
dfsNode
.
getPredTransition
().
on_symbol
()
...
...
@@ -704,6 +714,13 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
@Override
public
Color
getColor
(
Object
src
,
Object
dest
)
{
if
(
dest
instanceof
ParserConflictNode
)
{
ParserConflictNode
n
=
(
ParserConflictNode
)
dest
;
if
(
n
.
isNonTerm
)
{
Device
device
=
Display
.
getCurrent
();
return
device
.
getSystemColor
(
SWT
.
COLOR_DARK_MAGENTA
);
}
}
return
null
;
}
...
...
@@ -722,7 +739,7 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
public
EnumSet
<
JobsToDo
>
getRequiredJobs
()
{
EnumSet
<
JobsToDo
>
requestedJobs
=
EnumSet
.
noneOf
(
JobsToDo
.
class
);
if
(
isVisible
)
{
requestedJobs
=
EnumSet
.
of
(
JobsToDo
.
buildTable
,
JobsToDo
.
parseCode
);
requestedJobs
=
EnumSet
.
of
(
JobsToDo
.
buildTable
);
}
return
requestedJobs
;
}
...
...
CupPlugin/src/de/tum/in/www2/cupplugin/views/CupReduceGraphView.java
View file @
d7d181a4
...
...
@@ -870,7 +870,7 @@ public class CupReduceGraphView implements ICupParserLaLrChangeObserver,
public
EnumSet
<
JobsToDo
>
getRequiredJobs
()
{
EnumSet
<
JobsToDo
>
requestedJobs
=
EnumSet
.
noneOf
(
JobsToDo
.
class
);
if
(
isVisible
)
{
requestedJobs
=
EnumSet
.
of
(
JobsToDo
.
buildTable
,
JobsToDo
.
parseCode
);
requestedJobs
=
EnumSet
.
of
(
JobsToDo
.
buildTable
);
}
return
requestedJobs
;
}
...
...
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