summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-10-23 15:21:50 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-12-10 14:10:04 +0100
commit61c5b7db71667c7801ef2be2c82aaad888ec8e78 (patch)
tree0eebec826f1cae15f329cacebf5443ad85b42140
parent2b8059e58f353575e294a8a1cbfa9ab33f2cdb0f (diff)
Fix a parser bug
-rw-r--r--prolog/parser.py6
-rw-r--r--prolog/util.py2
2 files changed, 4 insertions, 4 deletions
diff --git a/prolog/parser.py b/prolog/parser.py
index 5b5c325..c9f4d86 100644
--- a/prolog/parser.py
+++ b/prolog/parser.py
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from nltk import ParentedTree as Tree
+from nltk import Tree
import ply.yacc as yacc
from .lexer import operators, tokens
from .util import Token
@@ -165,10 +165,10 @@ def p_list_empty(p):
p[0] = Tree('list', [make_token(p, 1), make_token(p, 2)])
def p_list(p):
'list : LBRACKET args RBRACKET'
- p[0] = Tree('list', [make_token(p, 1)] + p[2] + [make_token(p, 3)])
+ p[0] = Tree('list', [make_token(p, 1)] + list(p[2]) + [make_token(p, 3)])
def p_list_tail(p):
'list : LBRACKET args PIPE term RBRACKET'
- p[0] = Tree('list', [make_token(p, 1)] + p[2] + [make_token(p, 3), p[4], make_token(p, 5)])
+ p[0] = Tree('list', [make_token(p, 1)] + list(p[2]) + [make_token(p, 3), p[4], make_token(p, 5)])
def p_functor(p):
'functor : NAME'
diff --git a/prolog/util.py b/prolog/util.py
index a9fe944..ba48732 100644
--- a/prolog/util.py
+++ b/prolog/util.py
@@ -57,7 +57,7 @@ from .parser import parser
def parse(code):
try:
return parser.parse(code)
- except:
+ except SyntaxError:
return None
# Return a list of tokens in [text].