MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / InPort

Class InPort

18-with-match/lispy/original/lispy.py:39–51  ·  view source on GitHub ↗

An input port. Retains a line of chars.

Source from the content-addressed store, hash-verified

37eof_object = Symbol('#<eof-object>') # Note: uninterned; can't be read
38
39class InPort:
40 "An input port. Retains a line of chars."
41 tokenizer = r"""\s*(,@|[('`,)]|"(?:[\\].|[^\\"])*"|;.*|[^\s(&#x27;"`,;)]*)(.*)"""
42 def __init__(self, file):
43 self.file = file; self.line = ''
44 def next_token(self):
45 "Return the next token, reading new text into line buffer if needed."
46 while True:
47 if self.line == '': self.line = self.file.readline()
48 if self.line == '': return eof_object
49 token, self.line = re.match(InPort.tokenizer, self.line).groups()
50 if token != '' and not token.startswith(';'):
51 return token
52
53def readchar(inport):
54 "Read the next character from an input port."

Callers 3

parseFunction · 0.85
loadFunction · 0.85
replFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected