Skip to content

Commit

Permalink
[translation] Fix dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Chu committed Apr 12, 2024
1 parent 18484a2 commit d364efe
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion build/dynamic-deps.sh
Expand Up @@ -87,8 +87,9 @@ frontend/match.py # frontend/lexer_gen.py
mycpp/mops.py # Implemented in gc_mops.{h,cC}
pgen2/grammar.py
pgen2/grammar.py # These files are re-done in C++
pgen2/pnode.py
pgen2/token.py
# should be py_path_stat.py, because it's ported by hand to C++
pylib/path_stat.py
Expand Down
8 changes: 4 additions & 4 deletions pgen2/grammar.py
Expand Up @@ -76,7 +76,7 @@ class Grammar(object):
are used to mark state transitions (arcs) in the
DFAs.
Oil patch: this became List[int] where int is the
Oils patch: this became List[int] where int is the
token/symbol number.
start -- the number of the grammar's start symbol.
Expand All @@ -100,20 +100,20 @@ def __init__(self):

self.states = [] # type: states_t
self.dfas = {} # type: Dict[int, dfa_t]
# Oil patch: used to be [(0, "EMPTY")]. I suppose 0 is a special value?
# Oils patch: used to be [(0, "EMPTY")]. I suppose 0 is a special value?
# Or is it ENDMARKER?
self.labels = [0] # type: List[int]
self.keywords = {} # type: Dict[str, int]
self.tokens = {} # type: Dict[int, int]
self.symbol2label = {} # type: Dict[str, int]
self.start = token.NT_OFFSET
self.start = token.NT_OFFSET # Oils note: this init is arbitrary?

if mylib.PYTHON:
def dump(self, f):
# type: (IO[str]) -> None
"""Dump the grammar tables to a marshal file.
Oil patch: changed pickle to marshal.
Oils patch: changed pickle to marshal.
dump() recursively changes all dict to OrderedDict, so the pickled file
is not exactly the same as what was passed in to dump(). load() uses the
Expand Down
10 changes: 7 additions & 3 deletions pgen2/parse.py
Expand Up @@ -14,12 +14,16 @@

from typing import TYPE_CHECKING, Optional, Any, List
from pgen2.pnode import PNode, PNodeAllocator
from pgen2 import token

if TYPE_CHECKING:
from _devbuild.gen.syntax_asdl import Token
from pgen2.grammar import Grammar, dfa_t

# Duplicated to avoid dependency
# from pgen2 import token

NT_OFFSET = 256


class ParseError(Exception):
"""Exception to signal the parser is stuck."""
Expand Down Expand Up @@ -138,7 +142,7 @@ def addtoken(self, typ, opaque, ilabel):
t = self.grammar.labels[ilab]
if ilabel == ilab:
# Look it up in the list of labels
assert t < token.NT_OFFSET, t
assert t < NT_OFFSET, t
# Shift a token; we're done with it
self.shift(typ, opaque, newstate)
# Pop while we are in an accept-only state
Expand All @@ -163,7 +167,7 @@ def addtoken(self, typ, opaque, ilabel):

# Done with this token
return False
elif t >= token.NT_OFFSET:
elif t >= NT_OFFSET:
# See if it's a symbol and if we're in its first set
itsdfa = self.grammar.dfas[t]
_, itsfirst = itsdfa
Expand Down
1 change: 1 addition & 0 deletions prebuilt/dynamic-deps/filter-translate.txt
Expand Up @@ -12,6 +12,7 @@ frontend/match.py
mycpp/mops.py
pgen2/grammar.py
pgen2/pnode.py
pgen2/token.py
pylib/path_stat.py
osh/bool_stat.py
tea/

0 comments on commit d364efe

Please sign in to comment.