mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-125588: Teach the python PEG generator the new f-string tokens (#125589)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
This commit is contained in:
parent
0e45b1fd0f
commit
9dfef4e5f4
6 changed files with 61 additions and 2 deletions
|
@ -205,6 +205,36 @@ class Parser:
|
|||
return self._tokenizer.getnext()
|
||||
return None
|
||||
|
||||
@memoize
|
||||
def fstring_start(self) -> Optional[tokenize.TokenInfo]:
|
||||
FSTRING_START = getattr(token, "FSTRING_START")
|
||||
if not FSTRING_START:
|
||||
return None
|
||||
tok = self._tokenizer.peek()
|
||||
if tok.type == FSTRING_START:
|
||||
return self._tokenizer.getnext()
|
||||
return None
|
||||
|
||||
@memoize
|
||||
def fstring_middle(self) -> Optional[tokenize.TokenInfo]:
|
||||
FSTRING_MIDDLE = getattr(token, "FSTRING_MIDDLE")
|
||||
if not FSTRING_MIDDLE:
|
||||
return None
|
||||
tok = self._tokenizer.peek()
|
||||
if tok.type == FSTRING_MIDDLE:
|
||||
return self._tokenizer.getnext()
|
||||
return None
|
||||
|
||||
@memoize
|
||||
def fstring_end(self) -> Optional[tokenize.TokenInfo]:
|
||||
FSTRING_END = getattr(token, "FSTRING_END")
|
||||
if not FSTRING_END:
|
||||
return None
|
||||
tok = self._tokenizer.peek()
|
||||
if tok.type == FSTRING_END:
|
||||
return self._tokenizer.getnext()
|
||||
return None
|
||||
|
||||
@memoize
|
||||
def op(self) -> Optional[tokenize.TokenInfo]:
|
||||
tok = self._tokenizer.peek()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue