Skip to content

Commit

Permalink
Wrap lists with constructor if a constructor is defined in production…
Browse files Browse the repository at this point in the history
… in JSGLR2 imploding
  • Loading branch information
jasperdenkers committed Jun 18, 2018
1 parent d62e39f commit be4d632
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -154,9 +154,14 @@ protected Tree createContextFreeTerm(IProduction production, List<Tree> childAST
IToken rightToken) { IToken rightToken) {
String constructor = production.constructor(); String constructor = production.constructor();


if(production.isList()) if(production.isList()) {
return treeFactory.createList(production.sort(), childASTs, leftToken, rightToken); Tree list = treeFactory.createList(production.sort(), childASTs, leftToken, rightToken);
else if(production.isOptional())
if(constructor == null)
return list;
else
return treeFactory.createNonTerminal(production.sort(), constructor, Arrays.asList(list), leftToken, rightToken);
} else if(production.isOptional())
return treeFactory.createOptional(production.sort(), childASTs, leftToken, rightToken); return treeFactory.createOptional(production.sort(), childASTs, leftToken, rightToken);
else if(constructor != null) else if(constructor != null)
return treeFactory.createNonTerminal(production.sort(), constructor, childASTs, leftToken, rightToken); return treeFactory.createNonTerminal(production.sort(), constructor, childASTs, leftToken, rightToken);
Expand Down

0 comments on commit be4d632

Please sign in to comment.