Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SableCC STUPS
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
SableCC STUPS
Commits
7526f91e
Commit
7526f91e
authored
3 years ago
by
dgelessus
Browse files
Options
Downloads
Patches
Plain Diff
Use generics in remaining parts of Inlining
parent
e3660cb9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/sablecc/sablecc/Inlining.java
+17
-26
17 additions, 26 deletions
src/main/java/org/sablecc/sablecc/Inlining.java
with
17 additions
and
26 deletions
src/main/java/org/sablecc/sablecc/Inlining.java
+
17
−
26
View file @
7526f91e
...
...
@@ -247,7 +247,7 @@ public class Inlining
{
mapOfNewTermNames
=
new
HashMap
<>();
Li
nkedList
listElems
=
inlineList
(
aParsed_alt
.
getElems
(),
Li
st
<
PElem
>
listElems
=
inlineList
(
aParsed_alt
.
getElems
(),
prod_to_inline
.
getAlternative
(
j
).
getElems
(),
mapOfNewTermNames
);
AAltTransform
aAltTransform
=
((
AAltTransform
)
aParsed_alt
.
getAltTransform
()).
clone
();
...
...
@@ -345,22 +345,14 @@ public class Inlining
public
void
caseAListTerm
(
AListTerm
node
)
{
AListTerm
parent
=
(
AListTerm
)
node_
.
parent
();
Li
nkedList
oldlistTerms
=
parent
.
getListTerms
();
Li
nkedList
newlistTerms
=
new
LinkedList
();
Li
st
<
PListTerm
>
oldlistTerms
=
parent
.
getListTerms
();
Li
st
<
PListTerm
>
newlistTerms
=
new
LinkedList
<>
();
Object
[]
oldListTermsArray
=
(
Object
[])
oldlistTerms
.
toArray
();
for
(
int
i
=
0
;
i
<
oldListTermsArray
.
length
;
i
++)
for
(
PListTerm
oldListTerm
:
oldlistTerms
)
{
if
(
oldListTerm
sArray
[
i
]
!=
node_
)
if
(
oldListTerm
!=
node_
)
{
if
(
oldListTermsArray
[
i
]
instanceof
PTerm
)
{
newlistTerms
.
add
(
((
PTerm
)
oldListTermsArray
[
i
]).
clone
()
);
}
else
{
newlistTerms
.
add
(
((
PListTerm
)
oldListTermsArray
[
i
]).
clone
()
);
}
newlistTerms
.
add
(
oldListTerm
.
clone
());
}
else
{
...
...
@@ -404,12 +396,12 @@ public class Inlining
return
resultList
;
}
public
Li
nkedList
inlineList
(
Li
nkedList
oldElemsList
,
public
Li
st
<
PElem
>
inlineList
(
Li
st
<
PElem
>
oldElemsList
,
AElem
[]
inliningProductionsElems
,
Map
<
String
,
String
>
mapOfNewTermNames
)
{
int
position
=
0
;
AElem
[]
listElems
=
(
AElem
[])
oldElemsList
.
toArray
(
new
AElem
[
0
]);
AElem
[]
listElems
=
oldElemsList
.
toArray
(
new
AElem
[
0
]);
for
(
int
i
=
0
;
i
<
listElems
.
length
;
i
++)
{
//We are looking for the position of the element inside the alternative.
...
...
@@ -429,7 +421,7 @@ public class Inlining
}
}
Li
nkedList
list
=
new
LinkedList
();
Li
st
<
PElem
>
list
=
new
LinkedList
<>
();
int
elemPosition
=
1
;
//Before the inlined element (old alternative elements)
...
...
@@ -445,19 +437,18 @@ public class Inlining
}
// After the inlined element (old alternative elements)
for
(
int
i
=
position
+
1
;
i
<
list
Elems
.
length
;
i
++)
for
(
int
i
=
position
+
1
;
i
<
old
Elems
List
.
size
()
;
i
++)
{
list
.
add
(((
AElem
)
oldElemsList
.
get
(
i
)).
clone
());
}
AElem
[]
listOfAltElems
=
(
AElem
[])
list
.
toArray
(
new
AElem
[
0
]);
AElem
[]
listOfAltElems
=
list
.
toArray
(
new
AElem
[
0
]);
for
(
int
i
=
0
;
i
<
listOfAltElems
.
length
;
i
++)
{
String
old_name
=
listOfAltElems
[
i
].
getId
().
getText
();
TId
elemName
=
(
TId
)
listOfAltElems
[
i
].
getElemName
();
TId
elemName
=
listOfAltElems
[
i
].
getElemName
();
if
(
elemName
!=
null
)
{
elemName
=
(
TId
)
elemName
;
old_name
=
elemName
.
getText
();
}
...
...
@@ -496,13 +487,13 @@ public class Inlining
);
}
private
List
cloneList
(
List
list
)
@SuppressWarnings
(
"unchecked"
)
private
<
T
extends
Node
>
List
<
T
>
cloneList
(
List
<
T
>
list
)
{
List
clone
=
new
LinkedList
();
List
<
T
>
clone
=
new
LinkedList
<>
();
for
(
Iterator
i
=
list
.
iterator
();
i
.
hasNext
();)
{
clone
.
add
(((
Node
)
i
.
next
()).
clone
());
for
(
final
T
node
:
list
)
{
clone
.
add
((
T
)
node
.
clone
());
}
return
clone
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment