From 2b8059e58f353575e294a8a1cbfa9ab33f2cdb0f Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Thu, 24 Sep 2015 18:07:47 +0200 Subject: Add prolog.util.parse method --- prolog/util.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'prolog') diff --git a/prolog/util.py b/prolog/util.py index 19312ef..a9fe944 100644 --- a/prolog/util.py +++ b/prolog/util.py @@ -52,6 +52,13 @@ class Token(namedtuple('Token', ['type', 'val', 'pos', 'rule', 'part', 'stop'])) self.stop if stop is None else stop) from .lexer import lexer, operators +from .parser import parser + +def parse(code): + try: + return parser.parse(code) + except: + return None # Return a list of tokens in [text]. def tokenize(text): -- cgit v1.2.1