diff --git a/README.md b/README.md index 18c181f..23ec565 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Most importantly, Lark will save you time and prevent you from getting parsing h ### Install Lark - $ pip install lark-parser + $ pip install lark-parser --upgrade Lark has no dependencies. @@ -77,12 +77,11 @@ Notice punctuation doesn't appear in the resulting tree. It's automatically filt ### Fruit flies like bananas -Lark is great at handling ambiguity. Let's parse the phrase "fruit flies like bananas": +Lark is great at handling ambiguity. Here is the result of parsing the phrase "fruit flies like bananas": ![fruitflies.png](examples/fruitflies.png) -See more [examples here](https://github.com/lark-parser/lark/tree/master/examples) - +See the code and more [examples here](https://github.com/lark-parser/lark/tree/master/examples) ## List of main features diff --git a/docs/features.md b/docs/features.md index 9346989..c2f6983 100644 --- a/docs/features.md +++ b/docs/features.md @@ -19,8 +19,8 @@ [Read more about the parsers](parsers.md) # Extra features - - Import rules and tokens from other Lark grammars, for code reuse and modularity. + - Support for external regex module ([see here](/docs/classes.md#using-unicode-character-classes-with-regex)) - Import grammars from Nearley.js ([read more](/docs/nearley.md)) - CYK parser diff --git a/lark/exceptions.py b/lark/exceptions.py index 645b09c..a844dd4 100644 --- a/lark/exceptions.py +++ b/lark/exceptions.py @@ -72,7 +72,11 @@ class UnexpectedInput(LarkError): class UnexpectedCharacters(LexError, UnexpectedInput): def __init__(self, seq, lex_pos, line, column, allowed=None, considered_tokens=None, state=None, token_history=None): - message = "No terminal defined for '%s' at line %d col %d" % (seq[lex_pos], line, column) + + if isinstance(seq, bytes): + message = "No terminal defined for '%s' at line %d col %d" % (seq[lex_pos:lex_pos+1].decode("ascii", "backslashreplace"), line, column) + else: + message = "No terminal defined for '%s' at line %d col %d" % (seq[lex_pos], line, column) self.line = line self.column = column