diff options
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): |