-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get rid of global lexer state (#159)
* Get rid of Python 3.6 compat bits * Don't mix floating-point infinity with integers * Get rid of global lexer state
- Loading branch information
Showing
8 changed files
with
78 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +0,0 @@ | ||
from flynt.lexer.Chunk import Chunk as _Chunk | ||
|
||
set_multiline = _Chunk.set_multiline | ||
set_single_line = _Chunk.set_single_line | ||
set_multiline() | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import dataclasses | ||
import token | ||
from typing import FrozenSet | ||
|
||
|
||
@dataclasses.dataclass(frozen=True) | ||
class LexerContext: | ||
skip_tokens: FrozenSet[int] | ||
break_tokens: FrozenSet[int] | ||
multiline: bool | ||
|
||
|
||
single_line_context = LexerContext( | ||
skip_tokens=frozenset(), | ||
break_tokens=frozenset((token.COMMENT, token.NEWLINE, token.NL)), | ||
multiline=False, | ||
) | ||
|
||
multi_line_context = LexerContext( | ||
skip_tokens=frozenset((token.NEWLINE, token.NL)), | ||
break_tokens=frozenset((token.COMMENT,)), | ||
multiline=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters