diff options
author | Timotej Lazar <timotej.lazar@araneo.org> | 2015-09-24 18:07:47 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2015-12-10 14:10:04 +0100 |
commit | 2b8059e58f353575e294a8a1cbfa9ab33f2cdb0f (patch) | |
tree | 41d0cdc18dff2e8235fae580e52ac9ec7d919f3d /prolog | |
parent | 1f8fa5268bdcccac22b86b4b1d8e95b3397c14a7 (diff) |
Add prolog.util.parse method
Diffstat (limited to 'prolog')
-rw-r--r-- | prolog/util.py | 7 |
1 files changed, 7 insertions, 0 deletions
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): |