Kaynağa Gözat

Fix various typos

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.0
Peter Wienemann 3 yıl önce
ebeveyn
işleme
e02b1b6669
8 değiştirilmiş dosya ile 13 ekleme ve 13 silme
  1. +1
    -1
      docs/grammar.md
  2. +1
    -1
      docs/parsers.md
  3. +2
    -2
      docs/recipes.md
  4. +2
    -2
      docs/visitors.rst
  5. +2
    -2
      lark/exceptions.py
  6. +2
    -2
      lark/parsers/lalr_analysis.py
  7. +1
    -1
      lark/parsers/lalr_puppet.py
  8. +2
    -2
      lark/utils.py

+ 1
- 1
docs/grammar.md Dosyayı Görüntüle

@@ -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


+ 1
- 1
docs/parsers.md Dosyayı Görüntüle

@@ -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.



+ 2
- 2
docs/recipes.md Dosyayı Görüntüle

@@ -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
```
```

+ 2
- 2
docs/visitors.rst Dosyayı Görüntüle

@@ -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
.. autoclass:: lark.visitors.Discard

+ 2
- 2
lark/exceptions.py Dosyayı Görüntüle

@@ -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.



+ 2
- 2
lark/parsers/lalr_analysis.py Dosyayı Görüntüle

@@ -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()
self.compute_lalr1_states()

+ 1
- 1
lark/parsers/lalr_puppet.py Dosyayı Görüntüle

@@ -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``.
"""


+ 2
- 2
lark/utils.py Dosyayı Görüntüle

@@ -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
return value

Yükleniyor…
İptal
Kaydet