From 1797178f64c1af8f058f665acd854e895d3dad9e Mon Sep 17 00:00:00 2001 From: Amin Borjian Date: Thu, 6 Feb 2020 11:27:55 +0330 Subject: [PATCH] Fix Bug: Support loop on a node with nullable variables --- pom.xml | 2 +- src/main/java/ir/ac/sbu/parser/LLParserGenerator.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 7c5546f..35b8370 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ir.ac.sbu PGen - 2.1 + 2.1.1 UTF-8 diff --git a/src/main/java/ir/ac/sbu/parser/LLParserGenerator.java b/src/main/java/ir/ac/sbu/parser/LLParserGenerator.java index 2782ef3..04f3ddb 100644 --- a/src/main/java/ir/ac/sbu/parser/LLParserGenerator.java +++ b/src/main/java/ir/ac/sbu/parser/LLParserGenerator.java @@ -394,13 +394,15 @@ private Set calculateFirstSet(Map> firstSets, Set firstSetOfGraph = calculateFirstSet(firstSets, visited, variableGraph.get(edgeModel.getToken()).getStart()); firstOfCurrentNode.addAll(firstSetOfGraph); - if (nullableVariables.contains(edgeModel.getToken())) { + if (nullableVariables.contains(edgeModel.getToken()) && + edgeModel.getEnd().getId() != nodeModel.getId()) { Set firstSetOfRestOfGraph = calculateFirstSet(firstSets, visited, edgeModel.getEnd()); firstOfCurrentNode.addAll(firstSetOfRestOfGraph);