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
bc72a662
Commit
bc72a662
authored
Jul 20, 2023
by
dgelessus
Browse files
Options
Downloads
Patches
Plain Diff
Simplify null handling a bit in alternative code generation
parent
25dc7c45
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/sablecc/sablecc/GenerateAlternativeCodeForParser.java
+3
-18
3 additions, 18 deletions
...org/sablecc/sablecc/GenerateAlternativeCodeForParser.java
src/main/resources/org/sablecc/sablecc/parser.txt
+0
-5
0 additions, 5 deletions
src/main/resources/org/sablecc/sablecc/parser.txt
with
3 additions
and
23 deletions
src/main/java/org/sablecc/sablecc/GenerateAlternativeCodeForParser.java
+
3
−
18
View file @
bc72a662
...
@@ -80,7 +80,7 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter
...
@@ -80,7 +80,7 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter
{
{
if
(
"null"
.
equals
(
typeName
))
if
(
"null"
.
equals
(
typeName
))
{
{
throw
new
IllegalArgumentException
(
"Null values have no variable name"
)
;
return
"null"
;
}
}
else
if
(
typeName
.
startsWith
(
"L"
))
else
if
(
typeName
.
startsWith
(
"L"
))
{
{
...
@@ -156,16 +156,8 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter
...
@@ -156,16 +156,8 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter
position
=
CG
.
getTermNumbers
().
get
(
term
);
position
=
CG
.
getTermNumbers
().
get
(
term
);
if
(
"null"
.
equals
(
type_name
))
{
macros
.
apply
(
file
,
"ParserNewBodyListAddNull"
,
null
);
}
else
{
macros
.
apply
(
file
,
"ParserNewBodyListAdd"
,
new
String
[]
{
getVariableName
(
type_name
,
position
)});
macros
.
apply
(
file
,
"ParserNewBodyListAdd"
,
new
String
[]
{
getVariableName
(
type_name
,
position
)});
}
}
}
if
(
popCount
>
0
)
{
if
(
popCount
>
0
)
{
// The nodeArrayList variables are numbered starting at 1, so the first popped variable has the number popCount and not popCount-1.
// The nodeArrayList variables are numbered starting at 1, so the first popped variable has the number popCount and not popCount-1.
macros
.
apply
(
file
,
"ParserNewCheck"
,
new
String
[]
{
String
.
valueOf
(
popCount
)});
macros
.
apply
(
file
,
"ParserNewCheck"
,
new
String
[]
{
String
.
valueOf
(
popCount
)});
...
@@ -344,14 +336,7 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter
...
@@ -344,14 +336,7 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter
type_name
=
lookupInternalTypeName
(
term
);
type_name
=
lookupInternalTypeName
(
term
);
position
=
CG
.
getTermNumbers
().
get
(
term
);
position
=
CG
.
getTermNumbers
().
get
(
term
);
if
(
type_name
.
equals
(
"null"
))
{
macros
.
apply
(
file
,
"ParserNewBodyParam"
,
new
String
[]
{
isNotTheFirstParam
+
"null"
});
}
else
{
macros
.
apply
(
file
,
"ParserNewBodyParam"
,
new
String
[]
{
isNotTheFirstParam
+
getVariableName
(
type_name
,
position
)});
macros
.
apply
(
file
,
"ParserNewBodyParam"
,
new
String
[]
{
isNotTheFirstParam
+
getVariableName
(
type_name
,
position
)});
}
isNotTheFirstParam
=
", "
;
isNotTheFirstParam
=
", "
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/org/sablecc/sablecc/parser.txt
+
0
−
5
View file @
bc72a662
...
@@ -386,11 +386,6 @@ Macro:ParserNewBodyListAdd
...
@@ -386,11 +386,6 @@ Macro:ParserNewBodyListAdd
$
$
Macro:ParserNewBodyListAddNull
nodeList.add(null);
$
Macro:ParserNewCheck
Macro:ParserNewCheck
checkResult(nodeList.get(0), nodeArrayList1, nodeArrayList$0$);
checkResult(nodeList.get(0), nodeArrayList1, nodeArrayList$0$);
...
...
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