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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
SableCC STUPS
Commits
6d35f86f
Commit
6d35f86f
authored
Apr 25, 2022
by
dgelessus
Browse files
Options
Downloads
Patches
Plain Diff
Use generics in GenParser
parent
1d70a9ca
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/GenParser.java
+21
-32
21 additions, 32 deletions
src/main/java/org/sablecc/sablecc/GenParser.java
with
21 additions
and
32 deletions
src/main/java/org/sablecc/sablecc/GenParser.java
+
21
−
32
View file @
6d35f86f
...
...
@@ -289,10 +289,9 @@ public class GenParser extends DepthFirstAdapter
ids
.
names
.
put
(
node
,
name
);
//list of inAAlt code.
Object
[]
list_alt
=
(
Object
[])
node
.
getAlts
().
toArray
();
for
(
int
i
=
0
;
i
<
list_alt
.
length
;
i
++)
for
(
PAlt
alt
:
node
.
getAlts
())
{
((
PAlt
)
list_alt
[
i
])
.
apply
(
this
);
alt
.
apply
(
this
);
}
}
...
...
@@ -329,10 +328,9 @@ public class GenParser extends DepthFirstAdapter
ids
.
names
.
put
(
alt
,
currentAlt
);
}
AElem
list_elem
[]
=
(
AElem
[])
alt
.
getElems
().
toArray
(
new
AElem
[
0
]);
for
(
int
i
=
0
;
i
<
list_elem
.
length
;
i
++)
for
(
PElem
elem
:
alt
.
getElems
())
{
list_
elem
[
i
]
.
apply
(
this
);
elem
.
apply
(
this
);
}
}
...
...
@@ -428,7 +426,7 @@ public class GenParser extends DepthFirstAdapter
final
Node
node
=
alts
.
get
(
productions
[
i
].
name
);
final
BufferedWriter
finalFile
=
file
;
final
LinkedList
stack
=
new
LinkedList
();
final
Deque
<
Element
>
stack
=
new
LinkedList
<>
();
node
.
apply
(
new
DepthFirstAdapter
()
{
...
...
@@ -447,9 +445,8 @@ public class GenParser extends DepthFirstAdapter
try
{
for
(
Iterator
it
=
stack
.
iterator
();
it
.
hasNext
();
)
for
(
Element
e
:
stack
)
{
Element
e
=
(
Element
)
it
.
next
();
macros
.
apply
(
file
,
e
.
macro
,
e
.
arguments
);
}
}
...
...
@@ -479,11 +476,11 @@ public class GenParser extends DepthFirstAdapter
new
FileOutputStream
(
new
File
(
pkgDir
,
"parser.dat"
))));
Vector
outerArray
=
new
Vector
();
Vector
<
Vector
<
int
[]>>
outerArray
=
new
Vector
<>
();
//Generating of paring tables
for
(
int
i
=
0
;
i
<
Grammar
.
action_
.
length
;
i
++)
{
Vector
innerArray
=
new
Vector
();
Vector
<
int
[]>
innerArray
=
new
Vector
<>
();
String
mostFrequentAction
=
"ERROR"
;
int
mostFrequentDestination
=
i
;
...
...
@@ -551,14 +548,11 @@ public class GenParser extends DepthFirstAdapter
file
.
write
(
""
+
table
);
out
.
writeInt
(
outerArray
.
size
());
for
(
Enumeration
e
=
outerArray
.
elements
();
e
.
hasMoreElements
();
)
for
(
Vector
<
int
[]>
innerArray
:
outerArray
)
{
Vector
innerArray
=
(
Vector
)
e
.
nextElement
();
out
.
writeInt
(
innerArray
.
size
());
for
(
Enumeration
n
=
innerArray
.
elements
();
n
.
hasMoreElements
();
)
for
(
int
[]
array
:
innerArray
)
{
int
[]
array
=
(
int
[])
n
.
nextElement
();
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
out
.
writeInt
(
array
[
i
]);
...
...
@@ -571,11 +565,11 @@ public class GenParser extends DepthFirstAdapter
macros
.
apply
(
file
,
"ParserGotoHeader"
);
table
=
new
StringBuffer
();
outerArray
=
new
Vector
();
outerArray
=
new
Vector
<>
();
for
(
int
j
=
0
;
j
<
nonterminals
.
length
-
1
;
j
++)
{
Vector
innerArray
=
new
Vector
();
Vector
<
int
[]>
innerArray
=
new
Vector
<>
();
int
mostFrequent
=
-
1
;
int
frequence
=
0
;
...
...
@@ -620,14 +614,11 @@ public class GenParser extends DepthFirstAdapter
file
.
write
(
""
+
table
);
out
.
writeInt
(
outerArray
.
size
());
for
(
Enumeration
e
=
outerArray
.
elements
();
e
.
hasMoreElements
();
)
for
(
Vector
<
int
[]>
innerArray
:
outerArray
)
{
Vector
innerArray
=
(
Vector
)
e
.
nextElement
();
out
.
writeInt
(
innerArray
.
size
());
for
(
Enumeration
n
=
innerArray
.
elements
();
n
.
hasMoreElements
();
)
for
(
int
[]
array
:
innerArray
)
{
int
[]
array
=
(
int
[])
n
.
nextElement
();
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
out
.
writeInt
(
array
[
i
]);
...
...
@@ -645,8 +636,8 @@ public class GenParser extends DepthFirstAdapter
Map
<
String
,
Integer
>
errorIndex
=
new
TreeMap
<>();
outerArray
=
new
Vector
();
Vector
indexArray
=
new
Vector
();
Vector
<
String
>
outerArray
2
=
new
Vector
<>
();
Vector
<
Integer
>
indexArray
=
new
Vector
<>
();
index
.
append
(
" "
);
for
(
int
i
=
0
;
i
<
Grammar
.
action_
.
length
;
i
++)
...
...
@@ -680,7 +671,7 @@ public class GenParser extends DepthFirstAdapter
else
{
table
.
append
(
" \""
+
s
+
"\","
+
System
.
getProperty
(
"line.separator"
));
outerArray
.
addElement
(
s
.
toString
());
outerArray
2
.
addElement
(
s
.
toString
());
errorIndex
.
put
(
s
.
toString
(),
nextIndex
);
indexArray
.
addElement
(
nextIndex
);
index
.
append
(
nextIndex
++
+
", "
);
...
...
@@ -689,10 +680,9 @@ public class GenParser extends DepthFirstAdapter
file
.
write
(
""
+
table
);
out
.
writeInt
(
outerArray
.
size
());
for
(
Enumeration
e
=
outerArray
.
elements
();
e
.
hasMoreElements
();
)
out
.
writeInt
(
outerArray
2
.
size
());
for
(
String
s
:
outerArray2
)
{
String
s
=
(
String
)
e
.
nextElement
();
out
.
writeInt
(
s
.
length
());
int
length
=
s
.
length
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
...
...
@@ -702,10 +692,9 @@ public class GenParser extends DepthFirstAdapter
}
out
.
writeInt
(
indexArray
.
size
());
for
(
Enumeration
e
=
indexArray
.
elements
();
e
.
hasMoreElements
();
)
for
(
int
n
:
indexArray
)
{
Integer
n
=
(
Integer
)
e
.
nextElement
();
out
.
writeInt
(
n
.
intValue
());
out
.
writeInt
(
n
);
}
out
.
close
();
...
...
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