52 lines
864 B
Python
52 lines
864 B
Python
import os
|
|
import sys
|
|
|
|
def eq(a, b):
|
|
return a == b
|
|
|
|
def lt(a, b):
|
|
return a[0] < b[0]
|
|
|
|
def addstringchar(a, b):
|
|
return a + b[0]
|
|
|
|
def emit(string):
|
|
sys.stdout.write(string)
|
|
|
|
def trace(header, value):
|
|
if os.environ.get('TRACE'):
|
|
sys.stderr.write(f'{header}={value!r}\\n')
|
|
|
|
eof = chr(0)
|
|
eol = chr(10)
|
|
quote = chr(34)
|
|
PEEK = None
|
|
LINE = 1
|
|
|
|
def peek():
|
|
global PEEK
|
|
if PEEK is None:
|
|
char = sys.stdin.read(1)
|
|
trace('char', char)
|
|
if not char:
|
|
PEEK = eof
|
|
else:
|
|
PEEK = char
|
|
return PEEK
|
|
|
|
def skip():
|
|
global LINE
|
|
global PEEK
|
|
if eol == PEEK:
|
|
LINE += 1
|
|
PEEK = None
|
|
|
|
def skipchar(char):
|
|
global LINE
|
|
assert char == peek(), (LINE, char, peek())
|
|
skip()
|
|
|
|
def fileget(path):
|
|
with open(f'./{path}', encoding='ASCII') as fil:
|
|
return fil.read()
|