This file contains hidden or 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
import collections | |
import difflib | |
import pathlib | |
import dill as pickle | |
import scanner | |
import sys | |
import utils | |
Token = collections.namedtuple('Token', 'line col type string virtual') |
This file contains hidden or 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
Akaroa | |
Amuri | |
Ashburton | |
Bay of Islands | |
Bruce | |
Buller | |
Chatham Islands | |
Cheviot | |
Clifton | |
Clutha |
This file contains hidden or 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
# A xterm-256color based TERMINFO that adds the escape sequences for italic. | |
# | |
# Install: | |
# | |
# tic xterm-256color-italic.terminfo | |
# | |
# Usage: | |
# | |
# export TERM=xterm-256color-italic | |
# |
This file contains hidden or 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
DCPU-16 Specification | |
Copyright 1985 Mojang | |
Version 1.7 | |
=== SUMMARY ==================================================================== | |
* 16 bit words | |
* 0x10000 words of ram |
This file contains hidden or 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
print(__import__('random').choice(__import__('sys').stdin.read().strip())) |
This file contains hidden or 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
@compose(E.ControlStructureExpression) | |
@compose(list) | |
def linked_control_structure_stmt(self, initial, pos0): | |
linking_structure = self.linked_control_structures[self.current_token().string] | |
while True: | |
pos = self.current_token().pos | |
name = self.get_token().string | |
options = linking_structure[name] | |
params = [] | |
i, j = 0, 0 |
This file contains hidden or 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
28 base_linked_control_structures = { | |
29 'if': { | |
30 'if': [[None]], | |
31 'elif': [[None]], | |
32 'else': [] | |
33 }, | |
34 'while': { | |
35 'while': [[None]], | |
36 'else': [], | |
37 }, |
This file contains hidden or 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
if x: | |
pass | |
elif y: | |
pass | |
elif z: | |
pass | |
elif q: | |
pass | |
else: | |
pass |
This file contains hidden or 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
# to print an s-expression | |
# | |
# e.g. | |
# (macro-definition | |
# (id-expression name) | |
# (statements | |
# (...) | |
# (...) | |
# (...))) |
This file contains hidden or 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
def to_sexpr(o, indent=None): | |
return fmt_sexpr(json.loads(MyJSONEncoder().encode(o))) | |
def fmt_sexpr(o, depth=1): | |
if isinstance(o, dict): | |
return fmt_sexpr(list(o.values()), depth) | |
if isinstance(o, tuple): | |
return fmt_sexpr(list(o), depth) | |
if isinstance(o, list): | |
if len(o) == 0: |