Skip to content
Snippets Groups Projects
Commit bf585c72 authored by dgelessus's avatar dgelessus
Browse files

Remove generation of block braces in Parser new methods

The variables' numbers are unique within each alternative, so there's no
need to explicitly limit the scope of the variables.
parent ba0fb101
Branches
Tags
No related merge requests found
Pipeline #117723 passed
......@@ -125,22 +125,16 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter
}
}
private boolean generateVariableDeclaration(Node term, boolean generateOpeningBraceIfNeeded) throws IOException {
private void generateVariableDeclaration(Node term) throws IOException {
String typeName = lookupInternalTypeName(term);
if("null".equals(typeName) || "Lnull".equals(typeName))
{
// No intermediate variable needed for null or empty list arguments
return false;
}
if(generateOpeningBraceIfNeeded)
{
macros.apply(file, "ParserBraceOpening");
return;
}
macros.apply(file, "ParserVariableDeclaration", new String[] {variableTypeFromInternalType(typeName), getVariableName(term)});
return true;
}
@Override
......@@ -150,7 +144,7 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter
{
try
{
generateVariableDeclaration(term, false);
generateVariableDeclaration(term);
}
catch(IOException e)
{
......@@ -261,10 +255,9 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter
try
{
boolean openingBraceGenerated = false;
for(PListTerm listTerm : node.getListTerms())
{
openingBraceGenerated |= generateVariableDeclaration(listTerm, !openingBraceGenerated);
generateVariableDeclaration(listTerm);
listTerm.apply(this);
}
......@@ -339,11 +332,6 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter
first = false;
}
}
if(openingBraceGenerated)
{
macros.apply(file, "ParserBraceClosing");
}
}
catch(IOException e)
{
......@@ -358,10 +346,9 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter
try
{
boolean openingBraceGenerated = false;
for(PTerm term : params)
{
openingBraceGenerated |= generateVariableDeclaration(term, !openingBraceGenerated);
generateVariableDeclaration(term);
}
for(PTerm param : params)
......@@ -383,10 +370,6 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter
}
}
macros.apply(file, "ParserNewBodyNewTail");
if(openingBraceGenerated)
{
macros.apply(file, "ParserBraceClosing");
}
}
catch(IOException e)
{
......
This diff is collapsed.
......@@ -331,16 +331,6 @@ Macro:ParserNewBodyDeclNull
$
Macro:ParserBraceOpening
{
$
Macro:ParserBraceClosing
}
$
Macro:ParserVariableDeclaration
$0$ $1$;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment