mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-20 04:18:27 +08:00
Merge branch 'dev' of github.com:davidhalter/jedi into dev
This commit is contained in:
@@ -135,22 +135,27 @@ class PgenParser(object):
|
|||||||
ilabel = token_to_ilabel(self.grammar, type_, value)
|
ilabel = token_to_ilabel(self.grammar, type_, value)
|
||||||
|
|
||||||
# Loop until the token is shifted; may raise exceptions
|
# Loop until the token is shifted; may raise exceptions
|
||||||
|
_gram = self.grammar
|
||||||
|
_labels = _gram.labels
|
||||||
|
_push = self.push
|
||||||
|
_pop = self.pop
|
||||||
|
_shift = self.shift
|
||||||
while True:
|
while True:
|
||||||
dfa, state, node = self.stack[-1]
|
dfa, state, node = self.stack[-1]
|
||||||
states, first = dfa
|
states, first = dfa
|
||||||
arcs = states[state]
|
arcs = states[state]
|
||||||
# Look for a state with this label
|
# Look for a state with this label
|
||||||
for i, newstate in arcs:
|
for i, newstate in arcs:
|
||||||
t, v = self.grammar.labels[i]
|
t, v = _labels[i]
|
||||||
if ilabel == i:
|
if ilabel == i:
|
||||||
# Look it up in the list of labels
|
# Look it up in the list of labels
|
||||||
assert t < 256
|
assert t < 256
|
||||||
# Shift a token; we're done with it
|
# Shift a token; we're done with it
|
||||||
self.shift(type_, value, newstate, prefix, start_pos)
|
_shift(type_, value, newstate, prefix, start_pos)
|
||||||
# Pop while we are in an accept-only state
|
# Pop while we are in an accept-only state
|
||||||
state = newstate
|
state = newstate
|
||||||
while states[state] == [(0, state)]:
|
while states[state] == [(0, state)]:
|
||||||
self.pop()
|
_pop()
|
||||||
if not self.stack:
|
if not self.stack:
|
||||||
# Done parsing!
|
# Done parsing!
|
||||||
return True
|
return True
|
||||||
@@ -160,16 +165,16 @@ class PgenParser(object):
|
|||||||
return False
|
return False
|
||||||
elif t >= 256:
|
elif t >= 256:
|
||||||
# See if it's a symbol and if we're in its first set
|
# See if it's a symbol and if we're in its first set
|
||||||
itsdfa = self.grammar.dfas[t]
|
itsdfa = _gram.dfas[t]
|
||||||
itsstates, itsfirst = itsdfa
|
itsstates, itsfirst = itsdfa
|
||||||
if ilabel in itsfirst:
|
if ilabel in itsfirst:
|
||||||
# Push a symbol
|
# Push a symbol
|
||||||
self.push(t, itsdfa, newstate)
|
_push(t, itsdfa, newstate)
|
||||||
break # To continue the outer while loop
|
break # To continue the outer while loop
|
||||||
else:
|
else:
|
||||||
if (0, state) in arcs:
|
if (0, state) in arcs:
|
||||||
# An accepting state, pop it and try something else
|
# An accepting state, pop it and try something else
|
||||||
self.pop()
|
_pop()
|
||||||
if not self.stack:
|
if not self.stack:
|
||||||
# Done parsing, but another token is input
|
# Done parsing, but another token is input
|
||||||
raise InternalParseError("too much input", type_, value, start_pos)
|
raise InternalParseError("too much input", type_, value, start_pos)
|
||||||
|
|||||||
@@ -113,6 +113,11 @@ class ParserPickling(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def load_parser(self, path, original_changed_time):
|
def load_parser(self, path, original_changed_time):
|
||||||
|
"""
|
||||||
|
Try to load the parser for `path`, unless `original_changed_time` is
|
||||||
|
greater than the original pickling time. In which case the pickled
|
||||||
|
parser is not up to date.
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
pickle_changed_time = self._index[path]
|
pickle_changed_time = self._index[path]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|||||||
Reference in New Issue
Block a user