diff --git a/docs/grammar.md b/docs/grammar.md index 1cd72dd..8ed0c58 100644 --- a/docs/grammar.md +++ b/docs/grammar.md @@ -268,7 +268,7 @@ If the module path is absolute, Lark will attempt to load it from the built-in d If the module path is relative, such as `.path.to.file`, Lark will attempt to load it from the current working directory. Grammars must have the `.lark` extension. -The rule or terminal can be imported under an other name with the `->` syntax. +The rule or terminal can be imported under another name with the `->` syntax. **Example:** ```perl diff --git a/docs/parsers.md b/docs/parsers.md index 85fd35e..13f2466 100644 --- a/docs/parsers.md +++ b/docs/parsers.md @@ -37,7 +37,7 @@ Lark comes with an efficient implementation that outperforms every other parsing Lark extends the traditional YACC-based architecture with a *contextual lexer*, which automatically provides feedback from the parser to the lexer, making the LALR(1) algorithm stronger than ever. -The contextual lexer communicates with the parser, and uses the parser's lookahead prediction to narrow its choice of tokens. So at each point, the lexer only matches the subgroup of terminals that are legal at that parser state, instead of all of the terminals. It’s surprisingly effective at resolving common terminal collisions, and allows to parse languages that LALR(1) was previously incapable of parsing. +The contextual lexer communicates with the parser, and uses the parser's lookahead prediction to narrow its choice of tokens. So at each point, the lexer only matches the subgroup of terminals that are legal at that parser state, instead of all of the terminals. It’s surprisingly effective at resolving common terminal collisions, and allows one to parse languages that LALR(1) was previously incapable of parsing. This is an improvement to LALR(1) that is unique to Lark. diff --git a/docs/recipes.md b/docs/recipes.md index 18fed37..6a35591 100644 --- a/docs/recipes.md +++ b/docs/recipes.md @@ -81,7 +81,7 @@ Prints out: ## CollapseAmbiguities -Parsing ambiguous texts with earley and `ambiguity='explicit'` produces a single tree with `_ambig` nodes to mark where the ambiguity occured. +Parsing ambiguous texts with earley and `ambiguity='explicit'` produces a single tree with `_ambig` nodes to mark where the ambiguity occurred. However, it's sometimes more convenient instead to work with a list of all possible unambiguous trees. @@ -144,4 +144,4 @@ class Parent(Visitor): if isinstance(subtree, Tree): assert not hasattr(subtree, 'parent') subtree.parent = tree -``` \ No newline at end of file +``` diff --git a/docs/visitors.rst b/docs/visitors.rst index aa3189e..8086f7b 100644 --- a/docs/visitors.rst +++ b/docs/visitors.rst @@ -7,7 +7,7 @@ parse-trees that Lark returns. They are used by inheriting from the correct class (visitor or transformer), and implementing methods corresponding to the rule you wish to process. Each method accepts the children as an argument. That can be modified using the -``v_args`` decorator, which allows to inline the arguments (akin to ``*args``), +``v_args`` decorator, which allows one to inline the arguments (akin to ``*args``), or add the tree ``meta`` property as an argument. See: `visitors.py`_ @@ -99,4 +99,4 @@ v_args Discard ------- -.. autoclass:: lark.visitors.Discard \ No newline at end of file +.. autoclass:: lark.visitors.Discard diff --git a/lark/exceptions.py b/lark/exceptions.py index 6288398..79629e6 100644 --- a/lark/exceptions.py +++ b/lark/exceptions.py @@ -28,7 +28,7 @@ class UnexpectedInput(LarkError): Used as a base class for the following exceptions: - - ``UnexpectedToken``: The parser recieved an unexpected token + - ``UnexpectedToken``: The parser received an unexpected token - ``UnexpectedCharacters``: The lexer encountered an unexpected string After catching one of these exceptions, you may call the following helper methods to create a nicer error message. @@ -137,7 +137,7 @@ class UnexpectedCharacters(LexError, UnexpectedInput): class UnexpectedToken(ParseError, UnexpectedInput): - """When the parser throws UnexpectedToken, it instanciates a puppet + """When the parser throws UnexpectedToken, it instantiates a puppet with its internal state. Users can then interactively set the puppet to the desired puppet state, and resume regular parsing. diff --git a/lark/parsers/lalr_analysis.py b/lark/parsers/lalr_analysis.py index 57a71bf..f6a993b 100644 --- a/lark/parsers/lalr_analysis.py +++ b/lark/parsers/lalr_analysis.py @@ -274,7 +274,7 @@ class LALR_Analyzer(GrammarAnalyzer): for state, la, rules in reduce_reduce: msg = 'Reduce/Reduce collision in %s between the following rules: %s' % (la, ''.join([ '\n\t- ' + str(r) for r in rules ])) if self.debug: - msg += '\n collision occured in state: {%s\n }' % ''.join(['\n\t' + str(x) for x in state.closure]) + msg += '\n collision occurred in state: {%s\n }' % ''.join(['\n\t' + str(x) for x in state.closure]) msgs.append(msg) raise GrammarError('\n\n'.join(msgs)) @@ -301,4 +301,4 @@ class LALR_Analyzer(GrammarAnalyzer): self.compute_reads_relations() self.compute_includes_lookback() self.compute_lookaheads() - self.compute_lalr1_states() \ No newline at end of file + self.compute_lalr1_states() diff --git a/lark/parsers/lalr_puppet.py b/lark/parsers/lalr_puppet.py index e006c17..37a1e9d 100644 --- a/lark/parsers/lalr_puppet.py +++ b/lark/parsers/lalr_puppet.py @@ -23,7 +23,7 @@ class ParserPuppet(object): self.result = None def feed_token(self, token): - """Feed the parser with a token, and advance it to the next state, as if it recieved it from the lexer. + """Feed the parser with a token, and advance it to the next state, as if it received it from the lexer. Note that ``token`` has to be an instance of ``Token``. """ diff --git a/lark/utils.py b/lark/utils.py index ddfcf0b..cfd4306 100644 --- a/lark/utils.py +++ b/lark/utils.py @@ -43,7 +43,7 @@ class Serialize(object): Attributes: __serialize_fields__ (List[str]): Fields (aka attributes) to serialize. - __serialize_namespace__ (list): List of classes that deserialization is allowed to instanciate. + __serialize_namespace__ (list): List of classes that deserialization is allowed to instantiate. Should include all field types that aren't builtin types. """ @@ -332,4 +332,4 @@ def _serialize(value, memo): return list(value) # TODO reversible? elif isinstance(value, dict): return {key:_serialize(elem, memo) for key, elem in value.items()} - return value \ No newline at end of file + return value