diff options
-rw-r--r-- | prolog/parser.py | 6 | ||||
-rw-r--r-- | prolog/util.py | 2 |
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]. |