История изменений
Исправление rtxtxtrx, (текущая версия) :
@dataclass
class Token:
type: TokenType
value: str
@dataclass
class Parser:
stream: typing.TextIO
curch: str | None = None
nextch: str | None = None
def readch(self) -> str: ...
def advance(self):
self.curch, self.nextch = self.nextch, self.readch()
def peekch(self, charset: str) -> bool:
if self.nextch in charset:
self.advance()
return True
return False
def parse(self) -> Iterable[Token]:
self.advance()
while True:
if self.peekch('\\'):
val = '' # Если эта косая палка не нужна, а она не нужна в принципе
# Тут еще один цикл
while self.peekch('abcdef...A..Z'):
val += self.curch
yield Token(TokenType.Tag, val)
if self.peekch(''):
return Token(TokenType.EOF, self.curch)
Исправление rtxtxtrx, :
@dataclass
class Token:
type: TokenType
value: str
@dataclass
class Parser:
stream: typing.TextIO
curch: str | None = None
nextch: str | None = None
def readch(self) -> str: ...
def advance(self):
self.curch, self.nextch = self.nextch, self.readch()
def peekch(self, charset: str) -> bool:
if self.nextch in charset:
self.advance()
return True
return False
def parse(self) -> Iterable[Token]:
self.advance()
while True:
if self.peekch('\\'):
...
yield Token(TokenType.Tag, val)
if self.peekch(''):
return Token(TokenType.EOF, self.curch)
Исправление rtxtxtrx, :
@dataclass
class Token:
type: TokenType
value: str
@dataclass
class Parser:
stream: typing.TextIO
curch: str | None = None
nextch: str | None = None
def readch(self) -> str: ...
def advance(self):
self.curch, self.nextch = self.nextch, self.readch()
def peekch(self, charset: str) -> bool:
if self.nextch in charset:
self.advance()
return True
return False
def parse(self) -> Iterable[Token]:
self.advance()
while True:
if self.peekch('\\'):
...
yield Token(TokenType.Tag, val)
if self.peekch(''):
return Token(TokenType.EOL, self.curch)
Исправление rtxtxtrx, :
@dataclass
class Token:
type: TokenType
value: str
@dataclass
class Parser:
stream: typing.TextIO
curch: str | None = None
nextch: str | None = None
def readch(self) -> str: ...
def advance(self):
self.curch, self.nextch = self.nextch, self.readch()
def peekch(self, charset: str) -> bool:
if self.nextch in charset:
self.advance()
return True
return False
def parse(self) -> Iterable[Token]:
self.advance()
while True:
if self.peekch('\\'):
...
yield Token(TokenType.Tag, val)
Исправление rtxtxtrx, :
@dataclass
class Token:
type: TokenType
value: str
@dataclass
class Parser:
stream: typing.TextIO
curch: str | None = None
nextch: str | None = None
def readch(self) -> str: ...
def advance(self):
self.curch, self.nextch = self.nextch, self.readch()
def peekch(self, charset: str) -> bool:
if self.nextch in charset:
self.advance()
return True
return False
def parse(self) -> Token:
self.advance()
while True:
if self.peekch('\\'):
...
return Token(TokenType.Tag, val)
Исправление rtxtxtrx, :
@dataclass
class Token:
type: TokenType
value: str
@dataclass
class Parser:
stream: typing.TextIO
curch: str | None = None
nextch: str | None = None
def readch(self) -> str: ...
def advance(self):
self.curch, self.nextch = self.nextch, self.readch()
def peekch(self, charset: str) -> bool:
if self.nextch in charset:
self.advance()
return False
return True
def parse(self) -> Token:
self.advance()
while True:
if self.peekch('\\'):
...
return Token(TokenType.Tag, val)
Исходная версия rtxtxtrx, :
@dataclass
class Token:
type: TokenType
value: str
@dataclass
class Parser:
stream: typing.TextIO
curch: str | None = None
nextch: str | None = None
def readch(self) -> str: ...
def advance(self):
self.curch, self.nextch = self.nextch, self.readch()
def peekch(self, charset: str) -> bool:
if self.nextch in charset:
self.advance()
return False
return True
def parse(self) -> Token:
while True:
if self.peekch('\\'):
...
return Token(TokenType.Tag, val)