Skip to content

Commit 65d8d3b

Browse files
committed
Refactor Lexer
Replicates graphql/graphql-js@fd3d8c9
1 parent cda36db commit 65d8d3b

File tree

6 files changed

+396
-376
lines changed

6 files changed

+396
-376
lines changed

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
traceback
133133
types.TracebackType
134134
asyncio.events.AbstractEventLoop
135+
graphql.language.lexer.EscapeSequence
135136
graphql.subscription.map_async_iterator.MapAsyncIterator
136137
graphql.type.schema.InterfaceImplementations
137138
graphql.validation.validation_context.VariableUsage

src/graphql/language/ast.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,13 @@ def __init__(
9999
end: int,
100100
line: int,
101101
column: int,
102-
prev: Optional["Token"] = None,
103102
value: Optional[str] = None,
104103
) -> None:
105104
self.kind = kind
106105
self.start, self.end = start, end
107106
self.line, self.column = line, column
108107
self.value = value
109-
self.prev = prev
110-
self.next = None
108+
self.prev = self.next = None
111109

112110
def __str__(self) -> str:
113111
return self.desc
@@ -140,15 +138,16 @@ def __hash__(self) -> int:
140138

141139
def __copy__(self) -> "Token":
142140
"""Create a shallow copy of the token"""
143-
return self.__class__(
141+
token = self.__class__(
144142
self.kind,
145143
self.start,
146144
self.end,
147145
self.line,
148146
self.column,
149-
self.prev,
150147
self.value,
151148
)
149+
token.prev = self.prev
150+
return token
152151

153152
def __deepcopy__(self, memo: Dict) -> "Token":
154153
"""Allow only shallow copies to avoid recursion."""

0 commit comments

Comments
 (0)