Procházet zdrojové kódy

A few more type annotations, reduce use of inline flags

gm/2021-09-23T00Z/github.com--lark-parser-lark/1.0b
Erez Sh před 3 roky
rodič
revize
3f507fc073
3 změnil soubory, kde provedl 7 přidání a 3 odebrání
  1. +2
    -2
      lark/grammars/python.lark
  2. +4
    -0
      lark/indenter.py
  3. +1
    -1
      lark/parse_tree_builder.py

+ 2
- 2
lark/grammars/python.lark Zobrazit soubor

@@ -10,8 +10,8 @@ DEC_NUMBER: /0|[1-9][\d_]*/i
HEX_NUMBER.2: /0x[\da-f]*/i
OCT_NUMBER.2: /0o[0-7]*/i
BIN_NUMBER.2 : /0b[0-1]*/i
FLOAT_NUMBER.2: /((\d+\.[\d_]*|\.[\d_]+)(e[-+]?\d+)?|\d+(e[-+]?\d+))/i
IMAG_NUMBER.2: /\d+j/i | FLOAT_NUMBER "j"i
FLOAT_NUMBER.2: /((\d+\.[\d_]*|\.[\d_]+)([Ee][-+]?\d+)?|\d+([Ee][-+]?\d+))/
IMAG_NUMBER.2: /\d+[Jj]/ | FLOAT_NUMBER /[Jj]/


// Comma-separated list (with an optional trailing comma)


+ 4
- 0
lark/indenter.py Zobrazit soubor

@@ -9,6 +9,10 @@ class DedentError(LarkError):
pass

class Indenter(PostLex):
OPEN_PAREN_types: list
CLOSE_PAREN_types: list
DEDENT_type: str

def __init__(self):
self.paren_level = None
self.indent_level = None


+ 1
- 1
lark/parse_tree_builder.py Zobrazit soubor

@@ -151,7 +151,7 @@ def _should_expand(sym):
return not sym.is_term and sym.name.startswith('_')


def maybe_create_child_filter(expansion, keep_all_tokens, ambiguous, _empty_indices):
def maybe_create_child_filter(expansion, keep_all_tokens, ambiguous, _empty_indices: list):
# Prepare empty_indices as: How many Nones to insert at each index?
if _empty_indices:
assert _empty_indices.count(False) == len(expansion)


Načítá se…
Zrušit
Uložit