├── changelog.md ├── common.h ├── compiler.py ├── flpc.nim ├── flpc_all.c ├── gen ├── f_string.f ├── getter_syntax.f ├── getter_syntax.f.pos_map ├── list_comp_syntax.f ├── list_comp_syntax.f.pos_map ├── resizable_syntax.f ├── resizable_syntax.f.pos_map ├── split_grammar.f ├── triple_quote.f └── triple_quote.f.pos_map ├── globals.c ├── grammar ├── boot.grammar ├── f_string.grammar ├── flpc.grammar ├── getter.grammar ├── list_comp.grammar ├── resizable.grammar ├── test.grammar └── triple_quote.grammar ├── init_memory.dat ├── lib ├── boot.flpc ├── flpc_grammar.flpc ├── grammar.flpc ├── stage0.flpc ├── stage1a.flpc ├── stage1b.flpc ├── stage1b2.flpc ├── stage1b3.flpc ├── stage1c.flpc ├── stage1d.flpc ├── stage2.flpc ├── stage3a.flpc ├── stage3b.flpc ├── stage4.flpc ├── stage5.flpc ├── stage6a.flpc ├── stage6b.flpc ├── stage7a.flpc ├── stage7a2.flpc └── stage7b.flpc ├── pos_map.txt ├── precompiled ├── compiler.f ├── compiler.f.pos_map ├── flpc-gen.f ├── flpc-gen.f.pos_map ├── interpreter.f ├── interpreter.f.pos_map ├── self-stage0.f ├── self.f └── self.f.pos_map ├── readme.md ├── requirements.txt ├── stack.png └── test ├── file.flpc ├── list_comp_test.flpc ├── multi_if.flpc ├── prime-test.flpc ├── pyexec.flpc ├── self.flpc ├── stage1a-test.flpc ├── stage1b-test.flpc ├── stage1c-test.flpc ├── stage1d-test.flpc ├── stage3-test.flpc ├── stage6a-test.flpc └── stage6b-test.flpc /changelog.md: -------------------------------------------------------------------------------- 1 | This file lists backwards incompatible changes. If this becomes heavily used, migration scripts will be offered. 2 | 3 | # Changes 4 | 5 | ## Mid April 2021 6 | 7 | - Call stack use explicit separators to delimit function calls. `newfunc`/`return` changed drastically as a result. 8 | 9 | ## April 2021 10 | 11 | - Reversed order of args of `memory.set` so it matches other `. set` functions. 12 | - Break `inline` into two functions: `fast_fun` for unchecked args and `local_fun` for checked args. 13 | - String representation: Only strings following `push:` in FlpcForth have underscores interpreted as spaces. (Previously, this was the case for all strings, including FlpcPython!) 14 | 15 | ## June 2021 16 | 17 | - String replace spaces with "\s" and leave underscores alone. To avoid an unnecessary escape. Also use "\_" instead of "\s". 18 | 19 | ## July 2021 20 | 21 | - `pos_map.txt` no longer contains its own length as an integer on the second line. 22 | - `pos_map.txt` is replaced by a `.f.pos_map` file next to the `.f` file. E.g., `precompiled/compiler.f.pos_map`. 23 | -------------------------------------------------------------------------------- /common.h: -------------------------------------------------------------------------------- 1 | #define LENGTH -1 2 | #define MEMORY_LENGTH 10000000 3 | #define STRINGS_LENGTH 10000000 4 | #define MAX_NUM_STRINGS 1000000 5 | #define STACK_MAXLEN 10000 6 | #define MAX_NUM_FILES 50 7 | #define MAX_NUM_RUNTIME_FILES 50 8 | #define FILE_BUFFER_SIZE 150000 9 | #define POS_MAP_LENGTH 20000 10 | // TL: Type bits lengths (least significant x bits indicate types) 11 | #define TL 2 12 | #define call_stack_top call_stack[call_stack[LENGTH] - 1] 13 | #define Pointer 0b10 14 | #define Primitive 0b11 15 | #define String 0b01 16 | #define Int 0b00 17 | #define type(x) (x & 0b11) 18 | #define value(x) (x >> TL) 19 | // Dangerous if evaluating x has a side effect! 20 | #define cvalue(x, y) (type((x)) == (y) ? value((x)) : _error("Unexpected type")) 21 | #define init(C, value) (((value) << TL) + C) 22 | #define None init(Pointer, -1) 23 | #define NoValue init(Pointer, -4) 24 | #define Sep init(Pointer, -2) 25 | #define FileSep init(Pointer, -5) 26 | #define True init(Int, 1) 27 | #define False init(Int, 0) 28 | #define cstring(s) (strings_raw + strings[value(s)] + 1) 29 | #define print_slice(s, start, end) printf("%.*s", end - start, s + start) 30 | #define _assert(cond) if (!(cond)) {_error(#cond);} 31 | -------------------------------------------------------------------------------- /compiler.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from pymetaterp.boot_compiled import match, Node 3 | from pymetaterp import python_compiled 4 | from pymetaterp.util import simple_wrap_tree 5 | from pymetaterp import boot_tree, boot_grammar 6 | from pdb import set_trace as bp 7 | import argparse 8 | 9 | grammar = open("grammar/flpc.grammar").read() 10 | grammar += r""" 11 | SAME_INDENT = hspaces:s ?(self.indentation[-1] == (len(s) if s != None else 0)) 12 | INDENT = ~~(NEWLINE hspaces:s) !(self.indentation.append(len(s) if s != None else 0)) 13 | DEDENT = !(self.indentation.pop()) 14 | """ 15 | 16 | def parse(source): 17 | return python_compiled.match(lang_tree, source) 18 | 19 | def to_list(value): 20 | return value if isinstance(value, list) else\ 21 | [] if value is None else\ 22 | [value] 23 | 24 | # multi_block_call = (block_call["if"] block_call["else"] | block_call[expr])* 25 | def simplify(root): 26 | if not hasattr(root, "name"): 27 | return root 28 | elif root.name in ["func_call", "block_call"]: 29 | output = Node(root[0][0], simplify(root[1])) 30 | elif root.name == "infix": 31 | output = root[0] 32 | for i in range(2, len(root), 2): 33 | output = Node(root[i-1][0], [simplify(output), simplify(root[i])]) 34 | output.pos = root[i].pos 35 | elif root.name == "multi_block_call": 36 | children = [simplify(child) for child in root] 37 | # transition = [("if", "else")] 38 | transition = [("if", "else"), ("if", "elif"), ("elif", "elif"), ("elif", "else")] 39 | # Everything not listed above is a single block. 40 | prev = group = None 41 | groups = [] 42 | for child in children: 43 | # print prev, child.name, (prev, child.name) in transition 44 | if (prev, child.name) in transition: 45 | group.append(child) 46 | else: 47 | if group: 48 | groups.append(group) 49 | group = [child] 50 | prev = child.name 51 | groups.append(group) 52 | out = [] 53 | for group in groups: 54 | name = "-".join([child.name for child in group]) 55 | # Ugly hack! 56 | if "-elif" in name: 57 | name = "multi-if" 58 | out.append(Node(name, [gc for child in group for gc in child])) 59 | out[-1].pos = (group[0].pos[0], group[-1].pos[-1]) 60 | if len(out) > 1: 61 | output = Node("suite", out) 62 | else: 63 | output = out[0] 64 | elif root.name in ["suite"] and len(root) == 1: 65 | output = simplify(root[0]) 66 | elif root.name in ["suite"]: 67 | output = Node(root.name, [simplify(child) for child in root 68 | if type(child) != Node or child.name != "EMPTY_LINE"]) 69 | elif len(root) == 1 and type(root[0]) == Node and root[0].name == "exprs": 70 | assert(root.name == "parameters") 71 | return [simplify(child) for child in to_list(root[0].children)] 72 | elif root.name == "parameters": 73 | return [simplify(child) for child in to_list(root.children)] 74 | else: 75 | output = Node(root.name, [simplify(child) for child in root]) 76 | output.pos = root.pos 77 | return output 78 | 79 | class FList(list): 80 | def __init__(self, lst, pos=None): 81 | list.__init__(self, lst) 82 | self.pos = pos 83 | 84 | class FQuote(list): 85 | def __init__(self, lst, pos=None): 86 | list.__init__(self, lst) 87 | self.pos = pos 88 | 89 | class FComment: 90 | def __init__(self, value, pos=None): 91 | self.value = tuple(value) 92 | self.pos = pos 93 | def __repr__(self): 94 | return repr(self.value) 95 | def __nonzero__(self): 96 | return bool(self.value) 97 | 98 | class FCall: 99 | def __init__(self, s, pos=None): 100 | self.str = s 101 | self.pos = pos 102 | def __repr__(self): 103 | return self.str 104 | 105 | class FStr: 106 | def __init__(self, s, pos=None): 107 | assert(type(s) == str) 108 | self.str = s 109 | self.pos = pos 110 | def __str__(self): 111 | return self.str 112 | def __repr__(self): 113 | return repr(self.str) 114 | 115 | def flatten(lst): 116 | for elem in lst: 117 | if isinstance(elem, FList): 118 | for subelem in elem: 119 | yield subelem 120 | else: 121 | yield elem 122 | 123 | def escape_str(s): 124 | return s.replace(" ", "\\_") 125 | 126 | def to_forth(root): 127 | if not isinstance(root, Node): 128 | bp() # Shouldn't happen anymore either 129 | return root 130 | if root.name == "suite": 131 | return FList([to_forth(child) for child in root], root.pos) 132 | elif root.name == "quote": 133 | return FQuote(list(flatten(to_forth(child) for child in root)), root.pos) 134 | elif root.name == "simple_quote": 135 | assert(len(root) == 1 and root[0].name == "names") 136 | children = list(flatten(to_forth(child) for child in root)) 137 | return FComment(children[:-1], root.pos) 138 | elif root.name == "variable": 139 | return FList([FCall("pick:", root.pos), to_forth(root[0])], root.pos) 140 | elif root.name == "NAME": 141 | return FStr(root[0], pos=root.pos) 142 | elif root.name == "name_quote": 143 | return FList([FCall("check:", root.pos), to_forth(root[0])], root.pos) 144 | elif root.name == "STRING": 145 | return FList([FCall("push:", root.pos), FStr(escape_str(root[0]), pos=root.pos)], root.pos) 146 | elif root.name == "NUMBER": 147 | if 0 <= int(root[0]) < 3: 148 | return FStr(root[0], pos=root.pos) 149 | return FList([FCall("pushi:", root.pos), FStr(root[0], pos=root.pos)], root.pos) 150 | elif root.name == "forth_line": 151 | return FList([FCall(child[0], child.pos) for child in root], root.pos) 152 | elif root.name == "forth": 153 | return FList([to_forth(child) for child in root], root.pos) 154 | elif root.name == "assign": 155 | output = to_forth(root[1]) 156 | if not isinstance(output, FList): 157 | output = FList([output], pos=root[1].pos) 158 | output.append(FList([n for child in reversed(root[0]) 159 | for n in [FCall("assign:", child.pos), 160 | to_forth(child)]], root[0].pos)) 161 | return output 162 | elif root.name in ["fun", "inline", "local_fun", "fast_fun"]: 163 | children = list(flatten(to_forth(child) for child in root)) 164 | assert(len(children) == 2) 165 | names = children[0].value if root[0].name == "simple_quote"\ 166 | else children[0][1::2] 167 | if root.name == "fun": 168 | if len(names) < 4: 169 | decl = FList([FCall("newfunc%s" % len(names), root[0].pos)]) 170 | else: 171 | decl = FList([FCall("pushi:", root[0].pos), 172 | FCall(str(len(names)), root[0].pos), 173 | FCall("newfunc", root[0].pos)]) 174 | elif root.name == "local_fun": 175 | decl = FList([FCall("pushi:", root[0].pos), 176 | FCall(str(len(names)), root[0].pos), 177 | FCall("remove_top_names", root[0].pos)]) 178 | else: # inline, fast_fun 179 | decl = FList([], root[0].pos) 180 | if root.name != "fast_fun": 181 | for name in reversed(names): 182 | decl.append(FCall("assign:", root[0].pos)) 183 | decl.append(name) 184 | # Could instead replace children[0]? 185 | output = FQuote([decl, FList(children[1])], root.pos) 186 | if root.name == "fun": # and children[0]: 187 | # Doesn't work properly now that we want to preserve lines! 188 | # Trying to use flatten but not sure its always right. 189 | if str(list(flatten(output[1]))[-1]) not in ["return", "lookup_error"]: 190 | output[1].append(FCall("return_no_value", 191 | pos=(output[1][-1].pos[1], 192 | output[1][-1].pos[1]))) 193 | return output 194 | elif root.name == "bind": 195 | output = to_forth(root[1]) 196 | if not isinstance(output, FList): 197 | output = FList([output], pos=root[1].pos) 198 | output.append(FCall("bind:", root.pos)) 199 | output.append(to_forth(root[0][0])) 200 | return output 201 | elif root.name == "comment": 202 | children = list(flatten(FStr(child, pos=root.pos) for child in root)) 203 | return FComment(children, root.pos) 204 | elif root.name == ".": # getattr 205 | if root[1].name == "variable": 206 | children = [to_forth(root[0]), 207 | FCall("attr:", root.pos), 208 | to_forth(root[1][0])] 209 | else: 210 | children = [to_forth(child) for child in root[1]] +\ 211 | [to_forth(root[0]), 212 | FCall("attr_call:", root.pos), 213 | FStr(escape_str(root[1].name), root.pos)] 214 | return FList(list(flatten(children)), root.pos) 215 | elif root.name == "infix": 216 | bp() # Shouldn't happen anymore 217 | children = list(flatten(to_forth(child) for child in [root[0], root[2]])) 218 | return FList(children + [FCall(root[1][0], root[1].pos)], root.pos) 219 | elif root.name == "return": 220 | pass 221 | elif root.name == "multi-if": 222 | # Should quote conditions 223 | # Need to handle else clause 224 | # children = list(flatten(to_forth(child) for child in reversed(root))) 225 | def wrap(i, child): 226 | return Node("quote", child, child.pos) if i % 2 else child 227 | children = list(flatten(to_forth(wrap(i, child)) 228 | for i, child in enumerate(reversed(root)))) 229 | return FList(children + [FCall("pushi:", root.pos), 230 | FStr(str(len(root)/2), pos=root.pos), 231 | FCall(root.name, root.pos)], root.pos) 232 | elif root.name in ["grammar", "exprsp"]: 233 | children = list(flatten(to_forth(child) for child in root)) 234 | return FList(children) 235 | children = list(flatten(to_forth(child) for child in root)) 236 | return FList(children + [FCall(root.name, root.pos)], root.pos) 237 | 238 | def write_sep(value, pos=None): 239 | global output_stream_pos 240 | if value != "\n": 241 | start = output_stream_pos 242 | if g.last_value == "\n" and value not in ["return_no_value", "]"]: 243 | output_stream.write("\n") 244 | output_stream.write(" " * (g.nesting)) 245 | output_stream_pos += len("\n" + " " * g.nesting) 246 | #if str(value) == "bp": 247 | # bp() 248 | output_stream.write("%s " % value) 249 | output_stream_pos += len("%s " % value) 250 | if pos: 251 | pos_map[(start, output_stream_pos)] = (filename,) + tuple(pos) 252 | g.last_value = value 253 | 254 | escaped = {repr(x)[1:-1]:x for x in "\t\n\r\\"} #\'\" 255 | escaped.update({"\\s": " ", "\(": "(", "\)": ")"}) 256 | 257 | def write_string_body(root, depth): 258 | if isinstance(root, FList): 259 | g.nesting += 1 260 | for child in root: 261 | write_string_body(child, depth) 262 | g.nesting -= 1 263 | write_sep("\n", pos=root.pos) 264 | elif isinstance(root, FQuote): 265 | write_sep("pushf:", pos=root.pos) 266 | write_sep(root.func_name, pos=root.pos) 267 | elif isinstance(root, FCall): 268 | if str(root) in ["return", "return_two"]: 269 | write_sep("func_%s" % root, pos=root.pos) 270 | else: 271 | write_sep(str(root), pos=root.pos) 272 | elif isinstance(root, FStr): 273 | write_sep(root.str, pos=root.pos) 274 | elif isinstance(root, FComment): 275 | pass 276 | elif root is None: 277 | pass 278 | else: 279 | bp() 280 | 281 | def write_blocks(root, depth=1, nesting=0): 282 | # Bad!! And almost unused since reset by write_string_body 283 | g.nesting = nesting 284 | if isinstance(root, (FList, FQuote)): 285 | for child in root: 286 | write_blocks(child, depth + isinstance(child, FQuote), nesting + 1) 287 | g.nesting = nesting 288 | write_sep("\n") 289 | if isinstance(root, FQuote): 290 | if not hasattr(root, "func_name"): 291 | root.func_name = "autogen%s" % g.func_count 292 | g.func_count += 1 293 | g.nesting = 0 294 | write_sep("[", pos=root.pos) 295 | g.nesting = 1 296 | for child in root: 297 | write_string_body(child, depth) 298 | write_sep("]", pos=root.pos) 299 | g.nesting = nesting 300 | if root.func_name.startswith("autogen"): 301 | [write_sep(c, pos=root.pos) for c in ["bind:", root.func_name, "\n"]] 302 | 303 | def write_suite(root, prefix="", ns=False): 304 | for child in root: 305 | if isinstance(child, FComment): 306 | continue 307 | if isinstance(child, FList) and len(child) > 1 and str(child[-2]) == "bind:": 308 | if str(child[-3]) == "class": 309 | # Skip FQuote to avoid writing a function 310 | write_suite(list(child[-4]), "%s." % child[-1]) 311 | elif str(child[-3]) == "ns_class": 312 | # Wrong place. Should be added before write_* 313 | for token in ["pushi:", "100", "hashtable", "bind:", "current_ns"]: 314 | write_sep(token, root.pos) 315 | write_sep("\n") 316 | write_suite(list(child[-4]), ns=True) 317 | # Wrong place. Should be added before write_* 318 | for token in ["push:", child[-1], "new_ns_class"]: 319 | write_sep(token, root.pos) 320 | write_sep("\n") 321 | else: 322 | body = child[0] if len(child) == 3 else child[1] 323 | if isinstance(body, (FStr, FCall)): 324 | # Also need non-string version 325 | write_string_body(child, 0) 326 | write_sep("\n") 327 | continue 328 | # assert(len(child) == 4 or len(child) == 5 and str(child[-3]) in ["inline", "func"]) 329 | assert(len(child) == 3) 330 | body.func_name = (prefix + child[-1].str).replace("_colon", ":") 331 | write_blocks(body) 332 | if ns: 333 | write_sep("ns_bind:", body.pos) 334 | elif body.func_name not in g.written: 335 | g.written.append(body.func_name) 336 | write_sep("bind:", body.pos) 337 | else: 338 | write_sep("rebind:", body.pos) 339 | write_sep(body.func_name) 340 | write_sep("\n") 341 | elif isinstance(child, FList): 342 | g.nesting = 0 343 | write_string_body(child, 0) 344 | write_sep("\n") 345 | else: 346 | import pdb; pdb.set_trace() 347 | 348 | class Global(object): 349 | pass 350 | 351 | g = Global() 352 | 353 | if __name__ == "__main__": 354 | time_log = open("time.log", "w") 355 | output_stream_pos = 0 356 | pos_map = {} 357 | g.func_count = 0 358 | g.last_value = "" 359 | g.nesting = 0 360 | g.written = [] 361 | t1 = list(simple_wrap_tree(boot_tree.tree)) 362 | t2 = match(t1, boot_grammar.bootstrap + boot_grammar.extra + boot_grammar.diff) 363 | lang_tree = match(t2, grammar + boot_grammar.extra) 364 | 365 | parser = argparse.ArgumentParser() 366 | parser.add_argument('inputs', nargs='*') 367 | parser.add_argument('-o', '--output') 368 | args = parser.parse_args() 369 | output_stream = open(args.output, "w") if args.output else sys.stdout 370 | pos_map_filename = args.output + ".pos_map" if args.output else "pos_map.txt" 371 | 372 | header = "push: Generated_from_" + "_".join(sys.argv[1:]) + " print" 373 | output_stream.write(header + "\n") 374 | output_stream_pos += len(header) 375 | import time 376 | start_time = time.time() 377 | for filename in args.inputs: 378 | # g.filename = filename 379 | parsed = parse(open(filename).read()) 380 | if python_compiled.g.input.position+1 != len(python_compiled.g.input.source): 381 | inp = python_compiled.g.input 382 | sys.stderr.write("Warning: %s stopped parsing at character %s: %s\n" % 383 | (filename, inp.position, inp.source[inp.position: inp.position + 100])) 384 | time_log.write(str((filename, "parse", time.time() - start_time)) + "\n") 385 | write_suite(to_forth(simplify(parsed))) 386 | time_log.write(str((filename, "all", time.time() - start_time)) + "\n") 387 | open(pos_map_filename, "w").write("%s %s\n" % (len(sys.argv[1:]), " ".join(sys.argv[1:])) +\ 388 | # "%s\n" % len(pos_map) +\ 389 | "\n".join(" ".join(map(str, (key[0],) + pos_map[key])) 390 | for key in sorted(pos_map.keys()))) 391 | 392 | -------------------------------------------------------------------------------- /gen/f_string.f: -------------------------------------------------------------------------------- 1 | 2 | [ push: { exactly ] bind: tempgen0 3 | [ push: exprsp apply ] bind: tempgen1 4 | [ pushf: tempgen1 out ] bind: tempgen2 5 | [ push: hspaces apply ] bind: tempgen3 6 | [ push: } exactly ] bind: tempgen4 7 | [ pushf: tempgen0 pushf: tempgen2 pushf: tempgen3 pushf: tempgen4 ] bind: tempgen5 8 | [ newfunc0 9 | pushf: tempgen5 and func_return ] bind: flpcg.rules.string_expr 10 | [ push: ' exactly ] bind: tempgen6 11 | [ pushf: tempgen6 negation ] bind: tempgen7 12 | [ push: { exactly ] bind: tempgen8 13 | [ pushf: tempgen8 negation ] bind: tempgen9 14 | [ push: anything apply ] bind: tempgen10 15 | [ pushf: tempgen7 pushf: tempgen9 pushf: tempgen10 ] bind: tempgen11 16 | [ pushf: tempgen11 and ] bind: tempgen12 17 | [ pushf: tempgen12 push: * quantified ] bind: tempgen13 18 | [ push: void apply ] bind: tempgen14 19 | [ pushf: tempgen13 pushf: tempgen14 ] bind: tempgen15 20 | [ pushf: tempgen15 and ] bind: tempgen16 21 | [ newfunc0 22 | pushf: tempgen16 push: STRING bound func_return ] bind: flpcg.rules.f_string_chars_s 23 | [ push: \q exactly ] bind: tempgen17 24 | [ pushf: tempgen17 negation ] bind: tempgen18 25 | [ push: { exactly ] bind: tempgen19 26 | [ pushf: tempgen19 negation ] bind: tempgen20 27 | [ push: anything apply ] bind: tempgen21 28 | [ pushf: tempgen18 pushf: tempgen20 pushf: tempgen21 ] bind: tempgen22 29 | [ pushf: tempgen22 and ] bind: tempgen23 30 | [ pushf: tempgen23 push: * quantified ] bind: tempgen24 31 | [ push: void apply ] bind: tempgen25 32 | [ pushf: tempgen24 pushf: tempgen25 ] bind: tempgen26 33 | [ pushf: tempgen26 and ] bind: tempgen27 34 | [ newfunc0 35 | pushf: tempgen27 push: STRING bound func_return ] bind: flpcg.rules.f_string_chars_d 36 | [ push: f exactly ] bind: tempgen28 37 | [ push: ' exactly ] bind: tempgen29 38 | [ push: f_string_chars_s apply ] bind: tempgen30 39 | [ pushf: tempgen30 out ] bind: tempgen31 40 | [ push: string_expr apply ] bind: tempgen32 41 | [ push: f_string_chars_s apply ] bind: tempgen33 42 | [ pushf: tempgen32 pushf: tempgen33 ] bind: tempgen34 43 | [ pushf: tempgen34 and ] bind: tempgen35 44 | [ pushf: tempgen35 push: * quantified ] bind: tempgen36 45 | [ pushf: tempgen36 out ] bind: tempgen37 46 | [ push: ' exactly ] bind: tempgen38 47 | [ pushf: tempgen28 pushf: tempgen29 pushf: tempgen31 pushf: tempgen37 pushf: tempgen38 ] bind: tempgen39 48 | [ pushf: tempgen39 and ] bind: tempgen40 49 | [ newfunc0 50 | pushf: tempgen40 push: fmt bound func_return ] bind: flpcg.rules.F_QUOTE_S 51 | [ push: f exactly ] bind: tempgen41 52 | [ push: \q exactly ] bind: tempgen42 53 | [ push: f_string_chars_d apply ] bind: tempgen43 54 | [ pushf: tempgen43 out ] bind: tempgen44 55 | [ push: string_expr apply ] bind: tempgen45 56 | [ push: f_string_chars_d apply ] bind: tempgen46 57 | [ pushf: tempgen45 pushf: tempgen46 ] bind: tempgen47 58 | [ pushf: tempgen47 and ] bind: tempgen48 59 | [ pushf: tempgen48 push: * quantified ] bind: tempgen49 60 | [ pushf: tempgen49 out ] bind: tempgen50 61 | [ push: \q exactly ] bind: tempgen51 62 | [ pushf: tempgen41 pushf: tempgen42 pushf: tempgen44 pushf: tempgen50 pushf: tempgen51 ] bind: tempgen52 63 | [ pushf: tempgen52 and ] bind: tempgen53 64 | [ newfunc0 65 | pushf: tempgen53 push: fmt bound func_return ] bind: flpcg.rules.F_QUOTE_D 66 | [ push: hspaces apply ] bind: tempgen54 67 | [ push: F_QUOTE_S apply ] bind: tempgen55 68 | [ push: F_QUOTE_D apply ] bind: tempgen56 69 | [ pushf: tempgen55 pushf: tempgen56 ] bind: tempgen57 70 | [ pushf: tempgen57 or ] bind: tempgen58 71 | [ pushf: tempgen54 pushf: tempgen58 ] bind: tempgen59 72 | [ newfunc0 73 | pushf: tempgen59 and func_return ] bind: flpcg.rules.F_QUOTE 74 | [ push: single_quotes apply ] bind: tempgen60 75 | [ pushf: tempgen60 negation ] bind: tempgen61 76 | [ push: { exactly ] bind: tempgen62 77 | [ pushf: tempgen62 negation ] bind: tempgen63 78 | [ push: anything apply ] bind: tempgen64 79 | [ pushf: tempgen61 pushf: tempgen63 pushf: tempgen64 ] bind: tempgen65 80 | [ pushf: tempgen65 and ] bind: tempgen66 81 | [ pushf: tempgen66 push: * quantified ] bind: tempgen67 82 | [ push: void apply ] bind: tempgen68 83 | [ pushf: tempgen67 pushf: tempgen68 ] bind: tempgen69 84 | [ pushf: tempgen69 and ] bind: tempgen70 85 | [ newfunc0 86 | pushf: tempgen70 push: TRIPLE_QUOTE bound func_return ] bind: flpcg.rules.f_triple_quote_s 87 | [ push: double_quotes apply ] bind: tempgen71 88 | [ pushf: tempgen71 negation ] bind: tempgen72 89 | [ push: { exactly ] bind: tempgen73 90 | [ pushf: tempgen73 negation ] bind: tempgen74 91 | [ push: anything apply ] bind: tempgen75 92 | [ pushf: tempgen72 pushf: tempgen74 pushf: tempgen75 ] bind: tempgen76 93 | [ pushf: tempgen76 and ] bind: tempgen77 94 | [ pushf: tempgen77 push: * quantified ] bind: tempgen78 95 | [ push: void apply ] bind: tempgen79 96 | [ pushf: tempgen78 pushf: tempgen79 ] bind: tempgen80 97 | [ pushf: tempgen80 and ] bind: tempgen81 98 | [ newfunc0 99 | pushf: tempgen81 push: TRIPLE_QUOTE bound func_return ] bind: flpcg.rules.f_triple_quote_d 100 | [ push: f exactly ] bind: tempgen82 101 | [ push: single_quotes apply ] bind: tempgen83 102 | [ push: f_triple_quote_s apply ] bind: tempgen84 103 | [ pushf: tempgen84 out ] bind: tempgen85 104 | [ push: string_expr apply ] bind: tempgen86 105 | [ push: f_triple_quote_s apply ] bind: tempgen87 106 | [ pushf: tempgen86 pushf: tempgen87 ] bind: tempgen88 107 | [ pushf: tempgen88 and ] bind: tempgen89 108 | [ pushf: tempgen89 push: * quantified ] bind: tempgen90 109 | [ pushf: tempgen90 out ] bind: tempgen91 110 | [ push: single_quotes apply ] bind: tempgen92 111 | [ pushf: tempgen82 pushf: tempgen83 pushf: tempgen85 pushf: tempgen91 pushf: tempgen92 ] bind: tempgen93 112 | [ pushf: tempgen93 and ] bind: tempgen94 113 | [ newfunc0 114 | pushf: tempgen94 push: fmt bound func_return ] bind: flpcg.rules.F_TRIPLE_QUOTE_S 115 | [ push: f exactly ] bind: tempgen95 116 | [ push: double_quotes apply ] bind: tempgen96 117 | [ push: f_triple_quote_d apply ] bind: tempgen97 118 | [ pushf: tempgen97 out ] bind: tempgen98 119 | [ push: string_expr apply ] bind: tempgen99 120 | [ push: f_triple_quote_d apply ] bind: tempgen100 121 | [ pushf: tempgen99 pushf: tempgen100 ] bind: tempgen101 122 | [ pushf: tempgen101 and ] bind: tempgen102 123 | [ pushf: tempgen102 push: * quantified ] bind: tempgen103 124 | [ pushf: tempgen103 out ] bind: tempgen104 125 | [ push: double_quotes apply ] bind: tempgen105 126 | [ pushf: tempgen95 pushf: tempgen96 pushf: tempgen98 pushf: tempgen104 pushf: tempgen105 ] bind: tempgen106 127 | [ pushf: tempgen106 and ] bind: tempgen107 128 | [ newfunc0 129 | pushf: tempgen107 push: fmt bound func_return ] bind: flpcg.rules.F_TRIPLE_QUOTE_D 130 | [ push: hspaces apply ] bind: tempgen108 131 | [ push: F_TRIPLE_QUOTE_S apply ] bind: tempgen109 132 | [ push: F_TRIPLE_QUOTE_D apply ] bind: tempgen110 133 | [ pushf: tempgen109 pushf: tempgen110 ] bind: tempgen111 134 | [ pushf: tempgen111 or ] bind: tempgen112 135 | [ pushf: tempgen108 pushf: tempgen112 ] bind: tempgen113 136 | [ newfunc0 137 | pushf: tempgen113 and func_return ] bind: flpcg.rules.F_TRIPLE_QUOTE 138 | [ push: F_TRIPLE_QUOTE apply ] bind: tempgen114 139 | [ push: F_QUOTE apply ] bind: tempgen115 140 | [ push: list_comp_var apply ] bind: tempgen116 141 | [ push: make_dict apply ] bind: tempgen117 142 | [ push: make_resizable apply ] bind: tempgen118 143 | [ push: forth apply ] bind: tempgen119 144 | [ push: func_call apply ] bind: tempgen120 145 | [ push: name_quote apply ] bind: tempgen121 146 | [ push: quote apply ] bind: tempgen122 147 | [ push: parenthesis apply ] bind: tempgen123 148 | [ push: NUMBER apply ] bind: tempgen124 149 | [ push: TRIPLE_QUOTE apply ] bind: tempgen125 150 | [ push: STRING apply ] bind: tempgen126 151 | [ push: variable apply ] bind: tempgen127 152 | [ pushf: tempgen114 pushf: tempgen115 pushf: tempgen116 pushf: tempgen117 pushf: tempgen118 pushf: tempgen119 pushf: tempgen120 pushf: tempgen121 pushf: tempgen122 pushf: tempgen123 pushf: tempgen124 pushf: tempgen125 pushf: tempgen126 pushf: tempgen127 ] bind: tempgen128 153 | [ newfunc0 154 | pushf: tempgen128 or func_return ] bind: flpcg.rules.non_block_non_infix 155 | push: string_expr pick: flpcg.rules.string_expr pick: flpcg.rules hashtable.set 156 | push: f_string_chars_s pick: flpcg.rules.f_string_chars_s pick: flpcg.rules hashtable.set 157 | push: f_string_chars_d pick: flpcg.rules.f_string_chars_d pick: flpcg.rules hashtable.set 158 | push: F_QUOTE_S pick: flpcg.rules.F_QUOTE_S pick: flpcg.rules hashtable.set 159 | push: F_QUOTE_D pick: flpcg.rules.F_QUOTE_D pick: flpcg.rules hashtable.set 160 | push: F_QUOTE pick: flpcg.rules.F_QUOTE pick: flpcg.rules hashtable.set 161 | push: f_triple_quote_s pick: flpcg.rules.f_triple_quote_s pick: flpcg.rules hashtable.set 162 | push: f_triple_quote_d pick: flpcg.rules.f_triple_quote_d pick: flpcg.rules hashtable.set 163 | push: F_TRIPLE_QUOTE_S pick: flpcg.rules.F_TRIPLE_QUOTE_S pick: flpcg.rules hashtable.set 164 | push: F_TRIPLE_QUOTE_D pick: flpcg.rules.F_TRIPLE_QUOTE_D pick: flpcg.rules hashtable.set 165 | push: F_TRIPLE_QUOTE pick: flpcg.rules.F_TRIPLE_QUOTE pick: flpcg.rules hashtable.set 166 | push: non_block_non_infix pick: flpcg.rules.non_block_non_infix pick: flpcg.rules hashtable.set -------------------------------------------------------------------------------- /gen/getter_syntax.f: -------------------------------------------------------------------------------- 1 | 2 | [ push: + token ] bind: tempgen0 3 | [ push: - token ] bind: tempgen1 4 | [ push: / token ] bind: tempgen2 5 | [ push: == token ] bind: tempgen3 6 | [ push: < token ] bind: tempgen4 7 | [ push: > token ] bind: tempgen5 8 | [ push: . token ] bind: tempgen6 9 | [ push: in token ] bind: tempgen7 10 | [ push: || token ] bind: tempgen8 11 | [ push: && token ] bind: tempgen9 12 | [ push: ! token ] bind: tempgen10 13 | [ pushf: tempgen0 pushf: tempgen1 pushf: tempgen2 pushf: tempgen3 pushf: tempgen4 pushf: tempgen5 pushf: tempgen6 pushf: tempgen7 pushf: tempgen8 pushf: tempgen9 pushf: tempgen10 ] bind: tempgen11 14 | [ newfunc0 15 | pushf: tempgen11 or func_return ] bind: flpcg.rules.bin_op 16 | push: bin_op pick: flpcg.rules.bin_op pick: flpcg.rules hashtable.set -------------------------------------------------------------------------------- /gen/getter_syntax.f.pos_map: -------------------------------------------------------------------------------- 1 | 1 gen/getter_syntax.f 2 | 0 gen/getter_syntax.flpc 44 56 3 | 3 gen/getter_syntax.flpc 51 54 4 | 9 gen/getter_syntax.flpc 51 54 5 | 11 gen/getter_syntax.flpc 45 55 6 | 17 gen/getter_syntax.flpc 44 56 7 | 19 gen/getter_syntax.flpc 44 56 8 | 25 gen/getter_syntax.flpc 44 56 9 | 34 gen/getter_syntax.flpc 57 69 10 | 37 gen/getter_syntax.flpc 64 67 11 | 43 gen/getter_syntax.flpc 64 67 12 | 45 gen/getter_syntax.flpc 58 68 13 | 51 gen/getter_syntax.flpc 57 69 14 | 53 gen/getter_syntax.flpc 57 69 15 | 59 gen/getter_syntax.flpc 57 69 16 | 68 gen/getter_syntax.flpc 70 82 17 | 71 gen/getter_syntax.flpc 77 80 18 | 77 gen/getter_syntax.flpc 77 80 19 | 79 gen/getter_syntax.flpc 71 81 20 | 85 gen/getter_syntax.flpc 70 82 21 | 87 gen/getter_syntax.flpc 70 82 22 | 93 gen/getter_syntax.flpc 70 82 23 | 102 gen/getter_syntax.flpc 83 96 24 | 105 gen/getter_syntax.flpc 90 94 25 | 111 gen/getter_syntax.flpc 90 94 26 | 114 gen/getter_syntax.flpc 84 95 27 | 120 gen/getter_syntax.flpc 83 96 28 | 122 gen/getter_syntax.flpc 83 96 29 | 128 gen/getter_syntax.flpc 83 96 30 | 137 gen/getter_syntax.flpc 97 109 31 | 140 gen/getter_syntax.flpc 104 107 32 | 146 gen/getter_syntax.flpc 104 107 33 | 148 gen/getter_syntax.flpc 98 108 34 | 154 gen/getter_syntax.flpc 97 109 35 | 156 gen/getter_syntax.flpc 97 109 36 | 162 gen/getter_syntax.flpc 97 109 37 | 171 gen/getter_syntax.flpc 110 122 38 | 174 gen/getter_syntax.flpc 117 120 39 | 180 gen/getter_syntax.flpc 117 120 40 | 182 gen/getter_syntax.flpc 111 121 41 | 188 gen/getter_syntax.flpc 110 122 42 | 190 gen/getter_syntax.flpc 110 122 43 | 196 gen/getter_syntax.flpc 110 122 44 | 205 gen/getter_syntax.flpc 123 135 45 | 208 gen/getter_syntax.flpc 130 133 46 | 214 gen/getter_syntax.flpc 130 133 47 | 216 gen/getter_syntax.flpc 124 134 48 | 222 gen/getter_syntax.flpc 123 135 49 | 224 gen/getter_syntax.flpc 123 135 50 | 230 gen/getter_syntax.flpc 123 135 51 | 239 gen/getter_syntax.flpc 136 149 52 | 242 gen/getter_syntax.flpc 143 147 53 | 248 gen/getter_syntax.flpc 143 147 54 | 251 gen/getter_syntax.flpc 137 148 55 | 257 gen/getter_syntax.flpc 136 149 56 | 259 gen/getter_syntax.flpc 136 149 57 | 265 gen/getter_syntax.flpc 136 149 58 | 274 gen/getter_syntax.flpc 150 163 59 | 277 gen/getter_syntax.flpc 157 161 60 | 283 gen/getter_syntax.flpc 157 161 61 | 286 gen/getter_syntax.flpc 151 162 62 | 292 gen/getter_syntax.flpc 150 163 63 | 294 gen/getter_syntax.flpc 150 163 64 | 300 gen/getter_syntax.flpc 150 163 65 | 309 gen/getter_syntax.flpc 164 177 66 | 312 gen/getter_syntax.flpc 171 175 67 | 318 gen/getter_syntax.flpc 171 175 68 | 321 gen/getter_syntax.flpc 165 176 69 | 327 gen/getter_syntax.flpc 164 177 70 | 329 gen/getter_syntax.flpc 164 177 71 | 335 gen/getter_syntax.flpc 164 177 72 | 344 gen/getter_syntax.flpc 178 190 73 | 347 gen/getter_syntax.flpc 185 188 74 | 353 gen/getter_syntax.flpc 185 188 75 | 355 gen/getter_syntax.flpc 179 189 76 | 361 gen/getter_syntax.flpc 178 190 77 | 363 gen/getter_syntax.flpc 178 190 78 | 369 gen/getter_syntax.flpc 178 190 79 | 379 gen/getter_syntax.flpc 43 191 80 | 382 gen/getter_syntax.flpc 44 56 81 | 389 gen/getter_syntax.flpc 44 56 82 | 398 gen/getter_syntax.flpc 57 69 83 | 405 gen/getter_syntax.flpc 57 69 84 | 414 gen/getter_syntax.flpc 70 82 85 | 421 gen/getter_syntax.flpc 70 82 86 | 430 gen/getter_syntax.flpc 83 96 87 | 437 gen/getter_syntax.flpc 83 96 88 | 446 gen/getter_syntax.flpc 97 109 89 | 453 gen/getter_syntax.flpc 97 109 90 | 462 gen/getter_syntax.flpc 110 122 91 | 469 gen/getter_syntax.flpc 110 122 92 | 478 gen/getter_syntax.flpc 123 135 93 | 485 gen/getter_syntax.flpc 123 135 94 | 494 gen/getter_syntax.flpc 136 149 95 | 501 gen/getter_syntax.flpc 136 149 96 | 510 gen/getter_syntax.flpc 150 163 97 | 517 gen/getter_syntax.flpc 150 163 98 | 526 gen/getter_syntax.flpc 164 177 99 | 533 gen/getter_syntax.flpc 164 177 100 | 542 gen/getter_syntax.flpc 178 190 101 | 549 gen/getter_syntax.flpc 178 190 102 | 559 gen/getter_syntax.flpc 43 191 103 | 561 gen/getter_syntax.flpc 43 191 104 | 567 gen/getter_syntax.flpc 43 191 105 | 577 gen/getter_syntax.flpc 21 193 106 | 580 gen/getter_syntax.flpc 25 27 107 | 589 gen/getter_syntax.flpc 43 191 108 | 598 gen/getter_syntax.flpc 43 191 109 | 608 gen/getter_syntax.flpc 40 192 110 | 611 gen/getter_syntax.flpc 33 193 111 | 623 gen/getter_syntax.flpc 21 193 112 | 625 gen/getter_syntax.flpc 21 193 113 | 631 gen/getter_syntax.flpc 21 193 114 | 650 gen/getter_syntax.flpc 209 217 115 | 657 gen/getter_syntax.flpc 209 217 116 | 664 gen/getter_syntax.flpc 218 236 117 | 670 gen/getter_syntax.flpc 218 236 118 | 689 gen/getter_syntax.flpc 237 248 119 | 695 gen/getter_syntax.flpc 237 248 120 | 707 gen/getter_syntax.flpc 195 249 121 | -------------------------------------------------------------------------------- /gen/list_comp_syntax.f: -------------------------------------------------------------------------------- 1 | 2 | [ push: { token ] bind: tempgen0 3 | [ push: expr apply ] bind: tempgen1 4 | [ pushf: tempgen1 out ] bind: tempgen2 5 | [ push: for token ] bind: tempgen3 6 | [ push: NAME apply ] bind: tempgen4 7 | [ pushf: tempgen4 out ] bind: tempgen5 8 | [ push: in token ] bind: tempgen6 9 | [ push: expr apply ] bind: tempgen7 10 | [ pushf: tempgen7 out ] bind: tempgen8 11 | [ push: } token ] bind: tempgen9 12 | [ pushf: tempgen0 pushf: tempgen2 pushf: tempgen3 pushf: tempgen5 pushf: tempgen6 pushf: tempgen8 pushf: tempgen9 ] bind: tempgen10 13 | [ newfunc0 14 | pushf: tempgen10 and func_return ] bind: flpcg.rules.list_comp_var 15 | [ push: list_comp_var apply ] bind: tempgen11 16 | [ push: make_dict apply ] bind: tempgen12 17 | [ push: make_resizable apply ] bind: tempgen13 18 | [ push: forth apply ] bind: tempgen14 19 | [ push: func_call apply ] bind: tempgen15 20 | [ push: name_quote apply ] bind: tempgen16 21 | [ push: quote apply ] bind: tempgen17 22 | [ push: parenthesis apply ] bind: tempgen18 23 | [ push: NUMBER apply ] bind: tempgen19 24 | [ push: TRIPLE_QUOTE apply ] bind: tempgen20 25 | [ push: STRING apply ] bind: tempgen21 26 | [ push: variable apply ] bind: tempgen22 27 | [ pushf: tempgen11 pushf: tempgen12 pushf: tempgen13 pushf: tempgen14 pushf: tempgen15 pushf: tempgen16 pushf: tempgen17 pushf: tempgen18 pushf: tempgen19 pushf: tempgen20 pushf: tempgen21 pushf: tempgen22 ] bind: tempgen23 28 | [ newfunc0 29 | pushf: tempgen23 or func_return ] bind: flpcg.rules.non_block_non_infix 30 | push: list_comp_var pick: flpcg.rules.list_comp_var pick: flpcg.rules hashtable.set 31 | push: non_block_non_infix pick: flpcg.rules.non_block_non_infix pick: flpcg.rules hashtable.set -------------------------------------------------------------------------------- /gen/list_comp_syntax.f.pos_map: -------------------------------------------------------------------------------- 1 | 1 gen/list_comp_syntax.f 2 | 0 gen/list_comp_syntax.flpc 52 64 3 | 3 gen/list_comp_syntax.flpc 59 62 4 | 9 gen/list_comp_syntax.flpc 59 62 5 | 11 gen/list_comp_syntax.flpc 53 63 6 | 17 gen/list_comp_syntax.flpc 52 64 7 | 19 gen/list_comp_syntax.flpc 52 64 8 | 25 gen/list_comp_syntax.flpc 52 64 9 | 34 gen/list_comp_syntax.flpc 70 85 10 | 37 gen/list_comp_syntax.flpc 77 83 11 | 43 gen/list_comp_syntax.flpc 77 83 12 | 48 gen/list_comp_syntax.flpc 71 84 13 | 54 gen/list_comp_syntax.flpc 70 85 14 | 56 gen/list_comp_syntax.flpc 70 85 15 | 62 gen/list_comp_syntax.flpc 70 85 16 | 71 gen/list_comp_syntax.flpc 65 87 17 | 74 gen/list_comp_syntax.flpc 70 85 18 | 81 gen/list_comp_syntax.flpc 70 85 19 | 90 gen/list_comp_syntax.flpc 66 86 20 | 94 gen/list_comp_syntax.flpc 65 87 21 | 96 gen/list_comp_syntax.flpc 65 87 22 | 102 gen/list_comp_syntax.flpc 65 87 23 | 111 gen/list_comp_syntax.flpc 88 102 24 | 114 gen/list_comp_syntax.flpc 95 100 25 | 120 gen/list_comp_syntax.flpc 95 100 26 | 124 gen/list_comp_syntax.flpc 89 101 27 | 130 gen/list_comp_syntax.flpc 88 102 28 | 132 gen/list_comp_syntax.flpc 88 102 29 | 138 gen/list_comp_syntax.flpc 88 102 30 | 147 gen/list_comp_syntax.flpc 108 123 31 | 150 gen/list_comp_syntax.flpc 115 121 32 | 156 gen/list_comp_syntax.flpc 115 121 33 | 161 gen/list_comp_syntax.flpc 109 122 34 | 167 gen/list_comp_syntax.flpc 108 123 35 | 169 gen/list_comp_syntax.flpc 108 123 36 | 175 gen/list_comp_syntax.flpc 108 123 37 | 184 gen/list_comp_syntax.flpc 103 125 38 | 187 gen/list_comp_syntax.flpc 108 123 39 | 194 gen/list_comp_syntax.flpc 108 123 40 | 203 gen/list_comp_syntax.flpc 104 124 41 | 207 gen/list_comp_syntax.flpc 103 125 42 | 209 gen/list_comp_syntax.flpc 103 125 43 | 215 gen/list_comp_syntax.flpc 103 125 44 | 224 gen/list_comp_syntax.flpc 126 139 45 | 227 gen/list_comp_syntax.flpc 133 137 46 | 233 gen/list_comp_syntax.flpc 133 137 47 | 236 gen/list_comp_syntax.flpc 127 138 48 | 242 gen/list_comp_syntax.flpc 126 139 49 | 244 gen/list_comp_syntax.flpc 126 139 50 | 250 gen/list_comp_syntax.flpc 126 139 51 | 259 gen/list_comp_syntax.flpc 145 160 52 | 262 gen/list_comp_syntax.flpc 152 158 53 | 268 gen/list_comp_syntax.flpc 152 158 54 | 273 gen/list_comp_syntax.flpc 146 159 55 | 279 gen/list_comp_syntax.flpc 145 160 56 | 281 gen/list_comp_syntax.flpc 145 160 57 | 287 gen/list_comp_syntax.flpc 145 160 58 | 296 gen/list_comp_syntax.flpc 140 162 59 | 299 gen/list_comp_syntax.flpc 145 160 60 | 306 gen/list_comp_syntax.flpc 145 160 61 | 315 gen/list_comp_syntax.flpc 141 161 62 | 319 gen/list_comp_syntax.flpc 140 162 63 | 321 gen/list_comp_syntax.flpc 140 162 64 | 327 gen/list_comp_syntax.flpc 140 162 65 | 336 gen/list_comp_syntax.flpc 163 175 66 | 339 gen/list_comp_syntax.flpc 170 173 67 | 345 gen/list_comp_syntax.flpc 170 173 68 | 347 gen/list_comp_syntax.flpc 164 174 69 | 353 gen/list_comp_syntax.flpc 163 175 70 | 355 gen/list_comp_syntax.flpc 163 175 71 | 361 gen/list_comp_syntax.flpc 163 175 72 | 370 gen/list_comp_syntax.flpc 51 176 73 | 373 gen/list_comp_syntax.flpc 52 64 74 | 380 gen/list_comp_syntax.flpc 52 64 75 | 389 gen/list_comp_syntax.flpc 65 87 76 | 396 gen/list_comp_syntax.flpc 65 87 77 | 405 gen/list_comp_syntax.flpc 88 102 78 | 412 gen/list_comp_syntax.flpc 88 102 79 | 421 gen/list_comp_syntax.flpc 103 125 80 | 428 gen/list_comp_syntax.flpc 103 125 81 | 437 gen/list_comp_syntax.flpc 126 139 82 | 444 gen/list_comp_syntax.flpc 126 139 83 | 453 gen/list_comp_syntax.flpc 140 162 84 | 460 gen/list_comp_syntax.flpc 140 162 85 | 469 gen/list_comp_syntax.flpc 163 175 86 | 476 gen/list_comp_syntax.flpc 163 175 87 | 485 gen/list_comp_syntax.flpc 51 176 88 | 487 gen/list_comp_syntax.flpc 51 176 89 | 493 gen/list_comp_syntax.flpc 51 176 90 | 503 gen/list_comp_syntax.flpc 28 178 91 | 506 gen/list_comp_syntax.flpc 32 34 92 | 515 gen/list_comp_syntax.flpc 51 176 93 | 524 gen/list_comp_syntax.flpc 51 176 94 | 534 gen/list_comp_syntax.flpc 47 177 95 | 538 gen/list_comp_syntax.flpc 40 178 96 | 550 gen/list_comp_syntax.flpc 28 178 97 | 552 gen/list_comp_syntax.flpc 28 178 98 | 558 gen/list_comp_syntax.flpc 28 178 99 | 584 gen/list_comp_syntax.flpc 237 261 100 | 587 gen/list_comp_syntax.flpc 244 259 101 | 593 gen/list_comp_syntax.flpc 244 259 102 | 607 gen/list_comp_syntax.flpc 238 260 103 | 613 gen/list_comp_syntax.flpc 237 261 104 | 615 gen/list_comp_syntax.flpc 237 261 105 | 621 gen/list_comp_syntax.flpc 237 261 106 | 631 gen/list_comp_syntax.flpc 262 282 107 | 634 gen/list_comp_syntax.flpc 269 280 108 | 640 gen/list_comp_syntax.flpc 269 280 109 | 650 gen/list_comp_syntax.flpc 263 281 110 | 656 gen/list_comp_syntax.flpc 262 282 111 | 658 gen/list_comp_syntax.flpc 262 282 112 | 664 gen/list_comp_syntax.flpc 262 282 113 | 674 gen/list_comp_syntax.flpc 283 308 114 | 677 gen/list_comp_syntax.flpc 290 306 115 | 683 gen/list_comp_syntax.flpc 290 306 116 | 698 gen/list_comp_syntax.flpc 284 307 117 | 704 gen/list_comp_syntax.flpc 283 308 118 | 706 gen/list_comp_syntax.flpc 283 308 119 | 712 gen/list_comp_syntax.flpc 283 308 120 | 722 gen/list_comp_syntax.flpc 309 325 121 | 725 gen/list_comp_syntax.flpc 316 323 122 | 731 gen/list_comp_syntax.flpc 316 323 123 | 737 gen/list_comp_syntax.flpc 310 324 124 | 743 gen/list_comp_syntax.flpc 309 325 125 | 745 gen/list_comp_syntax.flpc 309 325 126 | 751 gen/list_comp_syntax.flpc 309 325 127 | 761 gen/list_comp_syntax.flpc 326 346 128 | 764 gen/list_comp_syntax.flpc 333 344 129 | 770 gen/list_comp_syntax.flpc 333 344 130 | 780 gen/list_comp_syntax.flpc 327 345 131 | 786 gen/list_comp_syntax.flpc 326 346 132 | 788 gen/list_comp_syntax.flpc 326 346 133 | 794 gen/list_comp_syntax.flpc 326 346 134 | 804 gen/list_comp_syntax.flpc 347 368 135 | 807 gen/list_comp_syntax.flpc 354 366 136 | 813 gen/list_comp_syntax.flpc 354 366 137 | 824 gen/list_comp_syntax.flpc 348 367 138 | 830 gen/list_comp_syntax.flpc 347 368 139 | 832 gen/list_comp_syntax.flpc 347 368 140 | 838 gen/list_comp_syntax.flpc 347 368 141 | 848 gen/list_comp_syntax.flpc 369 385 142 | 851 gen/list_comp_syntax.flpc 376 383 143 | 857 gen/list_comp_syntax.flpc 376 383 144 | 863 gen/list_comp_syntax.flpc 370 384 145 | 869 gen/list_comp_syntax.flpc 369 385 146 | 871 gen/list_comp_syntax.flpc 369 385 147 | 877 gen/list_comp_syntax.flpc 369 385 148 | 887 gen/list_comp_syntax.flpc 386 408 149 | 890 gen/list_comp_syntax.flpc 393 406 150 | 896 gen/list_comp_syntax.flpc 393 406 151 | 908 gen/list_comp_syntax.flpc 387 407 152 | 914 gen/list_comp_syntax.flpc 386 408 153 | 916 gen/list_comp_syntax.flpc 386 408 154 | 922 gen/list_comp_syntax.flpc 386 408 155 | 932 gen/list_comp_syntax.flpc 409 426 156 | 935 gen/list_comp_syntax.flpc 416 424 157 | 941 gen/list_comp_syntax.flpc 416 424 158 | 948 gen/list_comp_syntax.flpc 410 425 159 | 954 gen/list_comp_syntax.flpc 409 426 160 | 956 gen/list_comp_syntax.flpc 409 426 161 | 962 gen/list_comp_syntax.flpc 409 426 162 | 972 gen/list_comp_syntax.flpc 427 450 163 | 975 gen/list_comp_syntax.flpc 434 448 164 | 981 gen/list_comp_syntax.flpc 434 448 165 | 994 gen/list_comp_syntax.flpc 428 449 166 | 1000 gen/list_comp_syntax.flpc 427 450 167 | 1002 gen/list_comp_syntax.flpc 427 450 168 | 1008 gen/list_comp_syntax.flpc 427 450 169 | 1018 gen/list_comp_syntax.flpc 451 468 170 | 1021 gen/list_comp_syntax.flpc 458 466 171 | 1027 gen/list_comp_syntax.flpc 458 466 172 | 1034 gen/list_comp_syntax.flpc 452 467 173 | 1040 gen/list_comp_syntax.flpc 451 468 174 | 1042 gen/list_comp_syntax.flpc 451 468 175 | 1048 gen/list_comp_syntax.flpc 451 468 176 | 1058 gen/list_comp_syntax.flpc 469 488 177 | 1061 gen/list_comp_syntax.flpc 476 486 178 | 1067 gen/list_comp_syntax.flpc 476 486 179 | 1076 gen/list_comp_syntax.flpc 470 487 180 | 1082 gen/list_comp_syntax.flpc 469 488 181 | 1084 gen/list_comp_syntax.flpc 469 488 182 | 1090 gen/list_comp_syntax.flpc 469 488 183 | 1100 gen/list_comp_syntax.flpc 236 489 184 | 1103 gen/list_comp_syntax.flpc 237 261 185 | 1110 gen/list_comp_syntax.flpc 237 261 186 | 1120 gen/list_comp_syntax.flpc 262 282 187 | 1127 gen/list_comp_syntax.flpc 262 282 188 | 1137 gen/list_comp_syntax.flpc 283 308 189 | 1144 gen/list_comp_syntax.flpc 283 308 190 | 1154 gen/list_comp_syntax.flpc 309 325 191 | 1161 gen/list_comp_syntax.flpc 309 325 192 | 1171 gen/list_comp_syntax.flpc 326 346 193 | 1178 gen/list_comp_syntax.flpc 326 346 194 | 1188 gen/list_comp_syntax.flpc 347 368 195 | 1195 gen/list_comp_syntax.flpc 347 368 196 | 1205 gen/list_comp_syntax.flpc 369 385 197 | 1212 gen/list_comp_syntax.flpc 369 385 198 | 1222 gen/list_comp_syntax.flpc 386 408 199 | 1229 gen/list_comp_syntax.flpc 386 408 200 | 1239 gen/list_comp_syntax.flpc 409 426 201 | 1246 gen/list_comp_syntax.flpc 409 426 202 | 1256 gen/list_comp_syntax.flpc 427 450 203 | 1263 gen/list_comp_syntax.flpc 427 450 204 | 1273 gen/list_comp_syntax.flpc 451 468 205 | 1280 gen/list_comp_syntax.flpc 451 468 206 | 1290 gen/list_comp_syntax.flpc 469 488 207 | 1297 gen/list_comp_syntax.flpc 469 488 208 | 1307 gen/list_comp_syntax.flpc 236 489 209 | 1309 gen/list_comp_syntax.flpc 236 489 210 | 1315 gen/list_comp_syntax.flpc 236 489 211 | 1325 gen/list_comp_syntax.flpc 214 491 212 | 1328 gen/list_comp_syntax.flpc 218 220 213 | 1337 gen/list_comp_syntax.flpc 236 489 214 | 1346 gen/list_comp_syntax.flpc 236 489 215 | 1356 gen/list_comp_syntax.flpc 233 490 216 | 1359 gen/list_comp_syntax.flpc 226 491 217 | 1371 gen/list_comp_syntax.flpc 214 491 218 | 1373 gen/list_comp_syntax.flpc 214 491 219 | 1379 gen/list_comp_syntax.flpc 214 491 220 | 1411 gen/list_comp_syntax.flpc 507 522 221 | 1418 gen/list_comp_syntax.flpc 507 522 222 | 1432 gen/list_comp_syntax.flpc 523 548 223 | 1438 gen/list_comp_syntax.flpc 523 548 224 | 1464 gen/list_comp_syntax.flpc 549 560 225 | 1470 gen/list_comp_syntax.flpc 549 560 226 | 1482 gen/list_comp_syntax.flpc 493 561 227 | 1496 gen/list_comp_syntax.flpc 576 597 228 | 1503 gen/list_comp_syntax.flpc 576 597 229 | 1523 gen/list_comp_syntax.flpc 598 629 230 | 1529 gen/list_comp_syntax.flpc 598 629 231 | 1561 gen/list_comp_syntax.flpc 630 641 232 | 1567 gen/list_comp_syntax.flpc 630 641 233 | 1579 gen/list_comp_syntax.flpc 562 642 234 | -------------------------------------------------------------------------------- /gen/resizable_syntax.f: -------------------------------------------------------------------------------- 1 | 2 | [ push: { token ] bind: tempgen0 3 | [ push: spaces apply ] bind: tempgen1 4 | [ push: expr apply ] bind: tempgen2 5 | [ push: spacesp apply ] bind: tempgen3 6 | [ push: expr apply ] bind: tempgen4 7 | [ pushf: tempgen4 out ] bind: tempgen5 8 | [ pushf: tempgen3 pushf: tempgen5 ] bind: tempgen6 9 | [ pushf: tempgen6 and ] bind: tempgen7 10 | [ pushf: tempgen7 push: * quantified ] bind: tempgen8 11 | [ pushf: tempgen2 pushf: tempgen8 ] bind: tempgen9 12 | [ pushf: tempgen9 and ] bind: tempgen10 13 | [ push: void apply ] bind: tempgen11 14 | [ pushf: tempgen10 pushf: tempgen11 ] bind: tempgen12 15 | [ pushf: tempgen12 or ] bind: tempgen13 16 | [ pushf: tempgen13 out ] bind: tempgen14 17 | [ push: } token ] bind: tempgen15 18 | [ pushf: tempgen0 pushf: tempgen1 pushf: tempgen14 pushf: tempgen15 ] bind: tempgen16 19 | [ newfunc0 20 | pushf: tempgen16 and func_return ] bind: flpcg.rules.make_resizable 21 | [ push: { token ] bind: tempgen17 22 | [ push: spaces apply ] bind: tempgen18 23 | [ push: expr apply ] bind: tempgen19 24 | [ pushf: tempgen19 out ] bind: tempgen20 25 | [ push: : token ] bind: tempgen21 26 | [ push: expr apply ] bind: tempgen22 27 | [ pushf: tempgen22 out ] bind: tempgen23 28 | [ push: , token ] bind: tempgen24 29 | [ push: spaces apply ] bind: tempgen25 30 | [ push: expr apply ] bind: tempgen26 31 | [ pushf: tempgen26 out ] bind: tempgen27 32 | [ push: : token ] bind: tempgen28 33 | [ push: expr apply ] bind: tempgen29 34 | [ pushf: tempgen29 out ] bind: tempgen30 35 | [ pushf: tempgen24 pushf: tempgen25 pushf: tempgen27 pushf: tempgen28 pushf: tempgen30 ] bind: tempgen31 36 | [ pushf: tempgen31 and ] bind: tempgen32 37 | [ pushf: tempgen32 push: * quantified ] bind: tempgen33 38 | [ pushf: tempgen33 out ] bind: tempgen34 39 | [ push: | token ] bind: tempgen35 40 | [ push: expr apply ] bind: tempgen36 41 | [ pushf: tempgen36 out ] bind: tempgen37 42 | [ push: } token ] bind: tempgen38 43 | [ pushf: tempgen17 pushf: tempgen18 pushf: tempgen20 pushf: tempgen21 pushf: tempgen23 pushf: tempgen34 pushf: tempgen35 pushf: tempgen37 pushf: tempgen38 ] bind: tempgen39 44 | [ newfunc0 45 | pushf: tempgen39 and func_return ] bind: flpcg.rules.make_dict 46 | [ push: make_dict apply ] bind: tempgen40 47 | [ push: make_resizable apply ] bind: tempgen41 48 | [ push: forth apply ] bind: tempgen42 49 | [ push: func_call apply ] bind: tempgen43 50 | [ push: name_quote apply ] bind: tempgen44 51 | [ push: quote apply ] bind: tempgen45 52 | [ push: parenthesis apply ] bind: tempgen46 53 | [ push: NUMBER apply ] bind: tempgen47 54 | [ push: TRIPLE_QUOTE apply ] bind: tempgen48 55 | [ push: STRING apply ] bind: tempgen49 56 | [ push: variable apply ] bind: tempgen50 57 | [ pushf: tempgen40 pushf: tempgen41 pushf: tempgen42 pushf: tempgen43 pushf: tempgen44 pushf: tempgen45 pushf: tempgen46 pushf: tempgen47 pushf: tempgen48 pushf: tempgen49 pushf: tempgen50 ] bind: tempgen51 58 | [ newfunc0 59 | pushf: tempgen51 or func_return ] bind: flpcg.rules.non_block_non_infix 60 | push: make_resizable pick: flpcg.rules.make_resizable pick: flpcg.rules hashtable.set 61 | push: make_resizable pick: flpcg.flagged attr_call: append 62 | push: make_dict pick: flpcg.rules.make_dict pick: flpcg.rules hashtable.set 63 | push: make_dict pick: flpcg.flagged attr_call: append 64 | push: non_block_non_infix pick: flpcg.rules.non_block_non_infix pick: flpcg.rules hashtable.set -------------------------------------------------------------------------------- /gen/resizable_syntax.f.pos_map: -------------------------------------------------------------------------------- 1 | 1 gen/resizable_syntax.f 2 | 0 gen/resizable_syntax.flpc 53 65 3 | 3 gen/resizable_syntax.flpc 60 63 4 | 9 gen/resizable_syntax.flpc 60 63 5 | 11 gen/resizable_syntax.flpc 54 64 6 | 17 gen/resizable_syntax.flpc 53 65 7 | 19 gen/resizable_syntax.flpc 53 65 8 | 25 gen/resizable_syntax.flpc 53 65 9 | 34 gen/resizable_syntax.flpc 66 83 10 | 37 gen/resizable_syntax.flpc 73 81 11 | 43 gen/resizable_syntax.flpc 73 81 12 | 50 gen/resizable_syntax.flpc 67 82 13 | 56 gen/resizable_syntax.flpc 66 83 14 | 58 gen/resizable_syntax.flpc 66 83 15 | 64 gen/resizable_syntax.flpc 66 83 16 | 73 gen/resizable_syntax.flpc 100 115 17 | 76 gen/resizable_syntax.flpc 107 113 18 | 82 gen/resizable_syntax.flpc 107 113 19 | 87 gen/resizable_syntax.flpc 101 114 20 | 93 gen/resizable_syntax.flpc 100 115 21 | 95 gen/resizable_syntax.flpc 100 115 22 | 101 gen/resizable_syntax.flpc 100 115 23 | 110 gen/resizable_syntax.flpc 134 152 24 | 113 gen/resizable_syntax.flpc 141 150 25 | 119 gen/resizable_syntax.flpc 141 150 26 | 127 gen/resizable_syntax.flpc 135 151 27 | 133 gen/resizable_syntax.flpc 134 152 28 | 135 gen/resizable_syntax.flpc 134 152 29 | 141 gen/resizable_syntax.flpc 134 152 30 | 150 gen/resizable_syntax.flpc 158 173 31 | 153 gen/resizable_syntax.flpc 165 171 32 | 159 gen/resizable_syntax.flpc 165 171 33 | 164 gen/resizable_syntax.flpc 159 172 34 | 170 gen/resizable_syntax.flpc 158 173 35 | 172 gen/resizable_syntax.flpc 158 173 36 | 178 gen/resizable_syntax.flpc 158 173 37 | 187 gen/resizable_syntax.flpc 153 175 38 | 190 gen/resizable_syntax.flpc 158 173 39 | 197 gen/resizable_syntax.flpc 158 173 40 | 206 gen/resizable_syntax.flpc 154 174 41 | 210 gen/resizable_syntax.flpc 153 175 42 | 212 gen/resizable_syntax.flpc 153 175 43 | 218 gen/resizable_syntax.flpc 153 175 44 | 227 gen/resizable_syntax.flpc 133 176 45 | 230 gen/resizable_syntax.flpc 134 152 46 | 237 gen/resizable_syntax.flpc 134 152 47 | 246 gen/resizable_syntax.flpc 153 175 48 | 253 gen/resizable_syntax.flpc 153 175 49 | 262 gen/resizable_syntax.flpc 133 176 50 | 264 gen/resizable_syntax.flpc 133 176 51 | 270 gen/resizable_syntax.flpc 133 176 52 | 279 gen/resizable_syntax.flpc 128 178 53 | 282 gen/resizable_syntax.flpc 133 176 54 | 289 gen/resizable_syntax.flpc 133 176 55 | 298 gen/resizable_syntax.flpc 129 177 56 | 302 gen/resizable_syntax.flpc 128 178 57 | 304 gen/resizable_syntax.flpc 128 178 58 | 310 gen/resizable_syntax.flpc 128 178 59 | 319 gen/resizable_syntax.flpc 116 184 60 | 322 gen/resizable_syntax.flpc 128 178 61 | 329 gen/resizable_syntax.flpc 128 178 62 | 338 gen/resizable_syntax.flpc 179 182 63 | 344 gen/resizable_syntax.flpc 179 182 64 | 346 gen/resizable_syntax.flpc 117 183 65 | 357 gen/resizable_syntax.flpc 116 184 66 | 359 gen/resizable_syntax.flpc 116 184 67 | 365 gen/resizable_syntax.flpc 116 184 68 | 374 gen/resizable_syntax.flpc 99 185 69 | 377 gen/resizable_syntax.flpc 100 115 70 | 384 gen/resizable_syntax.flpc 100 115 71 | 393 gen/resizable_syntax.flpc 116 184 72 | 400 gen/resizable_syntax.flpc 116 184 73 | 409 gen/resizable_syntax.flpc 99 185 74 | 411 gen/resizable_syntax.flpc 99 185 75 | 417 gen/resizable_syntax.flpc 99 185 76 | 426 gen/resizable_syntax.flpc 94 187 77 | 429 gen/resizable_syntax.flpc 99 185 78 | 436 gen/resizable_syntax.flpc 99 185 79 | 445 gen/resizable_syntax.flpc 95 186 80 | 449 gen/resizable_syntax.flpc 94 187 81 | 451 gen/resizable_syntax.flpc 94 187 82 | 457 gen/resizable_syntax.flpc 94 187 83 | 467 gen/resizable_syntax.flpc 188 203 84 | 470 gen/resizable_syntax.flpc 195 201 85 | 476 gen/resizable_syntax.flpc 195 201 86 | 481 gen/resizable_syntax.flpc 189 202 87 | 487 gen/resizable_syntax.flpc 188 203 88 | 489 gen/resizable_syntax.flpc 188 203 89 | 495 gen/resizable_syntax.flpc 188 203 90 | 505 gen/resizable_syntax.flpc 93 204 91 | 508 gen/resizable_syntax.flpc 94 187 92 | 515 gen/resizable_syntax.flpc 94 187 93 | 525 gen/resizable_syntax.flpc 188 203 94 | 532 gen/resizable_syntax.flpc 188 203 95 | 542 gen/resizable_syntax.flpc 93 204 96 | 544 gen/resizable_syntax.flpc 93 204 97 | 550 gen/resizable_syntax.flpc 93 204 98 | 560 gen/resizable_syntax.flpc 89 206 99 | 563 gen/resizable_syntax.flpc 93 204 100 | 570 gen/resizable_syntax.flpc 93 204 101 | 580 gen/resizable_syntax.flpc 90 205 102 | 583 gen/resizable_syntax.flpc 89 206 103 | 585 gen/resizable_syntax.flpc 89 206 104 | 591 gen/resizable_syntax.flpc 89 206 105 | 601 gen/resizable_syntax.flpc 84 208 106 | 604 gen/resizable_syntax.flpc 89 206 107 | 611 gen/resizable_syntax.flpc 89 206 108 | 621 gen/resizable_syntax.flpc 85 207 109 | 625 gen/resizable_syntax.flpc 84 208 110 | 627 gen/resizable_syntax.flpc 84 208 111 | 633 gen/resizable_syntax.flpc 84 208 112 | 643 gen/resizable_syntax.flpc 209 221 113 | 646 gen/resizable_syntax.flpc 216 219 114 | 652 gen/resizable_syntax.flpc 216 219 115 | 654 gen/resizable_syntax.flpc 210 220 116 | 660 gen/resizable_syntax.flpc 209 221 117 | 662 gen/resizable_syntax.flpc 209 221 118 | 668 gen/resizable_syntax.flpc 209 221 119 | 678 gen/resizable_syntax.flpc 52 222 120 | 681 gen/resizable_syntax.flpc 53 65 121 | 688 gen/resizable_syntax.flpc 53 65 122 | 697 gen/resizable_syntax.flpc 66 83 123 | 704 gen/resizable_syntax.flpc 66 83 124 | 713 gen/resizable_syntax.flpc 84 208 125 | 720 gen/resizable_syntax.flpc 84 208 126 | 730 gen/resizable_syntax.flpc 209 221 127 | 737 gen/resizable_syntax.flpc 209 221 128 | 747 gen/resizable_syntax.flpc 52 222 129 | 749 gen/resizable_syntax.flpc 52 222 130 | 755 gen/resizable_syntax.flpc 52 222 131 | 765 gen/resizable_syntax.flpc 29 224 132 | 768 gen/resizable_syntax.flpc 33 35 133 | 777 gen/resizable_syntax.flpc 52 222 134 | 786 gen/resizable_syntax.flpc 52 222 135 | 796 gen/resizable_syntax.flpc 48 223 136 | 800 gen/resizable_syntax.flpc 41 224 137 | 812 gen/resizable_syntax.flpc 29 224 138 | 814 gen/resizable_syntax.flpc 29 224 139 | 820 gen/resizable_syntax.flpc 29 224 140 | 847 gen/resizable_syntax.flpc 274 286 141 | 850 gen/resizable_syntax.flpc 281 284 142 | 856 gen/resizable_syntax.flpc 281 284 143 | 858 gen/resizable_syntax.flpc 275 285 144 | 864 gen/resizable_syntax.flpc 274 286 145 | 866 gen/resizable_syntax.flpc 274 286 146 | 872 gen/resizable_syntax.flpc 274 286 147 | 882 gen/resizable_syntax.flpc 287 304 148 | 885 gen/resizable_syntax.flpc 294 302 149 | 891 gen/resizable_syntax.flpc 294 302 150 | 898 gen/resizable_syntax.flpc 288 303 151 | 904 gen/resizable_syntax.flpc 287 304 152 | 906 gen/resizable_syntax.flpc 287 304 153 | 912 gen/resizable_syntax.flpc 287 304 154 | 922 gen/resizable_syntax.flpc 310 325 155 | 925 gen/resizable_syntax.flpc 317 323 156 | 931 gen/resizable_syntax.flpc 317 323 157 | 936 gen/resizable_syntax.flpc 311 324 158 | 942 gen/resizable_syntax.flpc 310 325 159 | 944 gen/resizable_syntax.flpc 310 325 160 | 950 gen/resizable_syntax.flpc 310 325 161 | 960 gen/resizable_syntax.flpc 305 327 162 | 963 gen/resizable_syntax.flpc 310 325 163 | 970 gen/resizable_syntax.flpc 310 325 164 | 980 gen/resizable_syntax.flpc 306 326 165 | 984 gen/resizable_syntax.flpc 305 327 166 | 986 gen/resizable_syntax.flpc 305 327 167 | 992 gen/resizable_syntax.flpc 305 327 168 | 1002 gen/resizable_syntax.flpc 328 340 169 | 1005 gen/resizable_syntax.flpc 335 338 170 | 1011 gen/resizable_syntax.flpc 335 338 171 | 1013 gen/resizable_syntax.flpc 329 339 172 | 1019 gen/resizable_syntax.flpc 328 340 173 | 1021 gen/resizable_syntax.flpc 328 340 174 | 1027 gen/resizable_syntax.flpc 328 340 175 | 1037 gen/resizable_syntax.flpc 346 361 176 | 1040 gen/resizable_syntax.flpc 353 359 177 | 1046 gen/resizable_syntax.flpc 353 359 178 | 1051 gen/resizable_syntax.flpc 347 360 179 | 1057 gen/resizable_syntax.flpc 346 361 180 | 1059 gen/resizable_syntax.flpc 346 361 181 | 1065 gen/resizable_syntax.flpc 346 361 182 | 1075 gen/resizable_syntax.flpc 341 363 183 | 1078 gen/resizable_syntax.flpc 346 361 184 | 1085 gen/resizable_syntax.flpc 346 361 185 | 1095 gen/resizable_syntax.flpc 342 362 186 | 1099 gen/resizable_syntax.flpc 341 363 187 | 1101 gen/resizable_syntax.flpc 341 363 188 | 1107 gen/resizable_syntax.flpc 341 363 189 | 1117 gen/resizable_syntax.flpc 387 399 190 | 1120 gen/resizable_syntax.flpc 394 397 191 | 1126 gen/resizable_syntax.flpc 394 397 192 | 1128 gen/resizable_syntax.flpc 388 398 193 | 1134 gen/resizable_syntax.flpc 387 399 194 | 1136 gen/resizable_syntax.flpc 387 399 195 | 1142 gen/resizable_syntax.flpc 387 399 196 | 1152 gen/resizable_syntax.flpc 400 417 197 | 1155 gen/resizable_syntax.flpc 407 415 198 | 1161 gen/resizable_syntax.flpc 407 415 199 | 1168 gen/resizable_syntax.flpc 401 416 200 | 1174 gen/resizable_syntax.flpc 400 417 201 | 1176 gen/resizable_syntax.flpc 400 417 202 | 1182 gen/resizable_syntax.flpc 400 417 203 | 1192 gen/resizable_syntax.flpc 423 438 204 | 1195 gen/resizable_syntax.flpc 430 436 205 | 1201 gen/resizable_syntax.flpc 430 436 206 | 1206 gen/resizable_syntax.flpc 424 437 207 | 1212 gen/resizable_syntax.flpc 423 438 208 | 1214 gen/resizable_syntax.flpc 423 438 209 | 1220 gen/resizable_syntax.flpc 423 438 210 | 1230 gen/resizable_syntax.flpc 418 440 211 | 1233 gen/resizable_syntax.flpc 423 438 212 | 1240 gen/resizable_syntax.flpc 423 438 213 | 1250 gen/resizable_syntax.flpc 419 439 214 | 1254 gen/resizable_syntax.flpc 418 440 215 | 1256 gen/resizable_syntax.flpc 418 440 216 | 1262 gen/resizable_syntax.flpc 418 440 217 | 1272 gen/resizable_syntax.flpc 441 453 218 | 1275 gen/resizable_syntax.flpc 448 451 219 | 1281 gen/resizable_syntax.flpc 448 451 220 | 1283 gen/resizable_syntax.flpc 442 452 221 | 1289 gen/resizable_syntax.flpc 441 453 222 | 1291 gen/resizable_syntax.flpc 441 453 223 | 1297 gen/resizable_syntax.flpc 441 453 224 | 1307 gen/resizable_syntax.flpc 459 474 225 | 1310 gen/resizable_syntax.flpc 466 472 226 | 1316 gen/resizable_syntax.flpc 466 472 227 | 1321 gen/resizable_syntax.flpc 460 473 228 | 1327 gen/resizable_syntax.flpc 459 474 229 | 1329 gen/resizable_syntax.flpc 459 474 230 | 1335 gen/resizable_syntax.flpc 459 474 231 | 1345 gen/resizable_syntax.flpc 454 476 232 | 1348 gen/resizable_syntax.flpc 459 474 233 | 1355 gen/resizable_syntax.flpc 459 474 234 | 1365 gen/resizable_syntax.flpc 455 475 235 | 1369 gen/resizable_syntax.flpc 454 476 236 | 1371 gen/resizable_syntax.flpc 454 476 237 | 1377 gen/resizable_syntax.flpc 454 476 238 | 1387 gen/resizable_syntax.flpc 386 477 239 | 1390 gen/resizable_syntax.flpc 387 399 240 | 1397 gen/resizable_syntax.flpc 387 399 241 | 1407 gen/resizable_syntax.flpc 400 417 242 | 1414 gen/resizable_syntax.flpc 400 417 243 | 1424 gen/resizable_syntax.flpc 418 440 244 | 1431 gen/resizable_syntax.flpc 418 440 245 | 1441 gen/resizable_syntax.flpc 441 453 246 | 1448 gen/resizable_syntax.flpc 441 453 247 | 1458 gen/resizable_syntax.flpc 454 476 248 | 1465 gen/resizable_syntax.flpc 454 476 249 | 1475 gen/resizable_syntax.flpc 386 477 250 | 1477 gen/resizable_syntax.flpc 386 477 251 | 1483 gen/resizable_syntax.flpc 386 477 252 | 1493 gen/resizable_syntax.flpc 381 479 253 | 1496 gen/resizable_syntax.flpc 386 477 254 | 1503 gen/resizable_syntax.flpc 386 477 255 | 1513 gen/resizable_syntax.flpc 382 478 256 | 1517 gen/resizable_syntax.flpc 381 479 257 | 1519 gen/resizable_syntax.flpc 381 479 258 | 1525 gen/resizable_syntax.flpc 381 479 259 | 1535 gen/resizable_syntax.flpc 369 485 260 | 1538 gen/resizable_syntax.flpc 381 479 261 | 1545 gen/resizable_syntax.flpc 381 479 262 | 1555 gen/resizable_syntax.flpc 480 483 263 | 1561 gen/resizable_syntax.flpc 480 483 264 | 1563 gen/resizable_syntax.flpc 370 484 265 | 1574 gen/resizable_syntax.flpc 369 485 266 | 1576 gen/resizable_syntax.flpc 369 485 267 | 1582 gen/resizable_syntax.flpc 369 485 268 | 1592 gen/resizable_syntax.flpc 364 487 269 | 1595 gen/resizable_syntax.flpc 369 485 270 | 1602 gen/resizable_syntax.flpc 369 485 271 | 1612 gen/resizable_syntax.flpc 365 486 272 | 1616 gen/resizable_syntax.flpc 364 487 273 | 1618 gen/resizable_syntax.flpc 364 487 274 | 1624 gen/resizable_syntax.flpc 364 487 275 | 1634 gen/resizable_syntax.flpc 488 500 276 | 1637 gen/resizable_syntax.flpc 495 498 277 | 1643 gen/resizable_syntax.flpc 495 498 278 | 1645 gen/resizable_syntax.flpc 489 499 279 | 1651 gen/resizable_syntax.flpc 488 500 280 | 1653 gen/resizable_syntax.flpc 488 500 281 | 1659 gen/resizable_syntax.flpc 488 500 282 | 1669 gen/resizable_syntax.flpc 506 521 283 | 1672 gen/resizable_syntax.flpc 513 519 284 | 1678 gen/resizable_syntax.flpc 513 519 285 | 1683 gen/resizable_syntax.flpc 507 520 286 | 1689 gen/resizable_syntax.flpc 506 521 287 | 1691 gen/resizable_syntax.flpc 506 521 288 | 1697 gen/resizable_syntax.flpc 506 521 289 | 1707 gen/resizable_syntax.flpc 501 523 290 | 1710 gen/resizable_syntax.flpc 506 521 291 | 1717 gen/resizable_syntax.flpc 506 521 292 | 1727 gen/resizable_syntax.flpc 502 522 293 | 1731 gen/resizable_syntax.flpc 501 523 294 | 1733 gen/resizable_syntax.flpc 501 523 295 | 1739 gen/resizable_syntax.flpc 501 523 296 | 1749 gen/resizable_syntax.flpc 524 536 297 | 1752 gen/resizable_syntax.flpc 531 534 298 | 1758 gen/resizable_syntax.flpc 531 534 299 | 1760 gen/resizable_syntax.flpc 525 535 300 | 1766 gen/resizable_syntax.flpc 524 536 301 | 1768 gen/resizable_syntax.flpc 524 536 302 | 1774 gen/resizable_syntax.flpc 524 536 303 | 1784 gen/resizable_syntax.flpc 273 537 304 | 1787 gen/resizable_syntax.flpc 274 286 305 | 1794 gen/resizable_syntax.flpc 274 286 306 | 1804 gen/resizable_syntax.flpc 287 304 307 | 1811 gen/resizable_syntax.flpc 287 304 308 | 1821 gen/resizable_syntax.flpc 305 327 309 | 1828 gen/resizable_syntax.flpc 305 327 310 | 1838 gen/resizable_syntax.flpc 328 340 311 | 1845 gen/resizable_syntax.flpc 328 340 312 | 1855 gen/resizable_syntax.flpc 341 363 313 | 1862 gen/resizable_syntax.flpc 341 363 314 | 1872 gen/resizable_syntax.flpc 364 487 315 | 1879 gen/resizable_syntax.flpc 364 487 316 | 1889 gen/resizable_syntax.flpc 488 500 317 | 1896 gen/resizable_syntax.flpc 488 500 318 | 1906 gen/resizable_syntax.flpc 501 523 319 | 1913 gen/resizable_syntax.flpc 501 523 320 | 1923 gen/resizable_syntax.flpc 524 536 321 | 1930 gen/resizable_syntax.flpc 524 536 322 | 1940 gen/resizable_syntax.flpc 273 537 323 | 1942 gen/resizable_syntax.flpc 273 537 324 | 1948 gen/resizable_syntax.flpc 273 537 325 | 1958 gen/resizable_syntax.flpc 250 539 326 | 1961 gen/resizable_syntax.flpc 254 256 327 | 1970 gen/resizable_syntax.flpc 273 537 328 | 1979 gen/resizable_syntax.flpc 273 537 329 | 1989 gen/resizable_syntax.flpc 269 538 330 | 1993 gen/resizable_syntax.flpc 262 539 331 | 2005 gen/resizable_syntax.flpc 250 539 332 | 2007 gen/resizable_syntax.flpc 250 539 333 | 2013 gen/resizable_syntax.flpc 250 539 334 | 2035 gen/resizable_syntax.flpc 598 618 335 | 2038 gen/resizable_syntax.flpc 605 616 336 | 2044 gen/resizable_syntax.flpc 605 616 337 | 2054 gen/resizable_syntax.flpc 599 617 338 | 2060 gen/resizable_syntax.flpc 598 618 339 | 2062 gen/resizable_syntax.flpc 598 618 340 | 2068 gen/resizable_syntax.flpc 598 618 341 | 2078 gen/resizable_syntax.flpc 619 644 342 | 2081 gen/resizable_syntax.flpc 626 642 343 | 2087 gen/resizable_syntax.flpc 626 642 344 | 2102 gen/resizable_syntax.flpc 620 643 345 | 2108 gen/resizable_syntax.flpc 619 644 346 | 2110 gen/resizable_syntax.flpc 619 644 347 | 2116 gen/resizable_syntax.flpc 619 644 348 | 2126 gen/resizable_syntax.flpc 645 661 349 | 2129 gen/resizable_syntax.flpc 652 659 350 | 2135 gen/resizable_syntax.flpc 652 659 351 | 2141 gen/resizable_syntax.flpc 646 660 352 | 2147 gen/resizable_syntax.flpc 645 661 353 | 2149 gen/resizable_syntax.flpc 645 661 354 | 2155 gen/resizable_syntax.flpc 645 661 355 | 2165 gen/resizable_syntax.flpc 662 682 356 | 2168 gen/resizable_syntax.flpc 669 680 357 | 2174 gen/resizable_syntax.flpc 669 680 358 | 2184 gen/resizable_syntax.flpc 663 681 359 | 2190 gen/resizable_syntax.flpc 662 682 360 | 2192 gen/resizable_syntax.flpc 662 682 361 | 2198 gen/resizable_syntax.flpc 662 682 362 | 2208 gen/resizable_syntax.flpc 683 704 363 | 2211 gen/resizable_syntax.flpc 690 702 364 | 2217 gen/resizable_syntax.flpc 690 702 365 | 2228 gen/resizable_syntax.flpc 684 703 366 | 2234 gen/resizable_syntax.flpc 683 704 367 | 2236 gen/resizable_syntax.flpc 683 704 368 | 2242 gen/resizable_syntax.flpc 683 704 369 | 2252 gen/resizable_syntax.flpc 705 721 370 | 2255 gen/resizable_syntax.flpc 712 719 371 | 2261 gen/resizable_syntax.flpc 712 719 372 | 2267 gen/resizable_syntax.flpc 706 720 373 | 2273 gen/resizable_syntax.flpc 705 721 374 | 2275 gen/resizable_syntax.flpc 705 721 375 | 2281 gen/resizable_syntax.flpc 705 721 376 | 2291 gen/resizable_syntax.flpc 722 744 377 | 2294 gen/resizable_syntax.flpc 729 742 378 | 2300 gen/resizable_syntax.flpc 729 742 379 | 2312 gen/resizable_syntax.flpc 723 743 380 | 2318 gen/resizable_syntax.flpc 722 744 381 | 2320 gen/resizable_syntax.flpc 722 744 382 | 2326 gen/resizable_syntax.flpc 722 744 383 | 2336 gen/resizable_syntax.flpc 745 762 384 | 2339 gen/resizable_syntax.flpc 752 760 385 | 2345 gen/resizable_syntax.flpc 752 760 386 | 2352 gen/resizable_syntax.flpc 746 761 387 | 2358 gen/resizable_syntax.flpc 745 762 388 | 2360 gen/resizable_syntax.flpc 745 762 389 | 2366 gen/resizable_syntax.flpc 745 762 390 | 2376 gen/resizable_syntax.flpc 763 786 391 | 2379 gen/resizable_syntax.flpc 770 784 392 | 2385 gen/resizable_syntax.flpc 770 784 393 | 2398 gen/resizable_syntax.flpc 764 785 394 | 2404 gen/resizable_syntax.flpc 763 786 395 | 2406 gen/resizable_syntax.flpc 763 786 396 | 2412 gen/resizable_syntax.flpc 763 786 397 | 2422 gen/resizable_syntax.flpc 787 804 398 | 2425 gen/resizable_syntax.flpc 794 802 399 | 2431 gen/resizable_syntax.flpc 794 802 400 | 2438 gen/resizable_syntax.flpc 788 803 401 | 2444 gen/resizable_syntax.flpc 787 804 402 | 2446 gen/resizable_syntax.flpc 787 804 403 | 2452 gen/resizable_syntax.flpc 787 804 404 | 2462 gen/resizable_syntax.flpc 805 824 405 | 2465 gen/resizable_syntax.flpc 812 822 406 | 2471 gen/resizable_syntax.flpc 812 822 407 | 2480 gen/resizable_syntax.flpc 806 823 408 | 2486 gen/resizable_syntax.flpc 805 824 409 | 2488 gen/resizable_syntax.flpc 805 824 410 | 2494 gen/resizable_syntax.flpc 805 824 411 | 2504 gen/resizable_syntax.flpc 597 825 412 | 2507 gen/resizable_syntax.flpc 598 618 413 | 2514 gen/resizable_syntax.flpc 598 618 414 | 2524 gen/resizable_syntax.flpc 619 644 415 | 2531 gen/resizable_syntax.flpc 619 644 416 | 2541 gen/resizable_syntax.flpc 645 661 417 | 2548 gen/resizable_syntax.flpc 645 661 418 | 2558 gen/resizable_syntax.flpc 662 682 419 | 2565 gen/resizable_syntax.flpc 662 682 420 | 2575 gen/resizable_syntax.flpc 683 704 421 | 2582 gen/resizable_syntax.flpc 683 704 422 | 2592 gen/resizable_syntax.flpc 705 721 423 | 2599 gen/resizable_syntax.flpc 705 721 424 | 2609 gen/resizable_syntax.flpc 722 744 425 | 2616 gen/resizable_syntax.flpc 722 744 426 | 2626 gen/resizable_syntax.flpc 745 762 427 | 2633 gen/resizable_syntax.flpc 745 762 428 | 2643 gen/resizable_syntax.flpc 763 786 429 | 2650 gen/resizable_syntax.flpc 763 786 430 | 2660 gen/resizable_syntax.flpc 787 804 431 | 2667 gen/resizable_syntax.flpc 787 804 432 | 2677 gen/resizable_syntax.flpc 805 824 433 | 2684 gen/resizable_syntax.flpc 805 824 434 | 2694 gen/resizable_syntax.flpc 597 825 435 | 2696 gen/resizable_syntax.flpc 597 825 436 | 2702 gen/resizable_syntax.flpc 597 825 437 | 2712 gen/resizable_syntax.flpc 575 827 438 | 2715 gen/resizable_syntax.flpc 579 581 439 | 2724 gen/resizable_syntax.flpc 597 825 440 | 2733 gen/resizable_syntax.flpc 597 825 441 | 2743 gen/resizable_syntax.flpc 594 826 442 | 2746 gen/resizable_syntax.flpc 587 827 443 | 2758 gen/resizable_syntax.flpc 575 827 444 | 2760 gen/resizable_syntax.flpc 575 827 445 | 2766 gen/resizable_syntax.flpc 575 827 446 | 2798 gen/resizable_syntax.flpc 843 859 447 | 2805 gen/resizable_syntax.flpc 843 859 448 | 2820 gen/resizable_syntax.flpc 860 886 449 | 2826 gen/resizable_syntax.flpc 860 886 450 | 2853 gen/resizable_syntax.flpc 887 898 451 | 2859 gen/resizable_syntax.flpc 887 898 452 | 2871 gen/resizable_syntax.flpc 829 899 453 | 2885 gen/resizable_syntax.flpc 923 939 454 | 2892 gen/resizable_syntax.flpc 923 939 455 | 2907 gen/resizable_syntax.flpc 900 913 456 | 2913 gen/resizable_syntax.flpc 900 913 457 | 2927 gen/resizable_syntax.flpc 900 940 458 | 2938 gen/resizable_syntax.flpc 900 940 459 | 2945 gen/resizable_syntax.flpc 955 966 460 | 2952 gen/resizable_syntax.flpc 955 966 461 | 2962 gen/resizable_syntax.flpc 967 988 462 | 2968 gen/resizable_syntax.flpc 967 988 463 | 2990 gen/resizable_syntax.flpc 989 1000 464 | 2996 gen/resizable_syntax.flpc 989 1000 465 | 3008 gen/resizable_syntax.flpc 941 1001 466 | 3022 gen/resizable_syntax.flpc 1025 1036 467 | 3029 gen/resizable_syntax.flpc 1025 1036 468 | 3039 gen/resizable_syntax.flpc 1002 1015 469 | 3045 gen/resizable_syntax.flpc 1002 1015 470 | 3059 gen/resizable_syntax.flpc 1002 1037 471 | 3070 gen/resizable_syntax.flpc 1002 1037 472 | 3077 gen/resizable_syntax.flpc 1052 1073 473 | 3084 gen/resizable_syntax.flpc 1052 1073 474 | 3104 gen/resizable_syntax.flpc 1074 1105 475 | 3110 gen/resizable_syntax.flpc 1074 1105 476 | 3142 gen/resizable_syntax.flpc 1106 1117 477 | 3148 gen/resizable_syntax.flpc 1106 1117 478 | 3160 gen/resizable_syntax.flpc 1038 1118 479 | -------------------------------------------------------------------------------- /gen/split_grammar.f: -------------------------------------------------------------------------------- 1 | 2 | [ push: \s exactly ] bind: split_grammar_gen0 3 | [ push: \t exactly ] bind: split_grammar_gen1 4 | [ pushf: split_grammar_gen0 pushf: split_grammar_gen1 ] bind: split_grammar_gen2 5 | [ newfunc0 6 | pushf: split_grammar_gen2 or return1 ] bind: splitg.rules.hspace 7 | [ push: \n exactly ] bind: split_grammar_gen3 8 | [ push: \r exactly ] bind: split_grammar_gen4 9 | [ push: hspace apply ] bind: split_grammar_gen5 10 | [ pushf: split_grammar_gen3 pushf: split_grammar_gen4 pushf: split_grammar_gen5 ] bind: split_grammar_gen6 11 | [ newfunc0 12 | pushf: split_grammar_gen6 or return1 ] bind: splitg.rules.space 13 | [ push: space apply ] bind: split_grammar_gen7 14 | [ newfunc0 15 | pushf: split_grammar_gen7 push: * quantified return1 ] bind: splitg.rules.spaces 16 | [ push: space apply ] bind: split_grammar_gen8 17 | [ pushf: split_grammar_gen8 negation ] bind: split_grammar_gen9 18 | [ push: anything apply ] bind: split_grammar_gen10 19 | [ pushf: split_grammar_gen9 pushf: split_grammar_gen10 ] bind: split_grammar_gen11 20 | [ pushf: split_grammar_gen11 and ] bind: split_grammar_gen12 21 | [ newfunc0 22 | pushf: split_grammar_gen12 push: + quantified return1 ] bind: splitg.rules.token 23 | [ push: spaces apply ] bind: split_grammar_gen13 24 | [ push: token apply ] bind: split_grammar_gen14 25 | [ pushf: split_grammar_gen14 out ] bind: split_grammar_gen15 26 | [ push: space apply ] bind: split_grammar_gen16 27 | [ push: spaces apply ] bind: split_grammar_gen17 28 | [ push: token apply ] bind: split_grammar_gen18 29 | [ pushf: split_grammar_gen18 out ] bind: split_grammar_gen19 30 | [ pushf: split_grammar_gen16 pushf: split_grammar_gen17 pushf: split_grammar_gen19 ] bind: split_grammar_gen20 31 | [ pushf: split_grammar_gen20 and ] bind: split_grammar_gen21 32 | [ pushf: split_grammar_gen21 push: * quantified ] bind: split_grammar_gen22 33 | [ pushf: split_grammar_gen22 out ] bind: split_grammar_gen23 34 | [ pushf: split_grammar_gen15 pushf: split_grammar_gen23 ] bind: split_grammar_gen24 35 | [ pushf: split_grammar_gen24 and ] bind: split_grammar_gen25 36 | [ pushf: split_grammar_gen25 push: ? quantified ] bind: split_grammar_gen26 37 | [ pushf: split_grammar_gen26 out ] bind: split_grammar_gen27 38 | [ push: spaces apply ] bind: split_grammar_gen28 39 | [ pushf: split_grammar_gen13 pushf: split_grammar_gen27 pushf: split_grammar_gen28 ] bind: split_grammar_gen29 40 | [ newfunc0 41 | pushf: split_grammar_gen29 and return1 ] bind: splitg.rules.grammar 42 | pushi: 20 hashtable bind: splitg.rules 43 | 0 resizable bind: splitg.flagged 44 | push: hspace pick: splitg.rules.hspace pick: splitg.rules hashtable.set 45 | push: space pick: splitg.rules.space pick: splitg.rules hashtable.set 46 | push: spaces pick: splitg.rules.spaces pick: splitg.rules hashtable.set 47 | push: token pick: splitg.rules.token pick: splitg.rules hashtable.set 48 | push: token pick: splitg.flagged attr_call: append 49 | push: grammar pick: splitg.rules.grammar pick: splitg.rules hashtable.set 50 | pick: splitg.rules add_base_rules 51 | pick: splitg.rules add_escaped_char_rules 52 | 0 resizable bind: splitg.base 53 | push: add_base_rules pick: splitg.base attr_call: append 54 | push: add_escaped_char_rules pick: splitg.base attr_call: append 55 | 0 resizable bind: splitg 56 | push: splitg pick: splitg attr_call: append 57 | pick: splitg.rules pick: splitg attr_call: append 58 | pick: splitg.flagged pick: splitg attr_call: append 59 | pick: splitg.base pick: splitg attr_call: append -------------------------------------------------------------------------------- /gen/triple_quote.f: -------------------------------------------------------------------------------- 1 | 2 | [ push: ' exactly ] bind: tempgen0 3 | [ push: ' exactly ] bind: tempgen1 4 | [ push: ' exactly ] bind: tempgen2 5 | [ pushf: tempgen0 pushf: tempgen1 pushf: tempgen2 ] bind: tempgen3 6 | [ newfunc0 7 | pushf: tempgen3 and func_return ] bind: flpcg.rules.single_quotes 8 | [ push: \q exactly ] bind: tempgen4 9 | [ push: \q exactly ] bind: tempgen5 10 | [ push: \q exactly ] bind: tempgen6 11 | [ pushf: tempgen4 pushf: tempgen5 pushf: tempgen6 ] bind: tempgen7 12 | [ newfunc0 13 | pushf: tempgen7 and func_return ] bind: flpcg.rules.double_quotes 14 | [ push: hspaces apply ] bind: tempgen8 15 | [ push: single_quotes apply ] bind: tempgen9 16 | [ push: single_quotes apply ] bind: tempgen10 17 | [ pushf: tempgen10 negation ] bind: tempgen11 18 | [ push: anything apply ] bind: tempgen12 19 | [ pushf: tempgen11 pushf: tempgen12 ] bind: tempgen13 20 | [ pushf: tempgen13 and ] bind: tempgen14 21 | [ pushf: tempgen14 push: * quantified ] bind: tempgen15 22 | [ pushf: tempgen15 out ] bind: tempgen16 23 | [ push: single_quotes apply ] bind: tempgen17 24 | [ pushf: tempgen9 pushf: tempgen16 pushf: tempgen17 ] bind: tempgen18 25 | [ pushf: tempgen18 and ] bind: tempgen19 26 | [ push: double_quotes apply ] bind: tempgen20 27 | [ push: double_quotes apply ] bind: tempgen21 28 | [ pushf: tempgen21 negation ] bind: tempgen22 29 | [ push: anything apply ] bind: tempgen23 30 | [ pushf: tempgen22 pushf: tempgen23 ] bind: tempgen24 31 | [ pushf: tempgen24 and ] bind: tempgen25 32 | [ pushf: tempgen25 push: * quantified ] bind: tempgen26 33 | [ pushf: tempgen26 out ] bind: tempgen27 34 | [ push: double_quotes apply ] bind: tempgen28 35 | [ pushf: tempgen20 pushf: tempgen27 pushf: tempgen28 ] bind: tempgen29 36 | [ pushf: tempgen29 and ] bind: tempgen30 37 | [ pushf: tempgen19 pushf: tempgen30 ] bind: tempgen31 38 | [ pushf: tempgen31 or ] bind: tempgen32 39 | [ pushf: tempgen8 pushf: tempgen32 ] bind: tempgen33 40 | [ newfunc0 41 | pushf: tempgen33 and func_return ] bind: flpcg.rules.TRIPLE_QUOTE 42 | [ push: forth apply ] bind: tempgen34 43 | [ push: func_call apply ] bind: tempgen35 44 | [ push: name_quote apply ] bind: tempgen36 45 | [ push: quote apply ] bind: tempgen37 46 | [ push: parenthesis apply ] bind: tempgen38 47 | [ push: NUMBER apply ] bind: tempgen39 48 | [ push: TRIPLE_QUOTE apply ] bind: tempgen40 49 | [ push: STRING apply ] bind: tempgen41 50 | [ push: variable apply ] bind: tempgen42 51 | [ pushf: tempgen34 pushf: tempgen35 pushf: tempgen36 pushf: tempgen37 pushf: tempgen38 pushf: tempgen39 pushf: tempgen40 pushf: tempgen41 pushf: tempgen42 ] bind: tempgen43 52 | [ newfunc0 53 | pushf: tempgen43 or func_return ] bind: flpcg.rules.non_block_non_infix 54 | push: single_quotes pick: flpcg.rules.single_quotes pick: flpcg.rules hashtable.set 55 | push: double_quotes pick: flpcg.rules.double_quotes pick: flpcg.rules hashtable.set 56 | push: TRIPLE_QUOTE pick: flpcg.rules.TRIPLE_QUOTE pick: flpcg.rules hashtable.set 57 | push: TRIPLE_QUOTE pick: flpcg.flagged attr_call: append 58 | push: non_block_non_infix pick: flpcg.rules.non_block_non_infix pick: flpcg.rules hashtable.set -------------------------------------------------------------------------------- /gen/triple_quote.f.pos_map: -------------------------------------------------------------------------------- 1 | 1 gen/triple_quote.f 2 | 0 gen/triple_quote.flpc 52 66 3 | 3 gen/triple_quote.flpc 61 64 4 | 9 gen/triple_quote.flpc 61 64 5 | 11 gen/triple_quote.flpc 53 65 6 | 19 gen/triple_quote.flpc 52 66 7 | 21 gen/triple_quote.flpc 52 66 8 | 27 gen/triple_quote.flpc 52 66 9 | 36 gen/triple_quote.flpc 67 81 10 | 39 gen/triple_quote.flpc 76 79 11 | 45 gen/triple_quote.flpc 76 79 12 | 47 gen/triple_quote.flpc 68 80 13 | 55 gen/triple_quote.flpc 67 81 14 | 57 gen/triple_quote.flpc 67 81 15 | 63 gen/triple_quote.flpc 67 81 16 | 72 gen/triple_quote.flpc 82 96 17 | 75 gen/triple_quote.flpc 91 94 18 | 81 gen/triple_quote.flpc 91 94 19 | 83 gen/triple_quote.flpc 83 95 20 | 91 gen/triple_quote.flpc 82 96 21 | 93 gen/triple_quote.flpc 82 96 22 | 99 gen/triple_quote.flpc 82 96 23 | 108 gen/triple_quote.flpc 51 97 24 | 111 gen/triple_quote.flpc 52 66 25 | 118 gen/triple_quote.flpc 52 66 26 | 127 gen/triple_quote.flpc 67 81 27 | 134 gen/triple_quote.flpc 67 81 28 | 143 gen/triple_quote.flpc 82 96 29 | 150 gen/triple_quote.flpc 82 96 30 | 159 gen/triple_quote.flpc 51 97 31 | 161 gen/triple_quote.flpc 51 97 32 | 167 gen/triple_quote.flpc 51 97 33 | 176 gen/triple_quote.flpc 28 99 34 | 179 gen/triple_quote.flpc 32 34 35 | 188 gen/triple_quote.flpc 51 97 36 | 197 gen/triple_quote.flpc 51 97 37 | 206 gen/triple_quote.flpc 47 98 38 | 210 gen/triple_quote.flpc 40 99 39 | 222 gen/triple_quote.flpc 28 99 40 | 224 gen/triple_quote.flpc 28 99 41 | 230 gen/triple_quote.flpc 28 99 42 | 256 gen/triple_quote.flpc 153 168 43 | 259 gen/triple_quote.flpc 162 166 44 | 265 gen/triple_quote.flpc 162 166 45 | 268 gen/triple_quote.flpc 154 167 46 | 276 gen/triple_quote.flpc 153 168 47 | 278 gen/triple_quote.flpc 153 168 48 | 284 gen/triple_quote.flpc 153 168 49 | 293 gen/triple_quote.flpc 169 184 50 | 296 gen/triple_quote.flpc 178 182 51 | 302 gen/triple_quote.flpc 178 182 52 | 305 gen/triple_quote.flpc 170 183 53 | 313 gen/triple_quote.flpc 169 184 54 | 315 gen/triple_quote.flpc 169 184 55 | 321 gen/triple_quote.flpc 169 184 56 | 330 gen/triple_quote.flpc 185 200 57 | 333 gen/triple_quote.flpc 194 198 58 | 339 gen/triple_quote.flpc 194 198 59 | 342 gen/triple_quote.flpc 186 199 60 | 350 gen/triple_quote.flpc 185 200 61 | 352 gen/triple_quote.flpc 185 200 62 | 358 gen/triple_quote.flpc 185 200 63 | 367 gen/triple_quote.flpc 152 201 64 | 370 gen/triple_quote.flpc 153 168 65 | 377 gen/triple_quote.flpc 153 168 66 | 386 gen/triple_quote.flpc 169 184 67 | 393 gen/triple_quote.flpc 169 184 68 | 402 gen/triple_quote.flpc 185 200 69 | 409 gen/triple_quote.flpc 185 200 70 | 418 gen/triple_quote.flpc 152 201 71 | 420 gen/triple_quote.flpc 152 201 72 | 426 gen/triple_quote.flpc 152 201 73 | 435 gen/triple_quote.flpc 129 203 74 | 438 gen/triple_quote.flpc 133 135 75 | 447 gen/triple_quote.flpc 152 201 76 | 456 gen/triple_quote.flpc 152 201 77 | 465 gen/triple_quote.flpc 148 202 78 | 469 gen/triple_quote.flpc 141 203 79 | 481 gen/triple_quote.flpc 129 203 80 | 483 gen/triple_quote.flpc 129 203 81 | 489 gen/triple_quote.flpc 129 203 82 | 515 gen/triple_quote.flpc 256 274 83 | 518 gen/triple_quote.flpc 263 272 84 | 524 gen/triple_quote.flpc 263 272 85 | 532 gen/triple_quote.flpc 257 273 86 | 538 gen/triple_quote.flpc 256 274 87 | 540 gen/triple_quote.flpc 256 274 88 | 546 gen/triple_quote.flpc 256 274 89 | 555 gen/triple_quote.flpc 286 310 90 | 558 gen/triple_quote.flpc 293 308 91 | 564 gen/triple_quote.flpc 293 308 92 | 578 gen/triple_quote.flpc 287 309 93 | 584 gen/triple_quote.flpc 286 310 94 | 586 gen/triple_quote.flpc 286 310 95 | 592 gen/triple_quote.flpc 286 310 96 | 601 gen/triple_quote.flpc 344 368 97 | 604 gen/triple_quote.flpc 351 366 98 | 610 gen/triple_quote.flpc 351 366 99 | 624 gen/triple_quote.flpc 345 367 100 | 630 gen/triple_quote.flpc 344 368 101 | 632 gen/triple_quote.flpc 344 368 102 | 638 gen/triple_quote.flpc 344 368 103 | 648 gen/triple_quote.flpc 334 370 104 | 651 gen/triple_quote.flpc 344 368 105 | 658 gen/triple_quote.flpc 344 368 106 | 668 gen/triple_quote.flpc 335 369 107 | 677 gen/triple_quote.flpc 334 370 108 | 679 gen/triple_quote.flpc 334 370 109 | 685 gen/triple_quote.flpc 334 370 110 | 695 gen/triple_quote.flpc 371 390 111 | 698 gen/triple_quote.flpc 378 388 112 | 704 gen/triple_quote.flpc 378 388 113 | 713 gen/triple_quote.flpc 372 389 114 | 719 gen/triple_quote.flpc 371 390 115 | 721 gen/triple_quote.flpc 371 390 116 | 727 gen/triple_quote.flpc 371 390 117 | 737 gen/triple_quote.flpc 333 391 118 | 740 gen/triple_quote.flpc 334 370 119 | 747 gen/triple_quote.flpc 334 370 120 | 757 gen/triple_quote.flpc 371 390 121 | 764 gen/triple_quote.flpc 371 390 122 | 774 gen/triple_quote.flpc 333 391 123 | 776 gen/triple_quote.flpc 333 391 124 | 782 gen/triple_quote.flpc 333 391 125 | 792 gen/triple_quote.flpc 328 393 126 | 795 gen/triple_quote.flpc 333 391 127 | 802 gen/triple_quote.flpc 333 391 128 | 812 gen/triple_quote.flpc 329 392 129 | 816 gen/triple_quote.flpc 328 393 130 | 818 gen/triple_quote.flpc 328 393 131 | 824 gen/triple_quote.flpc 328 393 132 | 834 gen/triple_quote.flpc 316 399 133 | 837 gen/triple_quote.flpc 328 393 134 | 844 gen/triple_quote.flpc 328 393 135 | 854 gen/triple_quote.flpc 394 397 136 | 860 gen/triple_quote.flpc 394 397 137 | 862 gen/triple_quote.flpc 317 398 138 | 873 gen/triple_quote.flpc 316 399 139 | 875 gen/triple_quote.flpc 316 399 140 | 881 gen/triple_quote.flpc 316 399 141 | 891 gen/triple_quote.flpc 311 401 142 | 894 gen/triple_quote.flpc 316 399 143 | 901 gen/triple_quote.flpc 316 399 144 | 911 gen/triple_quote.flpc 312 400 145 | 915 gen/triple_quote.flpc 311 401 146 | 917 gen/triple_quote.flpc 311 401 147 | 923 gen/triple_quote.flpc 311 401 148 | 933 gen/triple_quote.flpc 402 426 149 | 936 gen/triple_quote.flpc 409 424 150 | 942 gen/triple_quote.flpc 409 424 151 | 956 gen/triple_quote.flpc 403 425 152 | 962 gen/triple_quote.flpc 402 426 153 | 964 gen/triple_quote.flpc 402 426 154 | 970 gen/triple_quote.flpc 402 426 155 | 980 gen/triple_quote.flpc 285 427 156 | 983 gen/triple_quote.flpc 286 310 157 | 990 gen/triple_quote.flpc 286 310 158 | 999 gen/triple_quote.flpc 311 401 159 | 1006 gen/triple_quote.flpc 311 401 160 | 1016 gen/triple_quote.flpc 402 426 161 | 1023 gen/triple_quote.flpc 402 426 162 | 1033 gen/triple_quote.flpc 285 427 163 | 1035 gen/triple_quote.flpc 285 427 164 | 1041 gen/triple_quote.flpc 285 427 165 | 1051 gen/triple_quote.flpc 280 429 166 | 1054 gen/triple_quote.flpc 285 427 167 | 1061 gen/triple_quote.flpc 285 427 168 | 1071 gen/triple_quote.flpc 281 428 169 | 1075 gen/triple_quote.flpc 280 429 170 | 1077 gen/triple_quote.flpc 280 429 171 | 1083 gen/triple_quote.flpc 280 429 172 | 1093 gen/triple_quote.flpc 436 460 173 | 1096 gen/triple_quote.flpc 443 458 174 | 1102 gen/triple_quote.flpc 443 458 175 | 1116 gen/triple_quote.flpc 437 459 176 | 1122 gen/triple_quote.flpc 436 460 177 | 1124 gen/triple_quote.flpc 436 460 178 | 1130 gen/triple_quote.flpc 436 460 179 | 1140 gen/triple_quote.flpc 494 518 180 | 1143 gen/triple_quote.flpc 501 516 181 | 1149 gen/triple_quote.flpc 501 516 182 | 1163 gen/triple_quote.flpc 495 517 183 | 1169 gen/triple_quote.flpc 494 518 184 | 1171 gen/triple_quote.flpc 494 518 185 | 1177 gen/triple_quote.flpc 494 518 186 | 1187 gen/triple_quote.flpc 484 520 187 | 1190 gen/triple_quote.flpc 494 518 188 | 1197 gen/triple_quote.flpc 494 518 189 | 1207 gen/triple_quote.flpc 485 519 190 | 1216 gen/triple_quote.flpc 484 520 191 | 1218 gen/triple_quote.flpc 484 520 192 | 1224 gen/triple_quote.flpc 484 520 193 | 1234 gen/triple_quote.flpc 521 540 194 | 1237 gen/triple_quote.flpc 528 538 195 | 1243 gen/triple_quote.flpc 528 538 196 | 1252 gen/triple_quote.flpc 522 539 197 | 1258 gen/triple_quote.flpc 521 540 198 | 1260 gen/triple_quote.flpc 521 540 199 | 1266 gen/triple_quote.flpc 521 540 200 | 1276 gen/triple_quote.flpc 483 541 201 | 1279 gen/triple_quote.flpc 484 520 202 | 1286 gen/triple_quote.flpc 484 520 203 | 1296 gen/triple_quote.flpc 521 540 204 | 1303 gen/triple_quote.flpc 521 540 205 | 1313 gen/triple_quote.flpc 483 541 206 | 1315 gen/triple_quote.flpc 483 541 207 | 1321 gen/triple_quote.flpc 483 541 208 | 1331 gen/triple_quote.flpc 478 543 209 | 1334 gen/triple_quote.flpc 483 541 210 | 1341 gen/triple_quote.flpc 483 541 211 | 1351 gen/triple_quote.flpc 479 542 212 | 1355 gen/triple_quote.flpc 478 543 213 | 1357 gen/triple_quote.flpc 478 543 214 | 1363 gen/triple_quote.flpc 478 543 215 | 1373 gen/triple_quote.flpc 466 549 216 | 1376 gen/triple_quote.flpc 478 543 217 | 1383 gen/triple_quote.flpc 478 543 218 | 1393 gen/triple_quote.flpc 544 547 219 | 1399 gen/triple_quote.flpc 544 547 220 | 1401 gen/triple_quote.flpc 467 548 221 | 1412 gen/triple_quote.flpc 466 549 222 | 1414 gen/triple_quote.flpc 466 549 223 | 1420 gen/triple_quote.flpc 466 549 224 | 1430 gen/triple_quote.flpc 461 551 225 | 1433 gen/triple_quote.flpc 466 549 226 | 1440 gen/triple_quote.flpc 466 549 227 | 1450 gen/triple_quote.flpc 462 550 228 | 1454 gen/triple_quote.flpc 461 551 229 | 1456 gen/triple_quote.flpc 461 551 230 | 1462 gen/triple_quote.flpc 461 551 231 | 1472 gen/triple_quote.flpc 552 576 232 | 1475 gen/triple_quote.flpc 559 574 233 | 1481 gen/triple_quote.flpc 559 574 234 | 1495 gen/triple_quote.flpc 553 575 235 | 1501 gen/triple_quote.flpc 552 576 236 | 1503 gen/triple_quote.flpc 552 576 237 | 1509 gen/triple_quote.flpc 552 576 238 | 1519 gen/triple_quote.flpc 435 577 239 | 1522 gen/triple_quote.flpc 436 460 240 | 1529 gen/triple_quote.flpc 436 460 241 | 1539 gen/triple_quote.flpc 461 551 242 | 1546 gen/triple_quote.flpc 461 551 243 | 1556 gen/triple_quote.flpc 552 576 244 | 1563 gen/triple_quote.flpc 552 576 245 | 1573 gen/triple_quote.flpc 435 577 246 | 1575 gen/triple_quote.flpc 435 577 247 | 1581 gen/triple_quote.flpc 435 577 248 | 1591 gen/triple_quote.flpc 430 579 249 | 1594 gen/triple_quote.flpc 435 577 250 | 1601 gen/triple_quote.flpc 435 577 251 | 1611 gen/triple_quote.flpc 431 578 252 | 1615 gen/triple_quote.flpc 430 579 253 | 1617 gen/triple_quote.flpc 430 579 254 | 1623 gen/triple_quote.flpc 430 579 255 | 1633 gen/triple_quote.flpc 279 580 256 | 1636 gen/triple_quote.flpc 280 429 257 | 1643 gen/triple_quote.flpc 280 429 258 | 1653 gen/triple_quote.flpc 430 579 259 | 1660 gen/triple_quote.flpc 430 579 260 | 1670 gen/triple_quote.flpc 279 580 261 | 1672 gen/triple_quote.flpc 279 580 262 | 1678 gen/triple_quote.flpc 279 580 263 | 1688 gen/triple_quote.flpc 275 582 264 | 1691 gen/triple_quote.flpc 279 580 265 | 1698 gen/triple_quote.flpc 279 580 266 | 1708 gen/triple_quote.flpc 276 581 267 | 1711 gen/triple_quote.flpc 275 582 268 | 1713 gen/triple_quote.flpc 275 582 269 | 1719 gen/triple_quote.flpc 275 582 270 | 1729 gen/triple_quote.flpc 255 583 271 | 1732 gen/triple_quote.flpc 256 274 272 | 1739 gen/triple_quote.flpc 256 274 273 | 1748 gen/triple_quote.flpc 275 582 274 | 1755 gen/triple_quote.flpc 275 582 275 | 1765 gen/triple_quote.flpc 255 583 276 | 1767 gen/triple_quote.flpc 255 583 277 | 1773 gen/triple_quote.flpc 255 583 278 | 1783 gen/triple_quote.flpc 232 585 279 | 1786 gen/triple_quote.flpc 236 238 280 | 1795 gen/triple_quote.flpc 255 583 281 | 1804 gen/triple_quote.flpc 255 583 282 | 1814 gen/triple_quote.flpc 251 584 283 | 1818 gen/triple_quote.flpc 244 585 284 | 1830 gen/triple_quote.flpc 232 585 285 | 1832 gen/triple_quote.flpc 232 585 286 | 1838 gen/triple_quote.flpc 232 585 287 | 1863 gen/triple_quote.flpc 644 660 288 | 1866 gen/triple_quote.flpc 651 658 289 | 1872 gen/triple_quote.flpc 651 658 290 | 1878 gen/triple_quote.flpc 645 659 291 | 1884 gen/triple_quote.flpc 644 660 292 | 1886 gen/triple_quote.flpc 644 660 293 | 1892 gen/triple_quote.flpc 644 660 294 | 1902 gen/triple_quote.flpc 661 681 295 | 1905 gen/triple_quote.flpc 668 679 296 | 1911 gen/triple_quote.flpc 668 679 297 | 1921 gen/triple_quote.flpc 662 680 298 | 1927 gen/triple_quote.flpc 661 681 299 | 1929 gen/triple_quote.flpc 661 681 300 | 1935 gen/triple_quote.flpc 661 681 301 | 1945 gen/triple_quote.flpc 682 703 302 | 1948 gen/triple_quote.flpc 689 701 303 | 1954 gen/triple_quote.flpc 689 701 304 | 1965 gen/triple_quote.flpc 683 702 305 | 1971 gen/triple_quote.flpc 682 703 306 | 1973 gen/triple_quote.flpc 682 703 307 | 1979 gen/triple_quote.flpc 682 703 308 | 1989 gen/triple_quote.flpc 704 720 309 | 1992 gen/triple_quote.flpc 711 718 310 | 1998 gen/triple_quote.flpc 711 718 311 | 2004 gen/triple_quote.flpc 705 719 312 | 2010 gen/triple_quote.flpc 704 720 313 | 2012 gen/triple_quote.flpc 704 720 314 | 2018 gen/triple_quote.flpc 704 720 315 | 2028 gen/triple_quote.flpc 721 743 316 | 2031 gen/triple_quote.flpc 728 741 317 | 2037 gen/triple_quote.flpc 728 741 318 | 2049 gen/triple_quote.flpc 722 742 319 | 2055 gen/triple_quote.flpc 721 743 320 | 2057 gen/triple_quote.flpc 721 743 321 | 2063 gen/triple_quote.flpc 721 743 322 | 2073 gen/triple_quote.flpc 744 761 323 | 2076 gen/triple_quote.flpc 751 759 324 | 2082 gen/triple_quote.flpc 751 759 325 | 2089 gen/triple_quote.flpc 745 760 326 | 2095 gen/triple_quote.flpc 744 761 327 | 2097 gen/triple_quote.flpc 744 761 328 | 2103 gen/triple_quote.flpc 744 761 329 | 2113 gen/triple_quote.flpc 762 785 330 | 2116 gen/triple_quote.flpc 769 783 331 | 2122 gen/triple_quote.flpc 769 783 332 | 2135 gen/triple_quote.flpc 763 784 333 | 2141 gen/triple_quote.flpc 762 785 334 | 2143 gen/triple_quote.flpc 762 785 335 | 2149 gen/triple_quote.flpc 762 785 336 | 2159 gen/triple_quote.flpc 786 803 337 | 2162 gen/triple_quote.flpc 793 801 338 | 2168 gen/triple_quote.flpc 793 801 339 | 2175 gen/triple_quote.flpc 787 802 340 | 2181 gen/triple_quote.flpc 786 803 341 | 2183 gen/triple_quote.flpc 786 803 342 | 2189 gen/triple_quote.flpc 786 803 343 | 2199 gen/triple_quote.flpc 804 823 344 | 2202 gen/triple_quote.flpc 811 821 345 | 2208 gen/triple_quote.flpc 811 821 346 | 2217 gen/triple_quote.flpc 805 822 347 | 2223 gen/triple_quote.flpc 804 823 348 | 2225 gen/triple_quote.flpc 804 823 349 | 2231 gen/triple_quote.flpc 804 823 350 | 2241 gen/triple_quote.flpc 643 824 351 | 2244 gen/triple_quote.flpc 644 660 352 | 2251 gen/triple_quote.flpc 644 660 353 | 2261 gen/triple_quote.flpc 661 681 354 | 2268 gen/triple_quote.flpc 661 681 355 | 2278 gen/triple_quote.flpc 682 703 356 | 2285 gen/triple_quote.flpc 682 703 357 | 2295 gen/triple_quote.flpc 704 720 358 | 2302 gen/triple_quote.flpc 704 720 359 | 2312 gen/triple_quote.flpc 721 743 360 | 2319 gen/triple_quote.flpc 721 743 361 | 2329 gen/triple_quote.flpc 744 761 362 | 2336 gen/triple_quote.flpc 744 761 363 | 2346 gen/triple_quote.flpc 762 785 364 | 2353 gen/triple_quote.flpc 762 785 365 | 2363 gen/triple_quote.flpc 786 803 366 | 2370 gen/triple_quote.flpc 786 803 367 | 2380 gen/triple_quote.flpc 804 823 368 | 2387 gen/triple_quote.flpc 804 823 369 | 2397 gen/triple_quote.flpc 643 824 370 | 2399 gen/triple_quote.flpc 643 824 371 | 2405 gen/triple_quote.flpc 643 824 372 | 2415 gen/triple_quote.flpc 621 826 373 | 2418 gen/triple_quote.flpc 625 627 374 | 2427 gen/triple_quote.flpc 643 824 375 | 2436 gen/triple_quote.flpc 643 824 376 | 2446 gen/triple_quote.flpc 640 825 377 | 2449 gen/triple_quote.flpc 633 826 378 | 2461 gen/triple_quote.flpc 621 826 379 | 2463 gen/triple_quote.flpc 621 826 380 | 2469 gen/triple_quote.flpc 621 826 381 | 2501 gen/triple_quote.flpc 842 857 382 | 2508 gen/triple_quote.flpc 842 857 383 | 2522 gen/triple_quote.flpc 858 883 384 | 2528 gen/triple_quote.flpc 858 883 385 | 2554 gen/triple_quote.flpc 884 895 386 | 2560 gen/triple_quote.flpc 884 895 387 | 2572 gen/triple_quote.flpc 828 896 388 | 2586 gen/triple_quote.flpc 911 926 389 | 2593 gen/triple_quote.flpc 911 926 390 | 2607 gen/triple_quote.flpc 927 952 391 | 2613 gen/triple_quote.flpc 927 952 392 | 2639 gen/triple_quote.flpc 953 964 393 | 2645 gen/triple_quote.flpc 953 964 394 | 2657 gen/triple_quote.flpc 897 965 395 | 2671 gen/triple_quote.flpc 980 994 396 | 2678 gen/triple_quote.flpc 980 994 397 | 2691 gen/triple_quote.flpc 995 1019 398 | 2697 gen/triple_quote.flpc 995 1019 399 | 2722 gen/triple_quote.flpc 1020 1031 400 | 2728 gen/triple_quote.flpc 1020 1031 401 | 2740 gen/triple_quote.flpc 966 1032 402 | 2754 gen/triple_quote.flpc 1056 1070 403 | 2761 gen/triple_quote.flpc 1056 1070 404 | 2774 gen/triple_quote.flpc 1033 1046 405 | 2780 gen/triple_quote.flpc 1033 1046 406 | 2794 gen/triple_quote.flpc 1033 1071 407 | 2805 gen/triple_quote.flpc 1033 1071 408 | 2812 gen/triple_quote.flpc 1086 1107 409 | 2819 gen/triple_quote.flpc 1086 1107 410 | 2839 gen/triple_quote.flpc 1108 1139 411 | 2845 gen/triple_quote.flpc 1108 1139 412 | 2877 gen/triple_quote.flpc 1140 1151 413 | 2883 gen/triple_quote.flpc 1140 1151 414 | 2895 gen/triple_quote.flpc 1072 1152 415 | -------------------------------------------------------------------------------- /globals.c: -------------------------------------------------------------------------------- 1 | // gcc -shared -x c -o globals.so -fPIC globals.c 2 | 3 | #include "common.h" 4 | #include 5 | #include 6 | 7 | // Needs underscore or for some reason dlopen isn't able to load! 8 | int *g_memory_array; //memory_array[MEMORY_LENGTH]; 9 | int *g_memory; 10 | int *g_memory_hint_array; 11 | int *g_memory_hint; 12 | int g_call_stack_array[STACK_MAXLEN]; 13 | int *g_call_stack; 14 | int g_prev_call_stack_array[STACK_MAXLEN]; 15 | int *g_prev_call_stack; 16 | int g_data_stack_array[STACK_MAXLEN]; 17 | int *g_data_stack; 18 | int g_local_stack_array[STACK_MAXLEN]; 19 | int *g_local_stack; 20 | // Input stack. Input caching, for rewinding. Contains function arguments. 21 | int g_input_stack_array[STACK_MAXLEN]; 22 | int *g_input_stack; 23 | char g_strings_raw_array[STRINGS_LENGTH]; 24 | int g_strings_raw_length; 25 | char *g_strings_raw; 26 | // TODO: Stop creating new strings when reading the input! 27 | // Only save the ones we actually need! 28 | int g_strings_array[MAX_NUM_STRINGS]; 29 | int *g_strings; 30 | 31 | void print_pointers(){ 32 | printf("%p %p %p\n", g_memory, g_memory_hint, g_call_stack); 33 | } 34 | 35 | void reinit(){ 36 | printf("Reinit globals\n"); 37 | g_call_stack = g_call_stack_array + 1; 38 | g_call_stack[0] = 0; 39 | g_memory_array = malloc((MEMORY_LENGTH + 1) * sizeof(int)); 40 | g_memory = g_memory_array + 1; 41 | g_memory_hint_array = malloc((MEMORY_LENGTH + 1) * sizeof(int)); 42 | g_memory_hint = g_memory_hint_array + 1; 43 | g_memory_hint[LENGTH] = MEMORY_LENGTH; 44 | g_call_stack = g_call_stack_array + 1; 45 | g_prev_call_stack = g_prev_call_stack_array + 1; 46 | g_data_stack = g_data_stack_array + 1; 47 | g_local_stack = g_local_stack_array + 1; 48 | g_input_stack = g_input_stack_array + 1; 49 | g_strings = g_strings_array + 1; 50 | g_strings[LENGTH] = 0; 51 | g_strings_raw = g_strings_raw_array + 1; 52 | g_strings_raw_length = 1; 53 | print_pointers(); 54 | } 55 | -------------------------------------------------------------------------------- /grammar/boot.grammar: -------------------------------------------------------------------------------- 1 | name = (letter | '_') (letter | digit | '_')* 2 | expr = apply | exactly | token | parenthesis | output 3 | 4 | exactly! = "'" {(escaped_char | ~'\'' anything)*} "'" 5 | token! = "\"" {(escaped_char | ~'"' anything)*} "\"" 6 | escaped_char! = '\\' {'n'|'r'|'t'|'b'|'f'|'"'|'\''|'\\'} 7 | apply! = ('\t'|' ')* {name} 8 | parenthesis = "(" {or} ")" 9 | output! = "{" {or} "}" 10 | 11 | not = "~" {expr=negation} | expr 12 | quantified = not ('*' | '+' | '?')? 13 | bound = quantified ('=' {name})? 14 | and = bound* 15 | or = and ("|" {and})* 16 | 17 | rule = spaces {name=rule_name '!'?=flags and=args ("=" {or})} 18 | grammar = {rule*} spaces 19 | 20 | comment = '#' (~'\n' anything)* 21 | hspace = ' ' | '\t' | comment 22 | indentation = (hspace* ('\r' '\n' | '\r' | '\n'))* hspace+ 23 | space = '\n' | '\r' | hspace 24 | spaces = space* -------------------------------------------------------------------------------- /grammar/f_string.grammar: -------------------------------------------------------------------------------- 1 | string_expr = '{' {exprsp} hspaces '}' 2 | # Using void to trigger string joining 3 | f_string_chars_s = ((~'\'' ~'{' anything)* void)=STRING 4 | f_string_chars_d = ((~'"' ~'{' anything)* void)=STRING 5 | F_QUOTE_S = ('f' '\'' {f_string_chars_s} {(string_expr f_string_chars_s)*} '\'')=fmt 6 | F_QUOTE_D = ('f' '"' {f_string_chars_d} {(string_expr f_string_chars_d)*} '"')=fmt 7 | F_QUOTE = hspaces ( F_QUOTE_S | F_QUOTE_D ) 8 | 9 | f_triple_quote_s = ((~single_quotes ~'{' anything)* void)=TRIPLE_QUOTE 10 | f_triple_quote_d = ((~double_quotes ~'{' anything)* void)=TRIPLE_QUOTE 11 | F_TRIPLE_QUOTE_S = ('f' single_quotes {f_triple_quote_s} {(string_expr f_triple_quote_s)*} single_quotes)=fmt 12 | F_TRIPLE_QUOTE_D = ('f' double_quotes {f_triple_quote_d} {(string_expr f_triple_quote_d)*} double_quotes)=fmt 13 | F_TRIPLE_QUOTE = hspaces (F_TRIPLE_QUOTE_S | F_TRIPLE_QUOTE_D) 14 | 15 | non_block_non_infix = F_TRIPLE_QUOTE | F_QUOTE 16 | | list_comp_var | make_dict | make_resizable | forth | func_call 17 | | name_quote | quote | parenthesis 18 | | NUMBER | TRIPLE_QUOTE | STRING | variable 19 | -------------------------------------------------------------------------------- /grammar/flpc.grammar: -------------------------------------------------------------------------------- 1 | comment = ('#' {(~'\n' {anything})*})=comment 2 | space = '\n' | '\r' | ' ' | '\t' 3 | spaces = space* 4 | spacesp = space+ 5 | hspaces = (' ' | '\t')* 6 | hspacesp = (' ' | '\t')+ 7 | EMPTY_LINE! = (hspaces comment? ('\n' | '\r'))=EMPTY_LINE 8 | 9 | NUMBER! = hspaces {'-'? digit+} 10 | STRING! = hspaces {('"' {(~'"' anything)*} '"' | '\'' {(~'\'' anything)*} '\'')} 11 | NAME! = hspaces {(letter | '_') (~space ~'(' ~'=' ~')' ~'[' ~']' ~'<' ~':' ~'\'' anything)*} 12 | FORTH_NAME = hspacesp ~"'F" {(~space anything)*} 13 | bin_op = "+" | "-" | "/" | "==" | "<" | ">" | "." | "in" | "||" | "&&" 14 | 15 | names! = NAME* 16 | variable! = NAME 17 | name_quote! = "`" {NAME} 18 | quote! = "[" {(~"]" spaces {statement})+} "]" 19 | # Each line has to start with non-zero whitespace 20 | forth! = "F'" {forth_line (hspaces ('\n' | '\r') {forth_line})*} spaces "'F" 21 | forth_line = (FORTH_NAME=NAME)* 22 | simple_quote! = "[" {names} "]" 23 | parenthesis = "(" {expr} ")" 24 | func_call = {NAME | bin_op=NAME} '(' {exprs=parameters} ")" 25 | block_call = NAME ({simple_quote | non_block | void} ":" {suite=quote})=parameters 26 | multi_block_call = block_call (NEWLINE+ SAME_INDENT {block_call})+ 27 | non_block_non_infix = forth | func_call | name_quote | quote 28 | | parenthesis | NUMBER | STRING | variable 29 | non_block = infix | non_block_non_infix 30 | infix = non_block_non_infix (bin_op=op non_block_non_infix)+ 31 | non_infix = block_call | non_block_non_infix 32 | expr = infix | non_infix 33 | exprs = expr ( spacesp {expr})* | void 34 | exprsp = expr (hspacesp {expr})* 35 | assign = ({names} "=" space | void) exprsp 36 | bind! = {names} "<-" {exprsp} 37 | 38 | statement = multi_block_call | bind | assign 39 | # Need to not consume "trailing" newlines because they are intended as multi-block separators. 40 | suite = INDENT (NEWLINE+ SAME_INDENT statement)+ DEDENT 41 | | statement 42 | NEWLINE = hspaces ('\n' | '\r') {} | COMMENT_LINE 43 | COMMENT_LINE = hspaces {comment} hspaces ('\n' | '\r') 44 | grammar = (NEWLINE* SAME_INDENT statement (NEWLINE+ | ~anything))+=suite 45 | | statement=suite 46 | -------------------------------------------------------------------------------- /grammar/getter.grammar: -------------------------------------------------------------------------------- 1 | bin_op = "+" | "-" | "/" | "==" | "<" | ">" | "." | "in" | "||" | "&&" | "!" 2 | -------------------------------------------------------------------------------- /grammar/list_comp.grammar: -------------------------------------------------------------------------------- 1 | list_comp_var = "{" {expr} "for" {NAME} "in" {expr} "}" 2 | non_block_non_infix = list_comp_var | make_dict | make_resizable | forth | func_call 3 | | name_quote | quote | parenthesis 4 | | NUMBER | TRIPLE_QUOTE | STRING | variable 5 | -------------------------------------------------------------------------------- /grammar/resizable.grammar: -------------------------------------------------------------------------------- 1 | # Note: needs size at the end at the moment! 2 | make_resizable! = "{" spaces {expr (spacesp {expr})* | void} "}" 3 | make_dict! = "{" spaces {expr} ":" {expr} {("," spaces {expr} ":" {expr})*} "|" {expr} "}" 4 | non_block_non_infix = make_dict | make_resizable | forth | func_call 5 | | name_quote | quote | parenthesis 6 | | NUMBER | TRIPLE_QUOTE | STRING | variable 7 | -------------------------------------------------------------------------------- /grammar/test.grammar: -------------------------------------------------------------------------------- 1 | space = '\n' | '\r' | hspace 2 | space = '\n' | '\r' | hspace -------------------------------------------------------------------------------- /grammar/triple_quote.grammar: -------------------------------------------------------------------------------- 1 | single_quotes = '\'' '\'' '\'' 2 | double_quotes = '"' '"' '"' 3 | TRIPLE_QUOTE! = hspaces (single_quotes {(~single_quotes anything)*} single_quotes | double_quotes {(~double_quotes anything)*} double_quotes) 4 | non_block_non_infix = forth | func_call | name_quote | quote 5 | | parenthesis | NUMBER | TRIPLE_QUOTE | STRING | variable 6 | -------------------------------------------------------------------------------- /init_memory.dat: -------------------------------------------------------------------------------- 1 | #memory 10557 557 2 | 794 163 -1 -1 79 51 1 123 23 163 83 131 5 119 171 11 31 23 163 51 147 42 51 51 42 42 51 103 42 51 51 42 42 51 15 42 51 18 42 51 163 42 35 35 163 111 43 167 163 111 167 163 111 167 163 111 167 163 111 810 27 163 111 167 163 111 167 163 111 167 163 111 167 163 75 167 163 67 9 87 163 111 131 13 139 13 810 27 139 13 51 17 103 51 182 135 139 13 51 21 103 51 198 135 139 13 51 25 103 51 210 135 139 13 51 29 103 51 222 135 139 13 51 33 103 51 234 135 139 13 51 37 103 51 250 135 139 13 51 41 103 51 262 135 139 13 51 45 103 51 274 135 139 13 51 49 103 51 286 135 139 13 51 53 103 51 298 135 67 13 51 57 103 51 310 135 163 79 127 71 131 9 51 326 159 23 163 131 61 67 61 810 95 163 111 810 19 163 51 778 159 163 83 131 65 147 51 69 103 51 3 15 147 51 73 103 51 7 15 147 51 77 103 51 11 15 147 51 81 103 51 15 15 147 51 85 103 51 19 15 147 51 89 103 51 23 15 147 51 93 103 51 27 15 147 51 97 103 51 31 15 147 51 101 103 51 35 15 147 51 105 103 51 43 15 147 51 109 103 51 47 15 147 51 17 103 51 51 15 147 51 33 103 51 55 15 147 51 113 103 51 59 15 147 51 117 103 51 63 15 147 51 37 103 51 67 15 147 51 121 103 51 71 15 147 51 125 103 51 75 15 147 51 129 103 51 79 15 147 51 133 103 51 83 15 147 51 137 103 51 87 15 147 51 29 103 51 91 15 147 51 141 103 51 95 15 147 51 145 103 51 99 15 147 51 149 103 51 103 15 147 51 153 103 51 107 15 147 51 157 103 51 111 15 147 51 161 103 51 115 15 147 51 165 103 51 119 15 147 51 169 103 51 123 15 147 51 173 103 51 127 15 147 51 41 103 51 131 15 147 51 177 103 51 135 15 147 51 45 103 51 139 15 147 51 181 103 51 143 15 147 51 185 103 51 147 15 147 51 189 103 51 151 15 147 51 193 103 51 155 15 147 51 197 103 51 159 15 147 51 57 103 51 163 15 147 51 201 103 51 167 15 147 51 205 103 51 171 15 147 51 209 103 51 710 15 147 51 213 103 51 810 15 147 51 1 103 51 18 15 147 51 217 103 51 42 15 147 51 221 103 51 78 15 147 51 225 103 51 710 15 147 51 229 103 51 750 15 147 51 233 103 51 794 15 18 163 3 | #positions 557 4 | -1 -1 -1 -1 -1 -1 -1 -1 20 32 51 65 -1 -1 45 66 -1 -1 42 66 68 84 91 98 -1 -1 113 128 129 134 102 135 150 174 -1 -1 99 174 334 340 340 346 346 363 364 374 374 380 380 397 397 414 415 425 425 438 438 455 456 466 466 472 472 489 489 506 507 517 517 527 527 544 545 555 555 568 568 585 586 596 596 598 598 615 616 643 643 666 329 669 897 915 881 916 867 917 860 917 974 992 960 993 953 993 1055 1073 1041 1074 1034 1074 1132 1150 1118 1151 1111 1151 1219 1237 1209 1238 1195 1239 1188 1239 1297 1315 1283 1316 1276 1316 1375 1393 1361 1394 1354 1394 1451 1469 1437 1470 1430 1470 1527 1545 1513 1546 1506 1546 1601 1626 1587 1627 1580 1627 1674 1682 -1 -1 1667 1683 1660 1683 770 788 762 767 -1 -1 817 822 -1 -1 807 823 793 824 845 850 -1 -1 851 858 -1 -1 831 859 860 917 860 917 829 917 938 943 -1 -1 944 951 -1 -1 924 952 953 993 953 993 922 993 1014 1019 -1 -1 1020 1032 -1 -1 1000 1033 1034 1074 1034 1074 998 1074 1095 1100 -1 -1 1101 1109 -1 -1 1081 1110 1111 1151 1111 1151 1079 1151 1172 1177 -1 -1 1178 1186 -1 -1 1158 1187 1188 1239 1188 1239 1156 1239 1260 1265 -1 -1 1266 1274 -1 -1 1246 1275 1276 1316 1276 1316 1244 1316 1337 1342 -1 -1 1343 1352 -1 -1 1323 1353 1354 1394 1354 1394 1321 1394 1415 1420 -1 -1 1421 1428 -1 -1 1401 1429 1430 1470 1430 1470 1399 1470 1491 1496 -1 -1 1497 1504 -1 -1 1477 1505 1506 1546 1506 1546 1475 1546 1567 1572 -1 -1 1573 1578 -1 -1 1553 1579 1580 1627 1580 1627 1551 1627 1648 1654 -1 -1 1655 1658 -1 -1 1634 1659 1660 1683 1660 1683 1632 1683 757 1683 693 703 734 746 726 747 716 723 -1 -1 757 1683 757 1683 750 1683 -1 -1 713 1683 1746 1752 -1 -1 1771 1776 -1 -1 1761 1777 1756 1778 1753 1778 1895 1913 1885 1914 1869 1915 1814 1915 1814 1915 1814 1915 1807 1915 1804 1915 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 5 | #strings 59 6 | lookup_error value pointer token push: attr: attr_call: pushi: pushf: check: assign: pick: bind: ''' ] name key 0 primitive_name memory.set return_if call_from_input return_no_value mempos_append functions.end.increase functions.end.decrease string_unescape print bp repeat_if Pointer input.next_triple_quote newfunc0 newfunc1 func_return call drop1 string_equal > input.next_token Prim functions.end error memory.len if - pick1 1 primitives.len repeat memory.append s21 [ names.get functions.append functions.add write_loop run input_loop2 7 | #indices 555 202 187 8 | #names 43 9 | 0 primitive_name memory.set return_if call_from_input return_no_value mempos_append functions.end.increase functions.end.decrease functions_end string_unescape print push: pushf: bp repeat_if check: Pointer input.next_triple_quote newfunc0 newfunc1 func_return pushi: call drop1 string_equal > input.next_token Prim functions.end error memory.len assign: if pick: - pick1 1 primitives.len repeat ] memory.append s21 10 | -------------------------------------------------------------------------------- /lib/boot.flpc: -------------------------------------------------------------------------------- 1 | 2 | "Unnamed" 3 | drop1() 4 | 5 | lookup_error <- fun[]: 6 | error("lookup_error") 7 | 8 | functions.append <- fun[value]: 9 | memory.set(functions.end() s21()) # pos value 10 | functions.end.increase() 11 | 12 | # Need to make this hyperstatic again later on 13 | # Slightly less ugly hack. Still depend on a memory reset for functions.append. 14 | functions.add <- inline[]: 15 | F' push: pick1 functions.append 16 | push: push: functions.append functions.append 17 | push: string_equal functions.append 18 | push: push: functions.append functions.append 19 | push: return_if functions.append 20 | push: lookup_error functions.append 21 | push: ] functions.append 22 | functions.end.decrease functions.end.decrease 'F 23 | 24 | # right_bracket <- 93 25 | write_loop <- fun[]: 26 | pointer = Pointer(memory.len()) 27 | repeat: 28 | token = input.next_token() 29 | mempos_append(names.get(token)) 30 | if string_equal(token "push:"): 31 | memory.append(string_unescape(input.next_token())) 32 | if string_equal(token "attr:"): 33 | memory.append(input.next_token()) 34 | if string_equal(token "attr_call:"): 35 | memory.append(input.next_token()) 36 | if string_equal(token "pushi:"): 37 | memory.append(input.next_token()) 38 | if string_equal(token "pushf:"): 39 | mempos_append(names.get(input.next_token())) 40 | if string_equal(token "check:"): 41 | memory.append(input.next_token()) 42 | if string_equal(token "assign:"): 43 | memory.append(input.next_token()) 44 | if string_equal(token "pick:"): 45 | memory.append(input.next_token()) 46 | if string_equal(token "bind:"): 47 | memory.append(input.next_token()) 48 | if string_equal(token "'''"): 49 | memory.append(input.next_triple_quote()) 50 | if string_equal(`token "]"): 51 | return(`pointer) 52 | 53 | # Doesn't work well with any semantic...removed 54 | run <- inline[name]: 55 | call(names.get(`name)) 56 | 57 | input_loop2 <- inline[]: 58 | repeat: 59 | # Too many issues when calling run instead... 60 | call_from_input(names.get(input.next_token())) 61 | -------------------------------------------------------------------------------- /lib/flpc_grammar.flpc: -------------------------------------------------------------------------------- 1 | flpcg.rules.comment <- fun[]: 2 | return(bound([and([[exactly("#")] [out([quantified([and([[negation([exactly("\n")])] [out([apply("anything")])]])] "*")])]])] "comment")) 3 | 4 | flpcg.rules.space <- fun[]: 5 | return(or([[exactly("\n")] [exactly("\r")] [exactly("\_")] [exactly("\t")]])) 6 | 7 | flpcg.rules.spaces <- fun[]: 8 | return(quantified([apply("space")] "*")) 9 | 10 | flpcg.rules.spacesp <- fun[]: 11 | return(quantified([apply("space")] "+")) 12 | 13 | flpcg.rules.hspaces <- fun[]: 14 | return(quantified([or([[exactly("\_")] [exactly("\t")]])] "*")) 15 | 16 | flpcg.rules.hspacesp <- fun[]: 17 | return(quantified([or([[exactly("\_")] [exactly("\t")]])] "+")) 18 | 19 | flpcg.rules.EMPTY_LINE <- fun[]: 20 | return(bound([and([[apply("hspaces")] [quantified([apply("comment")] "?")] [or([[exactly("\n")] [exactly("\r")]])]])] "EMPTY_LINE")) 21 | 22 | flpcg.rules.NUMBER <- fun[]: 23 | return(and([[apply("hspaces")] [out([and([[quantified([exactly("-")] "?")] [quantified([apply("digit")] "+")]])])]])) 24 | 25 | flpcg.rules.STRING <- fun[]: 26 | return(and([[apply("hspaces")] [out([or([[and([[exactly("\q")] [out([quantified([and([[negation([exactly("\q")])] [apply("anything")]])] "*")])] [exactly("\q")]])] [and([[exactly("'")] [out([quantified([and([[negation([exactly("'")])] [apply("anything")]])] "*")])] [exactly("'")]])]])])]])) 27 | 28 | flpcg.rules.NAME <- fun[]: 29 | return(and([[apply("hspaces")] [out([and([[or([[apply("letter")] [exactly("_")]])] [quantified([and([[negation([apply("space")])] [negation([exactly("(")])] [negation([exactly("=")])] [negation([exactly(")")])] [negation([exactly("[")])] [negation([exactly("]")])] [negation([exactly("<")])] [negation([exactly(":")])] [negation([exactly("'")])] [apply("anything")]])] "*")]])])]])) 30 | 31 | flpcg.rules.FORTH_NAME <- fun[]: 32 | return(and([[apply("hspacesp")] [negation([token("'F")])] [out([quantified([and([[negation([apply("space")])] [apply("anything")]])] "*")])]])) 33 | 34 | flpcg.rules.bin_op <- fun[]: 35 | return(or([[token("+")] [token("-")] [token("/")] [token("==")] [token("<")] [token(">")] [token(".")] [token("in")] [token("||")] [token("&&")]])) 36 | 37 | flpcg.rules.names <- fun[]: 38 | return(quantified([apply("NAME")] "*")) 39 | 40 | flpcg.rules.variable <- fun[]: 41 | return(apply("NAME")) 42 | 43 | flpcg.rules.name_quote <- fun[]: 44 | return(and([[token("`")] [out([apply("NAME")])]])) 45 | 46 | flpcg.rules.quote <- fun[]: 47 | return(and([[token("[")] [out([quantified([and([[negation([token("]")])] [apply("spaces")] [out([apply("statement")])]])] "+")])] [token("]")]])) 48 | 49 | flpcg.rules.forth <- fun[]: 50 | return(and([[token("F'")] [out([and([[apply("forth_line")] [quantified([and([[apply("hspaces")] [or([[exactly("\n")] [exactly("\r")]])] [out([apply("forth_line")])]])] "*")]])])] [apply("spaces")] [token("'F")]])) 51 | 52 | flpcg.rules.forth_line <- fun[]: 53 | return(quantified([bound([apply("FORTH_NAME")] "NAME")] "*")) 54 | 55 | flpcg.rules.simple_quote <- fun[]: 56 | return(and([[token("[")] [out([apply("names")])] [token("]")]])) 57 | 58 | flpcg.rules.parenthesis <- fun[]: 59 | return(and([[token("(")] [out([apply("expr")])] [token(")")]])) 60 | 61 | flpcg.rules.func_call <- fun[]: 62 | return(and([[out([or([[apply("NAME")] [bound([apply("bin_op")] "NAME")]])])] [exactly("(")] [out([bound([apply("exprs")] "parameters")])] [token(")")]])) 63 | 64 | flpcg.rules.block_call <- fun[]: 65 | return(and([[apply("NAME")] [bound([and([[out([or([[apply("simple_quote")] [apply("non_block")] [apply("void")]])])] [token(":")] [out([bound([apply("suite")] "quote")])]])] "parameters")]])) 66 | 67 | flpcg.rules.multi_block_call <- fun[]: 68 | return(and([[apply("block_call")] [quantified([and([[quantified([apply("NEWLINE")] "+")] [apply("SAME_INDENT")] [out([apply("block_call")])]])] "+")]])) 69 | 70 | flpcg.rules.non_block_non_infix <- fun[]: 71 | return(or([[apply("forth")] [apply("func_call")] [apply("name_quote")] [apply("quote")] [apply("parenthesis")] [apply("NUMBER")] [apply("STRING")] [apply("variable")]])) 72 | 73 | flpcg.rules.non_block <- fun[]: 74 | return(or([[apply("infix")] [apply("non_block_non_infix")]])) 75 | 76 | flpcg.rules.infix <- fun[]: 77 | return(and([[apply("non_block_non_infix")] [quantified([and([[bound([apply("bin_op")] "op")] [apply("non_block_non_infix")]])] "+")]])) 78 | 79 | flpcg.rules.non_infix <- fun[]: 80 | return(or([[apply("block_call")] [apply("non_block_non_infix")]])) 81 | 82 | flpcg.rules.expr <- fun[]: 83 | return(or([[apply("infix")] [apply("non_infix")]])) 84 | 85 | flpcg.rules.exprs <- fun[]: 86 | return(or([[and([[apply("expr")] [quantified([and([[apply("spacesp")] [out([apply("expr")])]])] "*")]])] [apply("void")]])) 87 | 88 | flpcg.rules.exprsp <- fun[]: 89 | return(and([[apply("expr")] [quantified([and([[apply("hspacesp")] [out([apply("expr")])]])] "*")]])) 90 | 91 | flpcg.rules.assign <- fun[]: 92 | return(and([[or([[and([[out([apply("names")])] [token("=")] [apply("space")]])] [apply("void")]])] [apply("exprsp")]])) 93 | 94 | flpcg.rules.bind <- fun[]: 95 | return(and([[out([apply("names")])] [token("<-")] [out([apply("exprsp")])]])) 96 | 97 | flpcg.rules.statement <- fun[]: 98 | return(or([[apply("multi_block_call")] [apply("bind")] [apply("assign")]])) 99 | 100 | flpcg.rules.suite <- fun[]: 101 | return(or([[and([[apply("INDENT")] [quantified([and([[quantified([apply("NEWLINE")] "+")] [apply("SAME_INDENT")] [apply("statement")]])] "+")] [apply("DEDENT")]])] [apply("statement")]])) 102 | 103 | flpcg.rules.NEWLINE <- fun[]: 104 | return(or([[and([[apply("hspaces")] [or([[exactly("\n")] [exactly("\r")]])] [out(None)]])] [apply("COMMENT_LINE")]])) 105 | 106 | flpcg.rules.COMMENT_LINE <- fun[]: 107 | return(and([[apply("hspaces")] [out([apply("comment")])] [apply("hspaces")] [or([[exactly("\n")] [exactly("\r")]])]])) 108 | 109 | flpcg.rules.grammar <- fun[]: 110 | return(or([[bound([quantified([and([[quantified([apply("NEWLINE")] "*")] [apply("SAME_INDENT")] [apply("statement")] [or([[quantified([apply("NEWLINE")] "+")] [negation([apply("anything")])]])]])] "+")] "suite")] [bound([apply("statement")] "suite")]])) 111 | 112 | flpcg.rules <- hashtable(148) 113 | flpcg.flagged <- resizable(0) 114 | hashtable.set("comment" flpcg.rules.comment flpcg.rules) 115 | hashtable.set("space" flpcg.rules.space flpcg.rules) 116 | hashtable.set("spaces" flpcg.rules.spaces flpcg.rules) 117 | hashtable.set("spacesp" flpcg.rules.spacesp flpcg.rules) 118 | hashtable.set("hspaces" flpcg.rules.hspaces flpcg.rules) 119 | hashtable.set("hspacesp" flpcg.rules.hspacesp flpcg.rules) 120 | hashtable.set("EMPTY_LINE" flpcg.rules.EMPTY_LINE flpcg.rules) 121 | flpcg.flagged . append("EMPTY_LINE") 122 | hashtable.set("NUMBER" flpcg.rules.NUMBER flpcg.rules) 123 | flpcg.flagged . append("NUMBER") 124 | hashtable.set("STRING" flpcg.rules.STRING flpcg.rules) 125 | flpcg.flagged . append("STRING") 126 | hashtable.set("NAME" flpcg.rules.NAME flpcg.rules) 127 | flpcg.flagged . append("NAME") 128 | hashtable.set("FORTH_NAME" flpcg.rules.FORTH_NAME flpcg.rules) 129 | hashtable.set("bin_op" flpcg.rules.bin_op flpcg.rules) 130 | hashtable.set("names" flpcg.rules.names flpcg.rules) 131 | flpcg.flagged . append("names") 132 | hashtable.set("variable" flpcg.rules.variable flpcg.rules) 133 | flpcg.flagged . append("variable") 134 | hashtable.set("name_quote" flpcg.rules.name_quote flpcg.rules) 135 | flpcg.flagged . append("name_quote") 136 | hashtable.set("quote" flpcg.rules.quote flpcg.rules) 137 | flpcg.flagged . append("quote") 138 | hashtable.set("forth" flpcg.rules.forth flpcg.rules) 139 | flpcg.flagged . append("forth") 140 | hashtable.set("forth_line" flpcg.rules.forth_line flpcg.rules) 141 | hashtable.set("simple_quote" flpcg.rules.simple_quote flpcg.rules) 142 | flpcg.flagged . append("simple_quote") 143 | hashtable.set("parenthesis" flpcg.rules.parenthesis flpcg.rules) 144 | hashtable.set("func_call" flpcg.rules.func_call flpcg.rules) 145 | hashtable.set("block_call" flpcg.rules.block_call flpcg.rules) 146 | hashtable.set("multi_block_call" flpcg.rules.multi_block_call flpcg.rules) 147 | hashtable.set("non_block_non_infix" flpcg.rules.non_block_non_infix flpcg.rules) 148 | hashtable.set("non_block" flpcg.rules.non_block flpcg.rules) 149 | hashtable.set("infix" flpcg.rules.infix flpcg.rules) 150 | hashtable.set("non_infix" flpcg.rules.non_infix flpcg.rules) 151 | hashtable.set("expr" flpcg.rules.expr flpcg.rules) 152 | hashtable.set("exprs" flpcg.rules.exprs flpcg.rules) 153 | hashtable.set("exprsp" flpcg.rules.exprsp flpcg.rules) 154 | hashtable.set("assign" flpcg.rules.assign flpcg.rules) 155 | hashtable.set("bind" flpcg.rules.bind flpcg.rules) 156 | flpcg.flagged . append("bind") 157 | hashtable.set("statement" flpcg.rules.statement flpcg.rules) 158 | hashtable.set("suite" flpcg.rules.suite flpcg.rules) 159 | hashtable.set("NEWLINE" flpcg.rules.NEWLINE flpcg.rules) 160 | hashtable.set("COMMENT_LINE" flpcg.rules.COMMENT_LINE flpcg.rules) 161 | hashtable.set("grammar" flpcg.rules.grammar flpcg.rules) 162 | add_base_rules(flpcg.rules) 163 | add_indent_rules(flpcg.rules) 164 | flpcg.base <- resizable(0) 165 | flpcg.base . append("add_base_rules") 166 | flpcg.base . append("add_indent_rules") 167 | flpcg <- resizable(0) 168 | flpcg . append("flpcg") 169 | flpcg . append(flpcg.rules) 170 | flpcg . append(flpcg.flagged) 171 | flpcg . append(flpcg.base) 172 | -------------------------------------------------------------------------------- /lib/grammar.flpc: -------------------------------------------------------------------------------- 1 | bootg.rules.name <- fun[]: 2 | return(and([[or([[apply("letter")] [exactly("_")]])] [quantified([or([[apply("letter")] [apply("digit")] [exactly("_")]])] "*")]])) 3 | 4 | bootg.rules.expr <- fun[]: 5 | return(or([[apply("apply")] [apply("exactly")] [apply("token")] [apply("parenthesis")] [apply("output")]])) 6 | 7 | bootg.rules.exactly <- fun[]: 8 | return(and([[token("'")] [out([quantified([or([[apply("escaped_char")] [and([[negation([exactly("'")])] [apply("anything")]])]])] "*")])] [token("'")]])) 9 | 10 | bootg.rules.token <- fun[]: 11 | return(and([[token("\q")] [out([quantified([or([[apply("escaped_char")] [and([[negation([exactly("\q")])] [apply("anything")]])]])] "*")])] [token("\q")]])) 12 | 13 | bootg.rules.escaped_char <- fun[]: 14 | return(and([[exactly("\\")] [out([or([[exactly("n")] [exactly("r")] [exactly("t")] [exactly("b")] [exactly("f")] [exactly("\q")] [exactly("'")] [exactly("\\")]])])]])) 15 | 16 | bootg.rules.apply <- fun[]: 17 | return(and([[quantified([or([[exactly("\t")] [exactly("\_")]])] "*")] [out([apply("name")])]])) 18 | 19 | bootg.rules.parenthesis <- fun[]: 20 | return(and([[token("(")] [out([apply("or")])] [token(")")]])) 21 | 22 | bootg.rules.output <- fun[]: 23 | return(and([[token("{")] [out([apply("or")])] [token("}")]])) 24 | 25 | bootg.rules.not <- fun[]: 26 | return(or([[and([[token("~")] [out([bound([apply("expr")] "negation")])]])] [apply("expr")]])) 27 | 28 | bootg.rules.quantified <- fun[]: 29 | return(and([[apply("not")] [quantified([or([[exactly("*")] [exactly("+")] [exactly("?")]])] "?")]])) 30 | 31 | bootg.rules.bound <- fun[]: 32 | return(and([[apply("quantified")] [quantified([and([[exactly("=")] [out([apply("name")])]])] "?")]])) 33 | 34 | bootg.rules.and <- fun[]: 35 | return(quantified([apply("bound")] "*")) 36 | 37 | bootg.rules.or <- fun[]: 38 | return(and([[apply("and")] [quantified([and([[token("|")] [out([apply("and")])]])] "*")]])) 39 | 40 | bootg.rules.rule <- fun[]: 41 | return(and([[apply("spaces")] [out([and([[bound([apply("name")] "rule_name")] [bound([quantified([exactly("!")] "?")] "flags")] [bound([apply("and")] "args")] [and([[token("=")] [out([apply("or")])]])]])])]])) 42 | 43 | bootg.rules.grammar <- fun[]: 44 | return(and([[out([quantified([apply("rule")] "*")])] [apply("spaces")]])) 45 | 46 | bootg.rules.comment <- fun[]: 47 | return(and([[exactly("#")] [quantified([and([[negation([exactly("\n")])] [apply("anything")]])] "*")]])) 48 | 49 | bootg.rules.hspace <- fun[]: 50 | return(or([[exactly("\_")] [exactly("\t")] [apply("comment")]])) 51 | 52 | bootg.rules.indentation <- fun[]: 53 | return(and([[quantified([and([[quantified([apply("hspace")] "*")] [or([[and([[exactly("\r")] [exactly("\n")]])] [exactly("\r")] [exactly("\n")]])]])] "*")] [quantified([apply("hspace")] "+")]])) 54 | 55 | bootg.rules.space <- fun[]: 56 | return(or([[exactly("\n")] [exactly("\r")] [apply("hspace")]])) 57 | 58 | bootg.rules.spaces <- fun[]: 59 | return(quantified([apply("space")] "*")) 60 | 61 | bootg.rules <- hashtable(200) 62 | bootg.flagged <- resizable(0) 63 | hashtable.set("name" bootg.rules.name bootg.rules) 64 | hashtable.set("expr" bootg.rules.expr bootg.rules) 65 | hashtable.set("exactly" bootg.rules.exactly bootg.rules) 66 | bootg.flagged . append("exactly") 67 | hashtable.set("token" bootg.rules.token bootg.rules) 68 | bootg.flagged . append("token") 69 | hashtable.set("escaped_char" bootg.rules.escaped_char bootg.rules) 70 | bootg.flagged . append("escaped_char") 71 | hashtable.set("apply" bootg.rules.apply bootg.rules) 72 | bootg.flagged . append("apply") 73 | hashtable.set("parenthesis" bootg.rules.parenthesis bootg.rules) 74 | hashtable.set("output" bootg.rules.output bootg.rules) 75 | bootg.flagged . append("output") 76 | hashtable.set("not" bootg.rules.not bootg.rules) 77 | hashtable.set("quantified" bootg.rules.quantified bootg.rules) 78 | hashtable.set("bound" bootg.rules.bound bootg.rules) 79 | hashtable.set("and" bootg.rules.and bootg.rules) 80 | hashtable.set("or" bootg.rules.or bootg.rules) 81 | hashtable.set("rule" bootg.rules.rule bootg.rules) 82 | hashtable.set("grammar" bootg.rules.grammar bootg.rules) 83 | hashtable.set("comment" bootg.rules.comment bootg.rules) 84 | hashtable.set("hspace" bootg.rules.hspace bootg.rules) 85 | hashtable.set("indentation" bootg.rules.indentation bootg.rules) 86 | hashtable.set("space" bootg.rules.space bootg.rules) 87 | hashtable.set("spaces" bootg.rules.spaces bootg.rules) 88 | add_base_rules(bootg.rules) 89 | add_escaped_char_rules(bootg.rules) 90 | 91 | bootg.base <- resizable(0) 92 | bootg.base . append("add_base_rules") 93 | bootg.base . append("add_escaped_char_rules") 94 | bootg <- resizable(0) 95 | bootg . append("bootg") 96 | bootg . append(bootg.rules) 97 | bootg . append(bootg.flagged) 98 | bootg . append(bootg.base) 99 | -------------------------------------------------------------------------------- /lib/stage0.flpc: -------------------------------------------------------------------------------- 1 | 2 | F' [ input.next_token functions.add ] input.next_token bind: functions.add 'F 3 | 4 | add_non_boot_primitive <- fast_fun[i]: 5 | functions.add(Prim(i) primitive_name(i)) 6 | 7 | add_non_boot_primitives <- fun[]: 8 | init_prims = 42 9 | total_prims = primitives.len() 10 | i = total_prims 11 | cond = i > init_prims 12 | repeat_if: 13 | drop1(`cond) 14 | i = `i - 1 15 | add_non_boot_primitive() 16 | cond = i > init_prims 17 | 18 | add_non_boot_primitives() 19 | 20 | # Should overwrite position too! 21 | rebind_colon <- fun[func]: 22 | location = names.get(input.next_token()) 23 | memory.set(location + 1 names.get("]")) 24 | # Need to invert check order when writing forth... 25 | memory.set(s21()) #`location `func 26 | 27 | pushn_colon <- fun[]: 28 | return(input.next_token()) 29 | 30 | ps <- fast_fun[]: 31 | print_state() 32 | 33 | # Need to not drop other values upon return. Should be a local_fun? 34 | # but local_fun still drops (only it does so in the outer function). 35 | # I guess a forth debugger, it doesn't make much sense in the current 36 | # model. So maybe dropping isn't too bad. 37 | debugger_inner <- fun[]: 38 | repeat: 39 | print("(dbg) ") 40 | name = stdin.next_token() 41 | # In all cases, should also remove name from stack 42 | if string_equal(name "s"): 43 | return(None()) 44 | if string_equal(name "n"): 45 | return(call_stack.len() - 6) 46 | if string_equal(name "r"): 47 | return(call_stack.len() - 7) 48 | if string_equal(name "c"): 49 | return(0) 50 | if string_equal(name "i"): 51 | # Should drop name but can't due to future string_equal tests! 52 | # Need continue or elif. Have to manually drop1 for the moment... 53 | print_state() 54 | if string_equal(name "l"): 55 | # TODO 56 | print_state() 57 | if not(string_equal(name "i")): 58 | print("Running ") 59 | print(name) 60 | # Needs a clean stack before running! 61 | call(names.get(`name)) 62 | 63 | debugger <- fun[]: 64 | print_state() 65 | debugger_waitlen_set(debugger_inner()) 66 | 67 | multi-if <- local_fun[i]: 68 | repeat_if: 69 | i = `i - 1 70 | i block cond = shuffle("231") 71 | if call(`cond): 72 | block i = s21() 73 | repeat_if: 74 | # Drop next pair of cond and block 75 | block i = shuffle("125") 76 | i = `i - 1 77 | call(`block) 78 | # Exit repeat_if 79 | i = 0 80 | else: 81 | drop1(`block) 82 | 83 | error_handler_set(debugger) -------------------------------------------------------------------------------- /lib/stage1a.flpc: -------------------------------------------------------------------------------- 1 | 2 | # Looks more like partial evaluation than closure. 3 | # Evaluates one param. 4 | # closure <- fun[method self]: 5 | # # push: self push: method 6 | # return(Pointer(memory.len() - 4)) 7 | closure <- fast_fun[]: 8 | F' pushf: push: memory.append memory.append 9 | memory.append 10 | pushf: ] memory.append 11 | memory.len pushi: 4 - Pointer 'F 12 | 13 | # Is running names.get("end_of_func") really that much better? 14 | end_of_func <- names.get("]") 15 | True <- 1 16 | False <- 0 17 | lookup_print <- False 18 | 19 | # call(*args func) 20 | attr_colon <- fast_fun[self]: 21 | # self.attrib(name self self) 22 | name = next_token2() 23 | name self = s21() 24 | # `name `self 25 | call(self memory.get(self - 1)) 26 | 27 | # Should be cached 28 | # Can't cache if *not* writing to function! 29 | # Cache should depend on the object. Maybe only cache the last one? 30 | # This is getting complicated... 31 | attr_call_colon <- fast_fun[self]: 32 | assign2("self") 33 | name = next_token2() 34 | if not(is_str(name)): 35 | print("attr call on non string ") 36 | print(name) 37 | printeol() 38 | error("attr call on non string") 39 | call(call(`name self self memory.get(self - 1))) 40 | 41 | nullobj.attrib <- fun[name receiver searcher]: 42 | print("Cannot find ") 43 | print(name) 44 | error("Lookup error") 45 | 46 | subclass <- fun[attrib parent]: 47 | memory.append(`parent) 48 | memory.append(`attrib) 49 | memory.append(names.get("]")) 50 | return(Pointer(memory.len() - 1)) 51 | 52 | nullobj <- subclass(nullobj.attrib None()) 53 | 54 | instance_attrib <- fun[name receiver searcher]: 55 | return_if(string_equal(name "parent") memory.get(receiver - 2)) 56 | parent = searcher . parent 57 | if parent == nullobj: 58 | print("Cannot find ") 59 | print(name) 60 | printeol() 61 | error("Lookup error") 62 | # Abusing param resolution. 63 | parent_copy = pick1(name receiver parent) 64 | return(call(memory.get(`parent_copy - 1))) 65 | 66 | minobj <- class[]: 67 | str <- fun[self]: 68 | # return("minobj_at_" + memory.str(self)) 69 | return("Boot object at ") 70 | 71 | instance <- fun[parent]: 72 | return(subclass(instance_attrib parent)) 73 | 74 | attrib <- fun[name receiver searcher]: 75 | error("Dummy function should not be called") 76 | 77 | # Closures have to be created manually 78 | attrib <- fun[name receiver searcher]: 79 | if lookup_print: 80 | print("Boot looking up ") 81 | print(name) 82 | printeol() 83 | return_if(string_equal(name "attrib_raw") memory.get(receiver - 1)) 84 | return_if(string_equal(name "attrib") minobj.attrib) 85 | return_if(string_equal(name "instance") minobj.instance) 86 | return_if(string_equal(name "subclass") subclass) 87 | return_if(string_equal(name "str") minobj.str) 88 | return_if(string_equal(name "type") "minobj") 89 | return(instance_attrib(name receiver searcher)) 90 | 91 | boot_obj <- subclass(minobj.attrib nullobj) 92 | 93 | memory.extend <- fun[i]: 94 | repeat_if: 95 | memory.append(0) 96 | i = `i - 1 97 | 98 | tprint <- fun[value]: 99 | if is_basic(value): 100 | print(value) 101 | else: 102 | if value < obj_boundary: 103 | print(value) 104 | else: 105 | # Should just print the pointer if "value . print" isn't defined... 106 | value . print() 107 | 108 | boot_array <- class[]: 109 | # Parent at -2, attrib at -1 110 | instance <- fun[length self]: 111 | new_obj = minobj.instance(boot_obj) 112 | memory.set(new_obj - 2 self) 113 | memory.set(new_obj length) 114 | memory.extend(length) 115 | memory.append(names.get("]")) 116 | return(new_obj) 117 | 118 | in_range <- fun[key self]: 119 | if key < 0: 120 | error("Index out of range") 121 | if not(key < memory.get(self)): 122 | error("Index out of range") 123 | 124 | get <- fun[key self]: 125 | boot_array.in_range(key self) 126 | return(memory.get(self + key + 1)) 127 | 128 | set <- fun[key value self]: 129 | boot_array.in_range(key self) 130 | memory.set(self + key + 1 value) 131 | 132 | print <- fun[self]: 133 | print("{ ") 134 | l = memory.get(self) 135 | i = l 136 | repeat_if: 137 | tprint(boot_array.get(l - i self)) 138 | printspace() 139 | i = `i - 1 140 | print("}") 141 | # printeol() 142 | 143 | string_index <- fun[value self]: 144 | i = memory.get(self) 145 | repeat_if: 146 | i = `i - 1 147 | if string_equal(value boot_array.get(i self)): 148 | return(`i) 149 | return(None()) 150 | 151 | hash_index <- fun[key i self]: 152 | self i = s21() 153 | repeat: 154 | # Need default value here, which is probably 0? 155 | if string_equal(key boot_array.get(i self)): 156 | return(`i) 157 | if boot_array.get(i self) == 0: 158 | return(None()) 159 | i = `i - 1 160 | if i == 0: 161 | drop1() 162 | # self . len() 163 | i = memory.get(self) 164 | 165 | none_index <- fun[i self]: 166 | self i = s21() 167 | repeat: 168 | # Need default value here, which is probably 0? 169 | if(boot_array.get(i self) == 0): 170 | return(`i) 171 | i = `i - 1 172 | if i == 0: 173 | drop1() 174 | # self . len() 175 | i = memory.get(self) 176 | 177 | copy_to <- fun[other self]: 178 | i = memory.get(self) 179 | repeat_if: 180 | i = `i - 1 181 | boot_array.set(i boot_array.get(i self) other) 182 | 183 | attrib <- fun[name receiver searcher]: 184 | if lookup_print: 185 | print("Array looking up ") 186 | print(name) 187 | printeol() 188 | return_if(string_equal(name "get") boot_array.get) 189 | return_if(string_equal(name "set") boot_array.set) 190 | return_if(string_equal(name "in_range") boot_array.in_range) 191 | return_if(string_equal(name "instance") boot_array.instance) 192 | return_if(string_equal(name "print") boot_array.print) 193 | return_if(string_equal(name "string_index") boot_array.string_index) 194 | return_if(string_equal(name "hash_index") boot_array.hash_index) 195 | return_if(string_equal(name "none_index") boot_array.none_index) 196 | return_if(string_equal(name "copy_to") boot_array.copy_to) 197 | return_if(string_equal(name "len") memory.get(receiver)) 198 | return_if(string_equal(name "type") "boot_array") 199 | return(instance_attrib(name receiver searcher)) 200 | 201 | boot_array_class <- boot_obj . subclass(boot_array.attrib) 202 | boot_array <- closure(boot_array_class . instance boot_array_class) 203 | 204 | boot_dict <- class[]: 205 | instance <- fun[length self]: 206 | keys = boot_array.instance(length boot_array_class) 207 | values = boot_array.instance(length boot_array_class) 208 | new_obj = minobj.instance(boot_obj) 209 | memory.set(new_obj - 2 self) 210 | memory.set(new_obj 0) 211 | memory.append(keys) 212 | memory.append(values) 213 | memory.append(names.get("]")) 214 | return(new_obj) 215 | 216 | get <- fun[key self]: 217 | index = boot_array.string_index(key memory.get(self + 1)) 218 | return_if(index == None() None()) 219 | return(boot_array.get(index memory.get(self + 2))) 220 | 221 | set <- fun[key value self]: 222 | l = memory.get(self) 223 | boot_array.set(l key memory.get(self + 1)) 224 | boot_array.set(l value memory.get(self + 2)) 225 | memory.set(self memory.get(self) + 1) 226 | 227 | increase <- fun[self]: 228 | memory.set(self memory.get(self) + 1) 229 | 230 | print <- fun[self]: 231 | print("{ ") 232 | l = memory.get(self) 233 | keys = memory.get(self + 1) 234 | values = memory.get(self + 2) 235 | i = l 236 | repeat_if: 237 | tprint(boot_array.get(l - i keys)) 238 | print(": ") 239 | tprint(boot_array.get(l - i values)) 240 | print(", ") 241 | i = `i - 1 242 | print("}") 243 | # printeol() 244 | 245 | attrib <- fun[name receiver searcher]: 246 | if lookup_print: 247 | print("Dict looking up ") 248 | print(name) 249 | printeol() 250 | return_if(string_equal(name "get") boot_dict.get) 251 | return_if(string_equal(name "set") boot_dict.set) 252 | return_if(string_equal(name "instance") boot_dict.instance) 253 | return_if(string_equal(name "print") boot_dict.print) 254 | return_if(string_equal(name "increase") boot_dict.increase) 255 | return_if(string_equal(name "len") memory.get(receiver)) 256 | return_if(string_equal(name "keys") memory.get(receiver + 1)) 257 | return_if(string_equal(name "values") memory.get(receiver + 2)) 258 | return_if(string_equal(name "type") "boot_dict") 259 | return(instance_attrib(name receiver searcher)) 260 | 261 | boot_dict_class <- boot_obj . subclass(boot_dict.attrib) 262 | boot_dict <- closure(boot_dict_class . instance boot_dict_class) 263 | 264 | is_instance <- fun[other class]: 265 | if is_basic(other): 266 | return(False) 267 | # self.parent == class 268 | # class doesn't need to be duplicated here! 269 | return(`class == memory.get(other - 2)) 270 | 271 | obj_boundary <- Pointer(memory.len()) -------------------------------------------------------------------------------- /lib/stage1b.flpc: -------------------------------------------------------------------------------- 1 | 2 | is_prime <- fun[n]: 3 | i = 2 4 | # Could stop at square root 5 | cond = i < n 6 | repeat_if: 7 | drop1() 8 | if mod(n i) == 0: 9 | return(False) 10 | i = `i + 1 11 | cond = i < n 12 | return(True) 13 | 14 | next_prime <- fun[n]: 15 | repeat: 16 | if is_prime(n): 17 | return(`n) 18 | n = `n + 1 19 | 20 | hashtable <- class[]: 21 | instance <- fun[length self]: 22 | plength = next_prime(length) 23 | keys = boot_array.instance(plength boot_array_class) 24 | values = boot_array.instance(plength boot_array_class) 25 | new_obj = minobj.instance(boot_obj) 26 | memory.set(new_obj - 2 self) 27 | memory.set(new_obj plength) 28 | memory.append(keys) 29 | memory.append(values) 30 | memory.append(names.get("]")) 31 | return(new_obj) 32 | 33 | get <- fun[key self]: 34 | start = mod(hash(key) memory.get(self)) 35 | index = boot_array.hash_index(key start memory.get(self + 1)) 36 | return_if(index == None() None()) 37 | return(boot_array.get(index memory.get(self + 2))) 38 | 39 | set <- fun[key value self]: 40 | start = mod(hash(key) memory.get(self)) 41 | if memory.get(self) < start: 42 | error("Index too big") 43 | if memory.get(self) == start: 44 | error("Index still too big") 45 | if start < 0: 46 | error("Negative index") 47 | # An index out of range error here probably means a hash table ran out of space. 48 | l = boot_array.hash_index(key start memory.get(self + 1)) 49 | if l == None(): 50 | drop1() 51 | l = boot_array.none_index(start memory.get(self + 1)) 52 | #print("Setting index ") 53 | #tprint(l) 54 | #printeol() 55 | boot_array.set(l key memory.get(self + 1)) 56 | boot_array.set(l value memory.get(self + 2)) 57 | # Should remove to speed up 58 | if not(boot_array.hash_index(key start memory.get(self + 1)) == l): 59 | error("Error reading new key") 60 | # memory.set(self memory.get(self) + 1) 61 | 62 | print <- fun[self]: 63 | print("{ ") 64 | l = memory.get(self) 65 | keys = memory.get(self + 1) 66 | values = memory.get(self + 2) 67 | i = l 68 | repeat_if: 69 | key = boot_array.get(l - i keys) 70 | if (key > 0): 71 | tprint(key) 72 | print(": ") 73 | print(boot_array.get(l - i values)) 74 | print(", ") 75 | drop1() 76 | i = `i - 1 77 | print("}") 78 | # printeol() 79 | 80 | num_elems <- fun[self]: 81 | keys = memory.get(self + 1) 82 | count = 0 83 | i = memory.get(self) 84 | repeat_if: 85 | i = `i - 1 86 | key = boot_array.get(i keys) 87 | if (`key > 0): 88 | i count = s21() 89 | count = `count + 1 90 | count i = s21() 91 | return(count) 92 | 93 | attrib <- fun[name receiver searcher]: 94 | if lookup_print: 95 | print("Dict looking up ") 96 | print(name) 97 | printeol() 98 | return_if(string_equal(name "get") hashtable.get) 99 | return_if(string_equal(name "set") hashtable.set) 100 | return_if(string_equal(name "instance") hashtable.instance) 101 | return_if(string_equal(name "print") hashtable.print) 102 | return_if(string_equal(name "len") memory.get(receiver)) 103 | return_if(string_equal(name "keys") memory.get(receiver + 1)) 104 | return_if(string_equal(name "values") memory.get(receiver + 2)) 105 | return_if(string_equal(name "type") "hashtable") 106 | return(instance_attrib(name receiver searcher)) 107 | 108 | hashtable_class <- boot_obj . subclass(hashtable.attrib) 109 | hashtable <- closure(hashtable_class . instance hashtable_class) 110 | -------------------------------------------------------------------------------- /lib/stage1b2.flpc: -------------------------------------------------------------------------------- 1 | names <- hashtable(2131) 2 | F' [ pushf: names ] bind: names2 'F 3 | mem_value <- hashtable(200000) 4 | 5 | set_mem_hint <- fun[index hint]: 6 | hashtable.set(int_to_str(index) hint mem_value) 7 | memory_hint.set(hint index) 8 | 9 | get_mem_hint <- fun[index]: 10 | return(hashtable.get(int_to_str(index) mem_value)) 11 | 12 | convert_names <- fun[]: 13 | end = functions.end() 14 | index = names.get + 5 15 | cond = not(index > end) 16 | repeat_if: 17 | drop1(`cond) 18 | names . set(memory.get(index) memory.get(index + 3)) 19 | # If it is memory pointer 20 | if type_of(memory.get(index + 3)) == 2: 21 | set_mem_hint(memory.get(index + 3) memory.get(index)) 22 | index = `index + 7 23 | cond = not(index > end) 24 | 25 | names.get <- fun[name]: 26 | value = hashtable.get(name names2()) 27 | if value == None(): 28 | if is_str(name): 29 | print("Can't find global name: ") 30 | printraw(name) 31 | printeol() 32 | value = error("Lookup error") 33 | return(value) 34 | 35 | new.bind <- fun[value]: 36 | name = input.next_token() 37 | hashtable.set(name value names2()) 38 | set_mem_hint(value name) 39 | 40 | convert_names() 41 | hashtable.set("bind:" hashtable.get("new.bind" names2()) names2()) 42 | F' push: bind: names2 hashtable.get rebind: bind: 43 | push: names.get names2 hashtable.get rebind: names.get 'F 44 | -------------------------------------------------------------------------------- /lib/stage1b3.flpc: -------------------------------------------------------------------------------- 1 | # Was hashattr.flpc 2 | func_len <- fun[func]: 3 | index = func 4 | repeat: 5 | if memory.get(index) == end_of_func: 6 | return(index - func) 7 | index = `index + 1 8 | 9 | read_to_return_if <- fun[index]: 10 | repeat: 11 | index = `index + 1 12 | if memory.get(index) == return_if: 13 | return(`index) 14 | 15 | add_attrib <- fun[attrib attrib_hash]: 16 | len = func_len(attrib) 17 | end = attrib + len - 16 18 | index = attrib + 12 19 | repeat: 20 | # return_no_value only pops 1 stack frame! 21 | if index > end: 22 | return(None()) 23 | tprint(memory.get(index + 3)) 24 | print(" ") 25 | tprint(memory.get(index + 6)) 26 | printeol() 27 | if attrib_hash . get(memory.get(index + 3)) == None(): 28 | attrib_hash . set(memory.get(index + 3) index + 5) 29 | index = read_to_return_if(`index + 5) 30 | index = `index + 1 31 | 32 | obj_total_len <- fun[obj]: 33 | nullobj_cached = nullobj 34 | nullobj_cached obj = s21() 35 | len = func_len(obj . attrib_raw) 36 | repeat: 37 | if obj == nullobj_cached: 38 | print("Total len: ") 39 | print(len) 40 | printeol() 41 | return(len) 42 | len = `len + func_len(obj . attrib_raw) 43 | parent = obj . parent 44 | obj len = shuffle("214") 45 | 46 | convert_attr <- fun[obj]: 47 | nullobj_cached = nullobj 48 | nullobj_cached obj = s21() 49 | len = obj_total_len(obj) 50 | # Twice len / 8. Should possibly subtract 12 from len first. 51 | attrib_hash = hashtable(`len) 52 | # add_attrib(attrib) 53 | repeat: 54 | if obj == nullobj_cached: 55 | return(attrib_hash) 56 | # Stupid hack because we can't return nothing inside a loop yet. 57 | attrib_hash = add_attrib(obj . attrib_raw attrib_hash) 58 | parent = obj . parent 59 | obj attrib_hash = shuffle("315") 60 | 61 | # Need boot_array.attrib to take new vars (newfunc3) 62 | # but not return because we're using the old function body as a jumptable! 63 | # Almost equivalent is: 64 | # boot_array.attrib <- fun[name receiver searcher]: 65 | # call(True hashtable.get(name array_hash)) 66 | 67 | # Don't have lexical scoping yet I don't think. 68 | F' [ pick: True ] bind: hash_header 'F 69 | 70 | print("obj total len ") 71 | print(boot_array.attrib) 72 | printeol() 73 | print(boot_array_class . attrib_raw) 74 | printeol() 75 | print(boot_obj . attrib) 76 | printeol() 77 | print(boot_array_class . parent . attrib_raw) 78 | printeol() 79 | print(nullobj) 80 | printeol() 81 | print(boot_array_class . parent . parent) 82 | printeol() 83 | print(boot_array_class) 84 | print(boot_array_class . parent) 85 | print(boot_array_class . parent . parent) 86 | printeol() 87 | print("total len is ") 88 | print(obj_total_len(boot_array_class)) 89 | printeol() 90 | 91 | hashtable.hash <- convert_attr(hashtable_class) 92 | hashtable.attrib <- fun[name receiver searcher]: 93 | hash_header() 94 | call(hashtable.get(name hashtable.hash)) 95 | 96 | boot_array.hash <- convert_attr(boot_array_class) 97 | boot_array.attrib <- fun[name receiver searcher]: 98 | hash_header() 99 | call(hashtable.get(name boot_array.hash)) 100 | 101 | boot_dict.hash <- convert_attr(boot_dict_class) 102 | boot_dict.attrib <- fun[name receiver searcher]: 103 | hash_header() 104 | call(hashtable.get(name boot_dict.hash)) 105 | -------------------------------------------------------------------------------- /lib/stage1c.flpc: -------------------------------------------------------------------------------- 1 | resizable <- class[]: 2 | instance <- fun[length self]: 3 | _array = boot_array.instance(length + length + 3 boot_array_class) 4 | new_obj = minobj.instance(boot_obj) 5 | # parent, attrib, len, array 6 | memory.set(new_obj - 2 self) 7 | memory.set(new_obj length) 8 | memory.append(_array) 9 | memory.append(names.get("]")) 10 | # set_mem_hint(new_obj "resizable instance") 11 | return(new_obj) 12 | 13 | get <- fun[key self]: 14 | return(boot_array.get(key memory.get(self + 1))) 15 | 16 | set <- fun[key value self]: 17 | boot_array.set(key value memory.get(self + 1)) 18 | 19 | string_index <- fun[name self]: 20 | return(boot_array.string_index(name memory.get(self + 1))) 21 | 22 | double <- fun[self]: 23 | length = memory.get(self) 24 | new_array = boot_array.instance(length + length + 3 boot_array_class) 25 | boot_array.copy_to(new_array memory.get(self + 1)) 26 | memory.set(self + 1 new_array) 27 | 28 | reset <- fun[self]: 29 | length = memory.get(self) 30 | new_array = boot_array.instance(length boot_array_class) 31 | memory.set(self + 1 new_array) 32 | 33 | increase <- fun[self]: 34 | memory.set(self memory.get(self) + 1) 35 | 36 | max_len <- fun[self]: 37 | # self . array . len 38 | return(memory.get(memory.get(self + 1))) 39 | 40 | append <- fun[value self]: 41 | if not(memory.get(self) < resizable.max_len(self)): 42 | resizable.double(self) 43 | resizable.set(memory.get(self) value self) 44 | resizable.increase(self) 45 | 46 | extend <- fun[other self]: 47 | l = other . len 48 | i = l 49 | repeat_if: 50 | resizable.append(resizable.get(l - i other) self) 51 | i = `i - 1 52 | 53 | append_array <- fun[value self]: 54 | if value == None(): 55 | return_no_value() 56 | # tprint(value) 57 | # if is_instance(node_class value): 58 | # value = value . children 59 | # Should test iterability instead 60 | if is_instance(value resizable_class): 61 | # Could be quoted with a better check system 62 | resizable.extend(value self) 63 | else: 64 | resizable.append(value self) 65 | 66 | pop <- fun[self]: 67 | memory.set(self memory.get(self) - 1) 68 | return(resizable.get(memory.get(self) self)) 69 | 70 | top <- fun[self]: 71 | return(resizable.get(memory.get(self) - 1 self)) 72 | 73 | print <- fun[self]: 74 | print("[") 75 | l = memory.get(self) 76 | i = l 77 | repeat_if: 78 | tprint(resizable.get(l - i self)) 79 | if i > 1: 80 | printspace() 81 | i = `i - 1 82 | print("]") 83 | # printeol() 84 | 85 | join <- fun[self]: 86 | return(str_join(self . array + 1 self . len)) 87 | 88 | attrib <- fun[name receiver searcher]: 89 | if lookup_print: 90 | print("Resizable looking up ") 91 | print(name) 92 | printeol() 93 | return_if(string_equal(name "get") resizable.get) 94 | return_if(string_equal(name "set") resizable.set) 95 | return_if(string_equal(name "string_index") resizable.string_index) 96 | return_if(string_equal(name "instance") resizable.instance) 97 | return_if(string_equal(name "print") resizable.print) 98 | return_if(string_equal(name "append") resizable.append) 99 | return_if(string_equal(name "extend") resizable.extend) 100 | return_if(string_equal(name "append_array") resizable.append_array) 101 | return_if(string_equal(name "double") resizable.double) 102 | return_if(string_equal(name "reset") resizable.reset) 103 | return_if(string_equal(name "increase") resizable.increase) 104 | return_if(string_equal(name "pop") resizable.pop) 105 | return_if(string_equal(name "top") resizable.top) 106 | return_if(string_equal(name "max_len") resizable.max_len) 107 | return_if(string_equal(name "join") resizable.join) 108 | return_if(string_equal(name "len") memory.get(receiver)) 109 | return_if(string_equal(name "array") memory.get(receiver + 1)) 110 | return_if(string_equal(name "type") "resizable") 111 | return(instance_attrib(name receiver searcher)) 112 | 113 | resizable_class <- boot_obj . subclass(resizable.attrib) 114 | resizable <- closure(resizable_class . instance resizable_class) 115 | 116 | resizable.hash <- convert_attr(resizable_class) 117 | resizable.attrib <- fun[name receiver searcher]: 118 | hash_header() 119 | call(hashtable.get(name resizable.hash)) 120 | 121 | node <- class[]: 122 | instance <- fun[name children self]: 123 | new_obj = minobj.instance(boot_obj) 124 | # parent, attrib, name, children 125 | memory.set(new_obj - 2 self) 126 | memory.set(new_obj name) 127 | memory.append(children) 128 | memory.append(resizable(2)) 129 | memory.append(names.get("]")) 130 | # set_mem_hint(new_obj "node instance") 131 | return(`new_obj) 132 | 133 | get <- fun[key self]: 134 | children = memory.get(self + 1) 135 | if is_instance(children resizable_class): 136 | return(resizable.get(key children)) 137 | else: 138 | if key == 0: 139 | return(children) 140 | error("Out of bound index") 141 | 142 | print <- fun[self]: 143 | printraw(memory.get(self)) 144 | print("{") 145 | tprint(memory.get(self + 1)) 146 | print("}") 147 | 148 | len <- fun[self]: 149 | children = memory.get(self + 1) 150 | if is_instance(children resizable_class): 151 | return(memory.get(children)) 152 | else: 153 | return(1) 154 | 155 | set_name <- fun[new_name self]: 156 | memory.set(self new_name) 157 | 158 | set_children <- fun[new_children self]: 159 | memory.set(self + 1 new_children) 160 | 161 | set_pos <- fun[pos self]: 162 | memory.set(self + 2 pos) 163 | 164 | attrib <- fun[name receiver searcher]: 165 | if lookup_print: 166 | print("Node looking up ") 167 | print(name) 168 | printeol() 169 | return_if(string_equal(name "get") node.get) 170 | return_if(string_equal(name "instance") node.instance) 171 | return_if(string_equal(name "print") node.print) 172 | return_if(string_equal(name "set_name") node.set_name) 173 | return_if(string_equal(name "set_children") node.set_children) 174 | return_if(string_equal(name "set_pos") node.set_pos) 175 | # Is @property really this easy? 176 | return_if(string_equal(name "len") node.len(receiver)) 177 | return_if(string_equal(name "name") memory.get(receiver)) 178 | return_if(string_equal(name "children") memory.get(receiver + 1)) 179 | return_if(string_equal(name "pos") memory.get(receiver + 2)) 180 | return_if(string_equal(name "type") "node") 181 | return(instance_attrib(name receiver searcher)) 182 | 183 | node_class <- boot_obj . subclass(node.attrib) 184 | node <- closure(node_class . instance node_class) 185 | 186 | node.hash <- convert_attr(node_class) 187 | node.attrib <- fun[name receiver searcher]: 188 | hash_header() 189 | call(hashtable.get(name node.hash)) 190 | 191 | nodep <- fun[name children pos]: 192 | res = node(name children) 193 | res . set_pos(pos) 194 | return(res) 195 | 196 | Input <- class[]: 197 | instance <- fun[filename self]: 198 | new_obj = minobj.instance(boot_obj) 199 | # parent, attrib, file (descriptor), position 200 | memory.set(new_obj - 2 self) 201 | memory.set(new_obj file.open("r" filename)) 202 | memory.append(0) 203 | memory.append(names.get("]")) 204 | # set_mem_hint(new_obj "Input instance") 205 | return(new_obj) 206 | 207 | next <- fun[self]: 208 | return(fd_next_token(memory.get(self))) 209 | 210 | next_char <- fun[self]: 211 | return(fd_next_char(memory.get(self))) 212 | 213 | startswith <- fun[s self]: 214 | return(fd_startswith(s memory.get(self))) 215 | 216 | position <- fun[self]: 217 | return(fd_position(memory.get(`self))) 218 | 219 | position_set <- fun[value self]: 220 | fd_position_set(memory.get(`self) value) 221 | 222 | ended <- fun[self]: 223 | return(fd_ended(memory.get(`self))) 224 | 225 | attrib <- fun[name receiver searcher]: 226 | if lookup_print: 227 | print("Input looking up ") 228 | print(name) 229 | printeol() 230 | return_if(string_equal(name "instance") Input.instance) 231 | return_if(string_equal(name "ended") Input.ended) 232 | return_if(string_equal(name "next") Input.next) 233 | return_if(string_equal(name "next_char") Input.next_char) 234 | return_if(string_equal(name "startswith") Input.startswith) 235 | return_if(string_equal(name "position") Input.position) 236 | return_if(string_equal(name "position_set") Input.position_set) 237 | return_if(string_equal(name "file") memory.get(receiver)) 238 | return_if(string_equal(name "type") "Input") 239 | return(instance_attrib(name receiver searcher)) 240 | 241 | Input_class <- boot_obj . subclass(Input.attrib) 242 | Input <- closure(Input_class . instance Input_class) 243 | 244 | Input.hash <- convert_attr(Input_class) 245 | Input.attrib <- fun[name receiver searcher]: 246 | hash_header() 247 | call(hashtable.get(name Input.hash)) 248 | 249 | cheat_dict <- class[]: 250 | instance <- fun[self]: 251 | new_obj = minobj.instance(boot_obj) 252 | memory.set(new_obj - 2 self) 253 | memory.set(new_obj _cheat_dict.new()) 254 | memory.append(names.get("]")) 255 | # set_mem_hint(new_obj "cheat_dict instance") 256 | return(new_obj) 257 | 258 | attrib <- fun[name receiver searcher]: 259 | if lookup_print: 260 | print("CheatDict looking up ") 261 | print(name) 262 | printeol() 263 | return_if(string_equal(name "instance") cheat_dict.instance) 264 | return_if(string_equal(name "get") _cheat_dict.get) 265 | return_if(string_equal(name "set") _cheat_dict.set) 266 | return(instance_attrib(name receiver searcher)) 267 | 268 | cheat_dict_class <- boot_obj . subclass(cheat_dict.attrib) 269 | cheat_dict <- closure(cheat_dict_class . instance cheat_dict_class) 270 | -------------------------------------------------------------------------------- /lib/stage1d.flpc: -------------------------------------------------------------------------------- 1 | pair <- fun[start end]: 2 | pos = resizable(0) 3 | pos . append(start) 4 | pos . append(end) 5 | return(pos) 6 | 7 | MatchError <- class[]: 8 | instance <- fun[message self]: 9 | new_obj = minobj.instance(boot_obj) 10 | # parent, attrib, message 11 | memory.set(new_obj - 2 self) 12 | memory.set(new_obj message) 13 | memory.append(names.get("]")) 14 | return(new_obj) 15 | 16 | print <- fun[self]: 17 | print("Match error:") 18 | print(memory.get(`self)) 19 | 20 | attrib <- fun[name receiver searcher]: 21 | if lookup_print: 22 | print("MatchError looking up ") 23 | print(name) 24 | printeol() 25 | return_if(string_equal(name "instance") MatchError.instance) 26 | return_if(string_equal(name "print") MatchError.print) 27 | return_if(string_equal(name "type") "MatchError") 28 | # Class method 29 | # return_if(string_equal(name "is_instance") MatchError.is_instance) 30 | return(instance_attrib(name receiver searcher)) 31 | 32 | MatchError_class <- boot_obj . subclass(MatchError.attrib) 33 | MatchError <- closure(MatchError_class . instance MatchError_class) 34 | 35 | exactly <- fun[char]: 36 | input_char = source . next_char() 37 | if input_char == None(): 38 | return(MatchError("End of file")) 39 | if not(string_equal(char input_char)): 40 | return(MatchError("Not exactly")) 41 | return(`input_char) 42 | 43 | between <- fun[start end]: 44 | input_char = source . next_char() 45 | if input_char == None(): 46 | return(MatchError("End of file")) 47 | if not(char_between(start end input_char)): 48 | return(MatchError("Not between")) 49 | return(`input_char) 50 | 51 | token <- fun[char]: 52 | input_char = source . next() 53 | if input_char == None(): 54 | return(MatchError("End of file")) 55 | if not(string_equal(char input_char)): 56 | return(MatchError("Not exactly")) 57 | return(`input_char) 58 | 59 | next_child <- fun[children]: 60 | if memory.get(children) == end_of_func: 61 | return_two(0 0) 62 | return_two(children + 2 memory.get(children + 1)) 63 | 64 | or <- fun[children]: 65 | saved = source . position() 66 | saved children = s21() 67 | children child = next_child(`children) 68 | repeat_if: 69 | output = call(`child) 70 | if not(is_instance(output MatchError_class)): 71 | return(`output) 72 | drop1(`output) 73 | source . position_set(saved) 74 | children child = next_child(`children) 75 | return(MatchError("No OR child matches")) 76 | 77 | out <- fun[child]: 78 | output = call(`child) 79 | if is_instance(output MatchError_class): 80 | return(`output) 81 | # Should wrap in resizable? Otherwise, it could be an str with no .print 82 | return(node("out" output)) 83 | 84 | is_output <- fun[output]: 85 | if is_instance(output node_class): 86 | return(string_equal(output . name "out")) 87 | return(False) 88 | 89 | # Need to preserve pos! Maybe not so important for strings? 90 | make_string <- fun[outputs]: 91 | if is_instance(outputs resizable_class): 92 | length = outputs . len 93 | if length == 0: 94 | # empty_string() 95 | return(outputs) 96 | output = outputs . get(0) 97 | if is_str(output): 98 | if str_len(output) == 1: 99 | return(str_join(outputs . array + 1 length)) 100 | if length == 1: 101 | return(output) 102 | return(outputs) 103 | else: 104 | if is_instance(outputs node_class): 105 | if is_str(outputs . children): 106 | return(outputs . children) 107 | return(outputs) 108 | 109 | and <- fun[init_children]: 110 | saved = source . position() 111 | outputs = resizable(0) 112 | output_mode = False 113 | children = init_children 114 | children child = next_child(`children) 115 | repeat_if: 116 | output = call(`child) 117 | if is_instance(output MatchError_class): 118 | source . position_set(saved) 119 | return(MatchError("And match failed")) 120 | # debugger() 121 | if output_mode: 122 | if is_output(output): 123 | outputs . append_array(output . children) 124 | drop1(`output) 125 | else: 126 | if is_output(output): 127 | outputs = resizable(0) 128 | outputs . append_array(output . children) 129 | output_mode = True 130 | outputs output_mode children = s4127() 131 | else: 132 | # Maybe need an extra case depending on if its a node or resizable. 133 | outputs . append_array(output) 134 | # Should really be a swap (s21) above. 135 | drop1(`output) 136 | children child = next_child(`children) 137 | # node("And" outputs) 138 | return(make_string(outputs)) 139 | 140 | get_bounds <- fun[quantifier]: 141 | if string_equal(quantifier "*"): 142 | return_two(0 c.infinity()) 143 | if string_equal(quantifier "+"): 144 | return_two(1 c.infinity()) 145 | if string_equal(quantifier "?"): 146 | return_two(0 1) 147 | error("Unknown quantifier") 148 | 149 | quantified <- fun[child quantifier]: 150 | lower upper = get_bounds(`quantifier) 151 | outputs = resizable(0) 152 | start_saved = source . position() 153 | count = 0 154 | repeat: 155 | saved = source . position() 156 | output = call(child) 157 | if is_instance(output MatchError_class): 158 | if count < lower: 159 | source . position_set(start_saved) 160 | return(MatchError("Quantified undermatch")) 161 | source . position_set(saved) 162 | return(make_string(outputs)) 163 | outputs . append_array(`output) 164 | drop1(`saved) 165 | count = `count + 1 166 | if count == upper: 167 | return(make_string(outputs)) 168 | 169 | negation <- fun[child]: 170 | saved = source . position() 171 | saved child = s21() 172 | output = call(`child) 173 | source . position_set(saved) 174 | if is_instance(output MatchError_class): 175 | return(None()) 176 | return(MatchError("Negation is true")) 177 | 178 | bound <- fun[child name]: 179 | saved = source . position() 180 | output = call(child) 181 | if is_instance(output MatchError_class): 182 | return(output) 183 | return(nodep(name output pair(saved source . position()))) 184 | 185 | should_make_node <- fun[output]: 186 | if is_instance(output resizable_class): 187 | return(output . len > 1) 188 | return(False) 189 | 190 | parseg <- hashtable(40) 191 | 192 | debug_parse <- fun[]: 193 | parseg . set("apply_print" True) 194 | 195 | init_parseg <- fun[grammar_obj]: 196 | # TODO make this not index based. 197 | # Could almost overwrite parseg if grammar_obj was a hashtable 198 | parseg . set("prefix" grammar_obj . get(0)) 199 | parseg . set("rules" grammar_obj . get(1)) 200 | #rules <- cheat_dict() 201 | parseg . set("flagged" grammar_obj . get(2)) 202 | parseg . set("base_rules" grammar_obj . get(3)) 203 | parseg . set("nest" 0) 204 | parseg . set("apply_print" False) 205 | # Could reuse the same one 206 | parseg . set("indentation" resizable(0)) 207 | parseg . get("indentation") . append(0) 208 | memoizer.reset() 209 | 210 | # Reverse the names of _apply and apply to toggle memoizer. 211 | 212 | _apply <- fun[name]: 213 | error("Dummy") 214 | 215 | _apply <- fun[name]: 216 | nesting = parseg . get("nest") 217 | saved = source . position() 218 | if parseg . get("apply_print"): 219 | i = nesting 220 | repeat_if: 221 | printspace() 222 | i = `i - 1 223 | print(name) 224 | printspace() 225 | tprint(source . position()) 226 | printeol() 227 | parseg . set("nest" nesting + 1) 228 | output = call(hashtable.get(name parseg . get("rules"))) 229 | # output = call(_cheat_dict.get(name parseg . get("rules"))) 230 | parseg . set("nest" nesting) 231 | if parseg . get("apply_print"): 232 | i = nesting 233 | repeat_if: 234 | printspace() 235 | i = `i - 1 236 | print(name) 237 | printspace() 238 | tprint(source . position()) 239 | print(" -> ") 240 | tprint(output) 241 | printeol() 242 | if string_equal(name "statement"): 243 | i = nesting 244 | repeat_if: 245 | printspace() 246 | i = `i - 1 247 | print(name) 248 | print(" -> ") 249 | tprint(output) 250 | printeol() 251 | if is_instance(output MatchError_class): 252 | return(output) 253 | if should_make_node(output): 254 | print("Making node ") 255 | printraw(name) 256 | printeol() 257 | return(nodep(name output pair(saved source . position()))) 258 | if parseg . get("flagged") . string_index(name) == None(): 259 | return(output) 260 | return(nodep(name output pair(saved source . position()))) 261 | 262 | # push: foo apply 263 | apply <- fun[name]: 264 | mem_out new_pos memoized = memoizer.get(name source . position() parseg . get("indentation")) 265 | if `memoized: 266 | source . position_set(`new_pos) 267 | return(`mem_out) 268 | else: 269 | saved = source . position() 270 | output = _apply(name) 271 | memoizer.set(name saved parseg . get("indentation") output source . position()) 272 | return(`output) 273 | 274 | base.rules.anything <- fun[]: 275 | char = source . next_char() 276 | if char == None(): 277 | return(MatchError("End of file")) 278 | return(`char) 279 | 280 | base.rules.void <- fun[]: 281 | return(None()) 282 | 283 | base.rules.letter <- fun[]: 284 | return(or([[between("a" "z")] [between("A" "Z")]])) 285 | 286 | base.rules.digit <- fun[]: 287 | return(between("0" "9")) 288 | 289 | base.rules.name <- fun[]: 290 | return(and([[or([[apply("rule.letter")] [exactly("_")]])] [quantified([or([[apply("rule.letter")] [apply("rule.digit")] [exactly("_")]])] "*")]])) 291 | 292 | base.rules.wrapped_escaped_char <- fun[]: 293 | output = apply("raw_escaped_char") 294 | if is_instance(output MatchError_class): 295 | return(output) 296 | if string_equal(output "t"): 297 | return("\t") 298 | if string_equal(output "n"): 299 | return("\n") 300 | if string_equal(output "r"): 301 | return("\r") 302 | if string_equal(output "\\"): 303 | return("\\") 304 | if string_equal(output "'"): 305 | return("'") 306 | if string_equal(output '"'): 307 | return('"') 308 | error("Unknown escaped char") 309 | 310 | add_base_rules <- fun[rules]: 311 | hashtable.set("letter" base.rules.letter rules) 312 | hashtable.set("digit" base.rules.digit rules) 313 | hashtable.set("anything" base.rules.anything rules) 314 | hashtable.set("void" base.rules.void rules) 315 | 316 | add_escaped_char_rules <- fun[rules]: 317 | hashtable.set("raw_escaped_char" rules . get("escaped_char") rules) 318 | hashtable.set("escaped_char" base.rules.wrapped_escaped_char rules) 319 | 320 | # source_index = functions.end() + 5 321 | # source <- Input("grammar/boot.grammar") 322 | # source <- Input("grammar/flpc.grammar") 323 | # source <- Input("grammar/test.grammar") 324 | source <- None() -------------------------------------------------------------------------------- /lib/stage2.flpc: -------------------------------------------------------------------------------- 1 | 2 | memoizer.reset() 3 | print("Running_grammar") 4 | printeol() 5 | # Still can't run both even with memoizer_reset 6 | #output = apply("grammar") 7 | #output . print() 8 | save("stage2.pkl") 9 | 10 | -------------------------------------------------------------------------------- /lib/stage3a.flpc: -------------------------------------------------------------------------------- 1 | 2 | load("stage2.pkl") 3 | 4 | to_flpc2 <- fun[root]: 5 | error("Dummy function should not be called") 6 | 7 | to_flpc2 <- fun[root]: 8 | # print(root . type) 9 | if not(is_instance(root node_class)): 10 | printrepr(root) 11 | return_no_value() 12 | name = root . name 13 | if string_equal(name "quantifier"): 14 | return_no_value(to_flpc2(root . get(0))) 15 | if string_equal(name "inline"): 16 | return_no_value(to_flpc2(root . get(0))) 17 | if (string_equal(name "exactly") || string_equal(name "token")) && is_instance(root . get(0) node_class): 18 | if not(string_equal(root . get(0) . name "escaped_char")): 19 | tprint(root . get(0)) 20 | error("Unexpected child of exactly. Was expecting a escaped chart.") 21 | # printrepr(to_flpc2(root . get(0) . get(0))) 22 | return_no_value(to_flpc2(node(root . name root . get(0) . get(0)))) 23 | if string_equal(name "rule"): 24 | printraw(parseg . get("prefix")) 25 | print(".rules.") 26 | printraw(root . get(0) . get(0)) 27 | print(" <- fun[]:\n return(") 28 | to_flpc2(root . get(3)) 29 | print(")") 30 | return_no_value() 31 | 32 | if string_equal(name "output"): 33 | print("out") 34 | else: 35 | printraw(name) 36 | print("(") 37 | if string_equal(name "and"): 38 | print("[") 39 | if string_equal(name "or"): 40 | print("[") 41 | l = root . len 42 | i = l 43 | repeat_if: 44 | child = root . get(l - i) 45 | bracket = 0 46 | if not(is_instance(child node_class)): 47 | bracket = `bracket + 1 48 | else: 49 | if string_equal(child . name "quantifier"): 50 | bracket = `bracket + 1 51 | if string_equal(child . name "inline"): 52 | bracket = `bracket + 1 53 | if not(bracket): 54 | print("[") 55 | bracket child = s21() 56 | to_flpc2(`child) 57 | if not(`bracket): 58 | print("]") 59 | i = `i - 1 60 | if i > 0: 61 | print(" ") 62 | if string_equal(name "and"): 63 | print("]") 64 | if string_equal(name "or"): 65 | print("]") 66 | print(")") 67 | 68 | print_grammar_funcs <- fun[root]: 69 | l = root . len 70 | i = l 71 | repeat_if: 72 | # Should exclude letter and digits 73 | to_flpc2(root . get(l - i)) 74 | printeol() 75 | printeol() 76 | i = `i - 1 77 | 78 | print_ruleset <- fun[ruleset]: 79 | printraw(ruleset) 80 | print("(") 81 | printraw(parseg . get("prefix")) 82 | print(".rules)") 83 | printeol() 84 | 85 | # Need to shorten this once we get more syntax. 86 | # Or maybe with nested functions, or escape chars. 87 | print_grammar_obj <- fun[]: 88 | prefix = parseg . get("prefix") 89 | printraw(prefix) 90 | print(".base <- resizable(0)") 91 | printeol() 92 | l = parseg . get("base_rules") . len 93 | i = l 94 | repeat_if: 95 | printraw(prefix) 96 | print('.base . append("') 97 | printraw(parseg . get("base_rules") . get(l - i)) 98 | print('")') 99 | printeol() 100 | i = `i - 1 101 | printraw(prefix) 102 | print(" <- resizable(0)") 103 | printeol() 104 | 105 | printraw(prefix) 106 | print(' . append("') 107 | printraw(prefix) 108 | print('")') 109 | printeol() 110 | 111 | printraw(prefix) 112 | print(' . append(') 113 | printraw(prefix) 114 | print('.rules)') 115 | printeol() 116 | 117 | printraw(prefix) 118 | print(' . append(') 119 | printraw(prefix) 120 | print('.flagged)') 121 | printeol() 122 | 123 | printraw(prefix) 124 | print(' . append(') 125 | printraw(prefix) 126 | print('.base)') 127 | printeol() 128 | 129 | print_child_setter <- fun[child]: 130 | name = child . get(0) . get(0) 131 | print('hashtable.set("') 132 | printraw(name) 133 | print('" ') 134 | printraw(parseg . get("prefix")) 135 | print(".rules.") 136 | printraw(name) 137 | print(' ') 138 | printraw(parseg . get("prefix")) 139 | print('.rules)') 140 | printeol() 141 | if child . get(1) . len > 0: 142 | printraw(parseg . get("prefix")) 143 | print('.flagged . append("') 144 | printraw(name) 145 | print('")') 146 | printeol() 147 | 148 | print_grammar_setters <- fun[root]: 149 | l = root . len 150 | printraw(parseg . get("prefix")) 151 | print('.rules <- hashtable(') 152 | print(int_to_str(l + l + l + l)) 153 | print(')') 154 | printeol() 155 | printraw(parseg . get("prefix")) 156 | print('.flagged <- resizable(0)') 157 | printeol() 158 | i = l 159 | repeat_if: 160 | print_child_setter(root . get(l - i)) 161 | i = `i - 1 162 | 163 | l = parseg . get("base_rules") . len 164 | i = l 165 | repeat_if: 166 | print_ruleset(parseg . get("base_rules") . get(l - i)) 167 | i = `i - 1 168 | 169 | print_grammar_all <- fun[root]: 170 | print_grammar_funcs(root) 171 | print_grammar_setters(`root) 172 | print_grammar_obj() 173 | 174 | parse_grammar <- fun[grammar_obj input_filename]: 175 | names2() . set("source" Input(input_filename)) 176 | init_parseg(grammar_obj) 177 | print(parseg) 178 | printeol() 179 | output = apply("grammar") 180 | return(output) 181 | 182 | write_parsed_funcs <- fun[grammar_obj input_filename output_filename]: 183 | output = parse_grammar(grammar_obj input_filename) 184 | output . print() 185 | printeol() 186 | print("Writing ") 187 | printraw(output_filename) 188 | printeol() 189 | print(output . name) 190 | printeol() 191 | outf = file.open("w" output_filename) 192 | set_output(outf) 193 | if not(string_equal(output . name "grammar")): 194 | wrapped = resizable(1) 195 | wrapped . set(0 output) 196 | else: 197 | wrapped = output 198 | print_grammar_funcs(wrapped) 199 | l = wrapped . len 200 | i = l 201 | repeat_if: 202 | print_child_setter(wrapped . get(l - i)) 203 | i = `i - 1 204 | set_output(None()) 205 | file.close(outf) 206 | 207 | write_parsed <- fun[grammar_obj input_filename output_filename]: 208 | output = parse_grammar(grammar_obj input_filename) 209 | output . print() 210 | printeol() 211 | print("Writing ") 212 | printraw(output_filename) 213 | printeol() 214 | outf = file.open("w" output_filename) 215 | set_output(outf) 216 | print_grammar_all(output) 217 | set_output(None()) 218 | file.close(outf) 219 | -------------------------------------------------------------------------------- /lib/stage3b.flpc: -------------------------------------------------------------------------------- 1 | base.rules.SAME_INDENT <- fun[]: 2 | saved = source . position() 3 | s = make_string(apply('hspaces')) 4 | if parseg . get("indentation") . top() == str_len(s): 5 | return(None()) 6 | source . position_set(saved) 7 | return(MatchError("Different indent")) 8 | 9 | base.rules.DEDENT <- fun[]: 10 | parseg . get("indentation") . pop() 11 | return(None()) 12 | 13 | base.rules.INDENT <- fun[]: 14 | saved = source . position() 15 | if is_instance(apply('NEWLINE') MatchError_class): 16 | source . position_set(saved) 17 | return(MatchError("Missing newline before indent")) 18 | s = make_string(apply('hspaces')) 19 | source . position_set(saved) 20 | parseg . get("indentation") . append(str_len(s)) 21 | return(None()) 22 | 23 | # Need new token function anyways 24 | token <- fun[s]: 25 | saved = source . position() 26 | drop1(apply("spaces")) 27 | if is_alpha(s): 28 | output = apply("NAME") 29 | if is_instance(output node_class): 30 | # output . children 31 | output = make_string(memory.get(`output + 1)) 32 | else: 33 | output = source . startswith(s) 34 | if output == None(): 35 | return(MatchError("Not token or EOF")) 36 | return(`output) 37 | if is_instance(output MatchError_class): 38 | return(output) 39 | if output == None(): 40 | return(MatchError("End of file")) 41 | if not(string_equal(output s)): 42 | return(MatchError("Not exactly token")) 43 | return(output) 44 | 45 | # names.set doesn't work well with pick: caching. 46 | 47 | # Need rebind:, but this isn't a function! 48 | # So rebind will do something random. 49 | # rules <- boot_dict(100) 50 | # Reset the keys and values array instead. 51 | #print("Regenerating_") 52 | #print(rules . len) 53 | #printeol() 54 | #memory.set(rules + 1 boot_array(rules . len)) 55 | #memory.set(rules + 2 boot_array(rules . len)) 56 | 57 | #names.set("rules" boot_dict(100)) 58 | #names.set("rules" cheat_dict()) 59 | 60 | add_indent_rules <- fun[rules]: 61 | hashtable.set("INDENT" base.rules.INDENT rules) 62 | hashtable.set("DEDENT" base.rules.DEDENT rules) 63 | hashtable.set("SAME_INDENT" base.rules.SAME_INDENT rules) -------------------------------------------------------------------------------- /lib/stage4.flpc: -------------------------------------------------------------------------------- 1 | 2 | load("flpc_grammar.pkl") 3 | # memory.set(source_index Input("lib/stage1.flpc")) 4 | source <- Input("lib/stage1a.flpc") 5 | # names.set("source" Input("lib/stage1.flpc")) 6 | # rules . print() 7 | memoizer.reset() 8 | print("Running_flpc_grammar") 9 | printeol() 10 | output = apply("grammar") 11 | output . print() 12 | save("flpc_parsed.pkl") 13 | -------------------------------------------------------------------------------- /lib/stage5.flpc: -------------------------------------------------------------------------------- 1 | 2 | load("flpc_parsed.pkl") 3 | print_indent <- fun[indent]: 4 | i = indent 5 | repeat_if: 6 | printspace() 7 | i = `i - 1 8 | 9 | pprint <- fun[indent self]: 10 | error("Dummy_function") 11 | 12 | print_child <- fun[indent child]: 13 | if is_instance(child node_class): 14 | pprint(indent + 2 child) 15 | else: 16 | if is_str(child): 17 | if str_len(child) > 0: 18 | print_indent(indent + 2) 19 | print("str_'") 20 | printraw(child) 21 | print("'") 22 | printeol() 23 | 24 | pprint <- fun[indent self]: 25 | if string_equal(self . name "exprsp"): 26 | pprint(indent self . children . get(0)) 27 | return_no_value() 28 | bad = False 29 | if is_instance(self . children resizable_class): 30 | if self . children . len == 2: 31 | child = self . children . get(1) 32 | if is_str(child): 33 | if str_len(`child) == 0: 34 | bad = `bad + 1 35 | else: 36 | drop1(`child) 37 | child = self . children . get(0) 38 | if is_str(child): 39 | if str_len(`child) == 0: 40 | bad = `bad + 1 41 | if string_equal(self . name "exprs"): 42 | if bad: 43 | pprint(indent self . children . get(0)) 44 | return(None()) 45 | if string_equal(self . name "suite"): 46 | if bad: 47 | pprint(indent self . children . get(1)) 48 | return(None()) 49 | print_indent(indent) 50 | printraw(self . name) 51 | printeol() 52 | children = self . children 53 | if not(is_instance(self . children resizable_class)): 54 | print_child(indent children) 55 | else: 56 | l = children . len 57 | i = l 58 | repeat_if: 59 | print_child(indent children . get(l - i)) 60 | i = `i - 1 61 | 62 | pprint(0 output) 63 | # tprint(output) -------------------------------------------------------------------------------- /lib/stage6a.flpc: -------------------------------------------------------------------------------- 1 | 2 | lazy_and <- local_fun[cond2_thunk cond1]: 3 | if `cond1: 4 | cond = call(`cond2_thunk) 5 | else: 6 | drop1(`cond2_thunk) 7 | cond = False 8 | 9 | debugger2 <- fast_fun[]: 10 | drop1(1) 11 | #print("debug") 12 | #printeol() 13 | 14 | dprint <- fun[title value]: 15 | print(title) 16 | tprint(value) 17 | printeol() 18 | 19 | # Actually a local_fun but we're re-ordering the params right away anyways 20 | simple_for <- fast_fun[end start block]: 21 | block end index = shuffle("231") 22 | cond = index < end 23 | repeat_if: 24 | drop1(`cond) 25 | call(block) 26 | # block needs to include a shuffl back to normal 27 | index = `index + 1 28 | cond = index < end 29 | drop1(`index) 30 | drop1(`end) 31 | drop1(`block) 32 | 33 | # Use memory location as Singleton 34 | memory.append(None()) 35 | Done <- Pointer(memory.len() - 1) 36 | 37 | make_resizable <- fast_fun[]: 38 | new_resizable = resizable(0) 39 | new_resizable elem = s21() 40 | not(pick1() == Done) 41 | repeat_if: 42 | drop1() # Condition 43 | new_resizable . append(`elem) 44 | new_resizable elem = s21() 45 | not(pick1() == Done) 46 | shuffle("23") # return(new_resizable) and drop elem = Done 47 | 48 | make_resizable_len <- fast_fun[num]: 49 | new_resizable = resizable(0) 50 | new_resizable num = s21() 51 | simple_for(`num 0 fast_fun[index]: 52 | new_resizable block end index elem = shuffle("51234") 53 | new_resizable . append(`elem)) 54 | shuffle("12") # return(new_resizable) 55 | 56 | make_resizable_rev <- fast_fun[]: 57 | res = make_resizable() 58 | # Reverse 59 | l = res . len - 1 60 | i = (l + 1) / 2 61 | repeat_if: 62 | i = `i - 1 63 | tmp = res . get(i) 64 | res . set(i res . get(l - i)) 65 | res . set(l - i tmp) 66 | drop1(`tmp) 67 | shuffle("23") # return(res) 68 | 69 | str_cat <- fast_fun[]: 70 | # make_resizable(*args) 71 | arr = make_resizable() 72 | joined = str_join(arr . array + 1 arr . len) 73 | # return joined 74 | shuffle("13") 75 | 76 | str_cat2 <- fast_fun[]: 77 | # make_resizable(*args) 78 | arr = make_resizable_rev() 79 | joined = str_join(arr . array + 1 arr . len) 80 | # return joined 81 | shuffle("13") 82 | 83 | for_in <- local_fun[iterable block2]: 84 | simple_for(iterable . len 0 fast_fun[index]: 85 | elem = iterable . get(index) 86 | call(block2)) 87 | drop1(`block2) 88 | drop1(`iterable) 89 | 90 | list_comp <- local_fun[block3 iterable]: 91 | list_comp_out = resizable(0) 92 | for_in(iterable fast_fun[elem]: 93 | list_comp_out . append(call(block3)) 94 | drop1(`elem)) 95 | # Leaving list_comp_out unnamed so the calling function can name this 96 | shuffle("14") 97 | 98 | list_comp_var <- local_fun[block3 var_name iterable]: 99 | list_comp_out = resizable(0) 100 | for_in(iterable fast_fun[elem]: 101 | assign2(elem var_name) 102 | list_comp_out . append(call(block3)) 103 | drop1() # var_name 104 | drop1(`elem)) 105 | # Leaving list_comp_out unnamed so the calling function can name this 106 | shuffle("15") 107 | 108 | list_comp_cond <- local_fun[block3 iterable condition]: 109 | list_comp_out = resizable(0) 110 | for_in(iterable fast_fun[elem]: 111 | if call(condition): 112 | list_comp_out . append(call(block3)) 113 | drop1(`elem)) 114 | # Leaving list_comp_out unnamed so the calling function can name this 115 | shuffle("14") 116 | 117 | FList_class <- boot_obj . subclass(resizable.attrib) 118 | FList <- closure(FList_class . instance FList_class) 119 | 120 | # Confused. This works for lookups but need to not have the -1 for is_instance to work. 121 | change_class <- fun[obj new_class]: 122 | memory.set(obj - 2 new_class) 123 | 124 | extend <- fun[in_list out_list]: 125 | for_in(in_list fast_fun[elem]: 126 | out_list . append(`elem)) 127 | 128 | flatten <- fun[in_list class]: 129 | out_list = resizable(0) 130 | for_in(in_list fast_fun[elem]: 131 | if is_instance(elem class): 132 | extend(`elem out_list) 133 | else: 134 | out_list . append(`elem)) 135 | return(`out_list) 136 | 137 | # Wrapper for a single Forth call 138 | # Subclass of node (via attribs) 139 | forthe <- class[]: 140 | print <- fun[self]: 141 | tprint(memory.get(self + 1)) 142 | 143 | attrib <- fun[name receiver searcher]: 144 | if lookup_print: 145 | print("Forthe looking up ") 146 | print(name) 147 | printeol() 148 | return_if(string_equal(name "get") node.get) 149 | return_if(string_equal(name "instance") node.instance) 150 | return_if(string_equal(name "print") forthe.print) 151 | return_if(string_equal(name "len") node.len(receiver)) 152 | return_if(string_equal(name "name") memory.get(receiver)) 153 | return_if(string_equal(name "value") memory.get(receiver + 1)) 154 | return_if(string_equal(name "pos") memory.get(receiver + 2)) 155 | return_if(string_equal(name "set_pos") node.set_pos) 156 | return_if(string_equal(name "type") "forthe") 157 | return(instance_attrib(name receiver searcher)) 158 | 159 | forthe_class <- boot_obj . subclass(forthe.attrib) 160 | forthe <- closure(forthe_class . instance forthe_class) 161 | 162 | forthep <- fun[name value pos]: 163 | res = forthe(name value) 164 | res . set_pos(pos) 165 | return(res) 166 | 167 | # Hack where name == "_" means not yet set! 168 | FQuote <- class[]: 169 | set_name <- fun[new_name self]: 170 | memory.set(s21()) # self new_name 171 | 172 | attrib <- fun[name receiver searcher]: 173 | if lookup_print: 174 | print("FQuote looking up ") 175 | print(name) 176 | printeol() 177 | return_if(string_equal(name "get") node.get) 178 | return_if(string_equal(name "instance") node.instance) 179 | return_if(string_equal(name "print") node.print) 180 | return_if(string_equal(name "set_name") FQuote.set_name) 181 | return_if(string_equal(name "len") node.len(receiver)) 182 | return_if(string_equal(name "name") memory.get(receiver)) 183 | return_if(string_equal(name "value") memory.get(receiver + 1)) 184 | return_if(string_equal(name "pos") memory.get(receiver + 2)) 185 | return_if(string_equal(name "set_pos") node.set_pos) 186 | return_if(string_equal(name "type") "FQuote") 187 | return(instance_attrib(name receiver searcher)) 188 | 189 | FQuote_class <- boot_obj . subclass(FQuote.attrib) 190 | FQuote <- closure(FQuote_class . instance FQuote_class) 191 | 192 | FQuote.hash <- convert_attr(FQuote_class) 193 | FQuote.attrib <- fun[name receiver searcher]: 194 | hash_header() 195 | call(hashtable.get(name FQuote.hash)) 196 | 197 | FQuotep <- fun[name value pos]: 198 | res = FQuote(name value) 199 | res . set_pos(pos) 200 | return(res) 201 | 202 | to_flist <- fun[array]: 203 | change_class(array FList_class) 204 | return(`array) 205 | 206 | array.clear <- fun[self]: 207 | i = memory.get(self) 208 | repeat_if: 209 | memory.set(self + i + 1 0) 210 | i = `i - 1 -------------------------------------------------------------------------------- /lib/stage7a.flpc: -------------------------------------------------------------------------------- 1 | 2 | # Nothing else from the compiled file will run if we run this! 3 | # So it has to be the last thing in the compiled file. 4 | # What's a good way to do nesting? Or should we go the 5 | # continuation passing route? 6 | # Also need to exit the function that called run. 7 | compile_temp <- fun[filename temp_filename]: 8 | init_g(temp_filename) 9 | g . set("autogen_name" "tempgen") 10 | set_output(g . get("pos_file")) 11 | print(str_cat(Done "\n" temp_filename "1 ")) 12 | set_output(None()) 13 | compile_file(filename) 14 | file.close(g . get("file")) 15 | file.close(g . get("pos_file")) 16 | 17 | run_file <- fast_fun[filename]: 18 | current_input_file() 19 | switch_input_file() # filename 20 | continue_from_file() # implicitly means continue from previous file 21 | 22 | run_temp <- fun[filename temp_filename]: 23 | compile_temp(filename temp_filename) 24 | run_file(temp_filename) 25 | 26 | run <- fun[filename]: 27 | compile_temp(`filename "gen/temp.f") 28 | run_file("gen/temp.f") 29 | 30 | outf <- 1 # Dummy value 31 | 32 | write_file <- fun[str filename]: 33 | file.open_at("w" filename outf) 34 | set_output(outf) 35 | print("# Generated") 36 | printeol() 37 | printraw(str) 38 | printeol() 39 | set_output(None()) 40 | file.close(outf) 41 | 42 | append_file <- fun[str filename]: 43 | file.open_at("a" filename outf) 44 | set_output(outf) 45 | printraw(str) 46 | printeol() 47 | set_output(None()) 48 | file.close(outf) 49 | 50 | eval_one <- fun[]: 51 | print(">> ") 52 | source = stdin.next_line() 53 | write_file(source "gen/eval.flpc") 54 | run("gen/eval.flpc") 55 | 56 | eval_repl <- fun[]: 57 | repeat: 58 | print(">> ") 59 | source = stdin.next_line() 60 | if source == None() || string_equal(source "q"): 61 | return() 62 | write_file(`source "gen/eval.flpc") 63 | run("gen/eval.flpc") 64 | 65 | debug_separator <- "debug_separator" # resizable(0) 66 | 67 | print_until_sep <- fast_fun[]: 68 | cond = not(pick1() == debug_separator) 69 | repeat_if: 70 | drop1(`cond) 71 | tprint() 72 | printeol() 73 | cond = not(pick1() == debug_separator) 74 | drop1() # debug_separator 75 | 76 | debug_g <- hashtable(20) 77 | 78 | help <- fun[func]: 79 | # Prints the source of the function 80 | # For example help(help) or help(for_in) 81 | if is_basic(func): 82 | print(func) 83 | else: 84 | if str_endswith("instance creator" get_mem_hint(func)): 85 | # Todo get the . attr once all this string stuff is fixed. 86 | class_name = get_class_name(func) 87 | print(class_name) 88 | print(" with keys\n") 89 | tprint(names2() . get(class_name) . attr) 90 | printeol() 91 | print("Type help(") 92 | print(class_name) 93 | print(" . method) to get help on specific methods of this class.") 94 | else: 95 | print_frame(True 3 func) 96 | printeol() 97 | 98 | look <- fun[]: 99 | print_frame(False debug_g . get("context") call_stack.len() - (debug_g . get("height"))) 100 | 101 | run_and_print <- fast_fun[filename]: 102 | current_input_file() 103 | debug_separator 104 | s21() 105 | switch_input_file() 106 | # Problem: When we assign values, we don't want them to be cleared 107 | # I guess no local vars then? Or have some syntax for "keep" 108 | print("-----") 109 | printeol() 110 | # debugger() 111 | print_until_sep() 112 | continue_from_file() 113 | 114 | debuggerv2 <- fast_fun[]: 115 | debug_g . set("height" 8) 116 | debug_g . set("context" 2) 117 | debug_g . set("multiline" False) 118 | repeat: 119 | print(">> ") 120 | source = stdin.next_line() 121 | if source == None() || string_equal(source "q"): 122 | # Returns too much because this is a fast_fun 123 | # Could turn the repeat into a repeat_if, but ugly. 124 | # Need another kind of function that adds func sep but not data sep? 125 | run(names2() . get("dv2loop_file")) 126 | # return() 127 | elif string_equal(source "u"): 128 | drop1() 129 | debug_g . set("height" debug_g . get("height") + 1) 130 | look() 131 | elif string_equal(source "d"): 132 | drop1() 133 | debug_g . set("height" debug_g . get("height") - 1) 134 | look() 135 | elif string_equal(source "l"): 136 | drop1() 137 | debug_g . set("context" debug_g . get("context") + 1) 138 | look() 139 | elif string_equal(source "L"): 140 | drop1() 141 | debug_g . set("context" debug_g . get("context") - 1) 142 | look() 143 | elif string_equal(source "m"): 144 | debug_g . set("multiline" not(debug_g . get("multiline"))) 145 | write_file("#Empty" "gen/eval.flpc") 146 | elif string_equal(source "f"): 147 | run_and_print("gen/temprun.f") 148 | elif debug_g . get("multiline"): 149 | if string_equal(source "r"): 150 | debug_separator 151 | compile_temp("gen/eval.flpc" "gen/temp.f") 152 | run_and_print("gen/temp.f") 153 | debug_g . set("multiline" not(debug_g . get("multiline"))) 154 | else: 155 | append_file(source "gen/eval.flpc") 156 | elif str_len(source) == 0: 157 | # Empty line, do nothing 158 | drop1() 159 | elif True: 160 | # Need an exec and var assign 161 | # Could just use files/run for now. 162 | write_file(`source "gen/eval.flpc") 163 | compile_temp("gen/eval.flpc" "gen/temp.f") 164 | run_and_print("gen/temp.f") 165 | 166 | error_handler_set(debuggerv2) 167 | 168 | grammar_eval_file <- fun[filename]: 169 | bootg . set(0 "flpcg") 170 | write_parsed_funcs(bootg filename "gen/grammar_temp.flpc") 171 | run("gen/grammar_temp.flpc") 172 | 173 | grammar_eval_file_with_out <- fun[filename output_prefix]: 174 | bootg . set(0 "flpcg") 175 | write_parsed_funcs(bootg filename str_cat(Done ".flpc" output_prefix)) 176 | run_temp(str_cat(Done ".flpc" output_prefix) str_cat(Done ".f" output_prefix)) 177 | 178 | add_getter_syntax <- fun[]: 179 | g . set("autogen_name" "getter_gen") 180 | grammar_eval_file_with_out("grammar/getter.grammar" "gen/getter_syntax") 181 | 182 | get <- fun[obj index]: 183 | return(obj . get(index)) 184 | 185 | names2() . set("!" get) 186 | 187 | to_forth_conv.TRIPLE_QUOTE <- fun[root]: 188 | return(changed_class(FList_class make_resizable(Done 189 | forthep("FCall" "'''" root . pos) 190 | forthep("FStr" root . get(0) root . pos) 191 | forthep("FCall" "'''" root . pos) ))) 192 | 193 | add_triple_quote <- fun[]: 194 | g . set("autogen_name" "triple_quote_gen") 195 | grammar_eval_file_with_out("grammar/triple_quote.grammar" "gen/triple_quote") 196 | to_forth_conv_hash . set("TRIPLE_QUOTE" to_forth_conv.TRIPLE_QUOTE) 197 | 198 | to_forth_conv.make_resizable <- fun[root]: 199 | output = make_resizable(Done forthep("FStr" "Done" root . pos) 200 | forthep("FCall" "pick:" root . pos)) 201 | extend(list_comp([to_forth(elem)] root) output) 202 | output = flatten(`output FList_class) 203 | output . append(forthep("FCall" root . name root . pos)) 204 | return(changed_class(FList_class output)) 205 | 206 | add_resizable_syntax <- fun[]: 207 | g . set("autogen_name" "resizable_syntax_gen") 208 | grammar_eval_file_with_out("grammar/resizable.grammar" "gen/resizable_syntax") 209 | to_forth_conv_hash . set("make_resizable" to_forth_conv.make_resizable) 210 | 211 | add_list_comp_syntax <- fun[]: 212 | g . set("autogen_name" "list_comp_syntax_gen") 213 | grammar_eval_file_with_out("grammar/list_comp.grammar" "gen/list_comp_syntax") 214 | to_forth_conv_hash . set("list_comp_var" to_forth_conv.list_comp_var) 215 | 216 | to_forth_conv.list_comp_var <- fun[root]: 217 | #output = list_comp([to_forth(elem)] root) 218 | output = make_resizable(Done 219 | to_forth(root . get(2)) 220 | forthep("FStr" root . get(1) . get(0) root . get(1) . pos) 221 | forthep("FCall" "push:" root . get(1) . pos) 222 | FQuotep(" " to_forth(root . get(0)) root . get(1) . pos) ) 223 | output = flatten(`output FList_class) 224 | output . append(forthep("FCall" root . name root . pos)) 225 | return(changed_class(FList_class output)) 226 | 227 | # Assumes index and end are in scope and point to the right things. 228 | # Now replaced by opt.incr 229 | simple_for_incr <- fast_fun[]: 230 | index = `index + 1 231 | index < end 232 | 233 | to_forth_conv.opt_simple_for <- fun[root]: 234 | # end start block 235 | output = make_resizable_rev(Done 236 | to_forth(root . get(0)) 237 | forthep("FCall" "assign:") forthep("FStr" "end" root . get(0) . pos) 238 | to_forth(root . get(1)) 239 | forthep("FCall" "assign:") forthep("FStr" "index" root . get(1) . pos) 240 | to_forth(root . get(2)) forthep("FCall" "call" root . get(2) . pos) 241 | forthep("FCall" "opt.incr" root . pos) 242 | forthep("FCall" "repeat5_if" root . pos) 243 | ) 244 | output . print() 245 | output = flatten(`output FList_class) 246 | return(changed_class(FList_class output)) 247 | 248 | to_forth_conv.opt_for_in <- fun[root]: 249 | # end start block 250 | output = make_resizable_rev(Done 251 | to_forth(root . get(0)) forthe("FCall" "attr_call:") forthe("FStr" "len") 252 | forthe("FCall" "assign:") forthe("FStr" "end") 253 | forthe("FCall" "0") forthe("FCall" "assign:") forthe("FStr" "index") 254 | forthe("FCall" "pick:") forthe("FStr" "index") 255 | forthe("FCall" "pick:") forthe("FStr" "iterable") 256 | forthe("FCall" "attr_call:") forthe("FStr" "get") 257 | forthe("FCall" "assign:") forthe("FStr" "elem") 258 | to_forth(root . get(1)) forthe("FCall" "call") 259 | forthe("FCall" "opt.incr") 260 | forthe("FCall" "repeat5_if") 261 | ) 262 | output = flatten(`output FList_class) 263 | return(changed_class(FList_class output)) 264 | 265 | # String format 266 | to_forth_conv.fmt <- fun[root]: 267 | output = make_resizable(Done forthep("FStr" "Done" root . pos) forthep("FCall" "pick:" root . pos)) 268 | extend(list_comp([to_forth(elem)] root) output) 269 | output = flatten(`output FList_class) 270 | output . append(forthep("FCall" "str_cat3" root . pos)) 271 | return(changed_class(FList_class output)) 272 | 273 | add_f_string_syntax <- fun[]: 274 | g . set("autogen_name" "f_string_gen") 275 | grammar_eval_file_with_out("grammar/f_string.grammar" "gen/f_string") 276 | 277 | getter <- fun[obj index]: 278 | return(obj . get(index)) 279 | 280 | to_forth_conv.assign_op <- fun[root]: 281 | # names operator expressions 282 | names = root . get(0) 283 | if not(names . len == 1): 284 | error("Augmented assignment cannot have more than one target name.") 285 | output = make_resizable_rev(Done forthep("FCall" "pick:" names . pos) 286 | to_forth(names . get(0)) 287 | to_forth(root . get(2)) 288 | forthep("FCall" root . get(1) . get(0) root . get(1) . pos) 289 | forthep("FCall" "assign:" names . pos) 290 | to_forth(names . get(0))) 291 | return(changed_class(FList_class output)) 292 | 293 | names2() . set("!" getter) 294 | 295 | dv2loop <- fun[]: 296 | repeat: 297 | print("debugger_v2") 298 | printeol() 299 | #return(None()) 300 | debuggerv2() 301 | run(names2() . get("dv2loop_file")) 302 | 303 | # Uncomment to (re)generate FlpcForth for extra syntax 304 | #add_triple_quote() 305 | #add_resizable_syntax() 306 | #add_list_comp_syntax() 307 | #add_getter_syntax() 308 | #add_f_string_syntax() 309 | 310 | run_file("gen/triple_quote.f") 311 | to_forth_conv_hash . set("TRIPLE_QUOTE" to_forth_conv.TRIPLE_QUOTE) 312 | run_file("gen/resizable_syntax.f") 313 | to_forth_conv_hash . set("make_resizable" to_forth_conv.make_resizable) 314 | run_file("gen/list_comp_syntax.f") 315 | to_forth_conv_hash . set("list_comp_var" to_forth_conv.list_comp_var) 316 | run_file("gen/getter_syntax.f") 317 | to_forth_conv_hash . set("opt_simple_for" to_forth_conv.opt_simple_for) 318 | to_forth_conv_hash . set("fmt" to_forth_conv.fmt) 319 | run_file("gen/f_string.f") 320 | to_forth_conv_hash . set("assign_op" to_forth_conv.assign_op) 321 | 322 | dv2loop_file <- "lib/stage7b.flpc" 323 | dv2loop() 324 | -------------------------------------------------------------------------------- /lib/stage7a2.flpc: -------------------------------------------------------------------------------- 1 | closure <- fast_fun[]: 2 | F' pushf: push: memory.append memory.append 3 | memory.append 4 | pushf: ] memory.append 5 | memory.len pushi: 4 - Pointer 6 | pick1 push: closure set_mem_hint 'F 7 | 8 | print_array <- fun[iterable]: 9 | l = iterable . len 10 | simple_for(l 0 fast_fun[]: 11 | tprint(iterable . get(l - index - 1))) 12 | 13 | ns_obj <- class[]: 14 | attrib <- fun[name receiver searcher]: 15 | error("Dummy") 16 | 17 | child <- fun[child_hash parent]: 18 | memory.append(parent) 19 | memory.append(ns_obj.attrib) 20 | memory.append(child_hash) 21 | memory.append(names.get("]")) 22 | pointer = Pointer(memory.len() - 2) 23 | set_mem_hint(pointer str_cat(Done " instance" parent . type)) 24 | return(pointer) 25 | 26 | set_attr <- fun[key value self]: 27 | return(self . attr . set(key value)) 28 | 29 | print <- fun[self]: 30 | print("ns_obj instance or subclass") 31 | 32 | getattrib <- fun[name self]: 33 | return(self . attr . get(name)) 34 | 35 | attrib <- fun[name receiver searcher]: 36 | return_if(string_equal(name "attr") memory.get(receiver)) 37 | value = searcher . attr . get(name) 38 | if value == None(): 39 | # Hack for default values! Can't use return_if because we're inside an if block 40 | if string_equal(name "child"): 41 | return(ns_obj.child) 42 | return(instance_attrib(name receiver searcher)) 43 | return(`value) 44 | 45 | ns_bind_colon <- fun[func]: 46 | name = input.next_token() 47 | current_ns . set(name func) 48 | # current_ns should have a __name__? __ns_name__? 49 | set_mem_hint(func str_cat(Done name "ns.")) 50 | 51 | current_ns <- hashtable(100) 52 | ns_obj_class <- ns_obj.child(current_ns boot_obj) 53 | ns_obj <- closure(ns_obj.child ns_obj_class) 54 | current_ns . set("attrib" ns_obj.attrib) 55 | current_ns . set("child" ns_obj.child) 56 | current_ns . set("set_attr" ns_obj.set_attr) 57 | current_ns . set("print" ns_obj.print) 58 | current_ns . set("type" "ns_obj") 59 | 60 | new_ns_class <- fun[name]: 61 | # Contains hard-coded names semantics! 62 | #hashtable.set("current_ns" hashtable(100) names2()) 63 | hashtable.set("type" name current_ns) 64 | class_name = str_cat(Done "_class" name) 65 | hashtable.set(class_name ns_obj.child(current_ns ns_obj_class) names2()) 66 | new_class = names.get(class_name) 67 | # Problem: need the child class to create a closure! 68 | instance_creator = closure(new_class . child new_class) 69 | hashtable.set(name instance_creator names2()) 70 | set_mem_hint(current_ns str_cat(Done ".attr" class_name)) 71 | set_mem_hint(instance_creator str_cat(Done " instance creator" class_name)) 72 | 73 | String <- ns_class[]: 74 | child <- fun[str parent]: 75 | # parent . parent . child(hashtable(100)) but with "self" set 76 | # as parent instead of parent . parent 77 | new_obj = call(hashtable(100) parent parent . parent . child) 78 | # Could parse ints here? 79 | new_obj . attr . set("str" str) 80 | return(new_obj) 81 | 82 | len <- fun[self]: 83 | return(str_len(self . str)) 84 | 85 | slice <- fun[start end self]: 86 | return(self . parent . child(sub_str(self . str start end))) 87 | 88 | get <- fun[index self]: 89 | return(self . slice(index index + 1)) 90 | 91 | index <- fun[c self]: 92 | i = self . len() 93 | repeat_if: 94 | i = `i - 1 95 | if string_equal(self . get(i) . str c): 96 | return(`i) 97 | return(None()) 98 | 99 | index2 <- fun[c self]: 100 | simple_for(self . len() 0 fast_fun[index]: 101 | if string_equal(self . get(index) . str c): 102 | # Problem: This compiles to return3, which gets us to the stack frame of the for, but not beyond. 103 | # Maybe we should just have newfunc stack separators. Not sure. 104 | # Might just be that simple_for needs return increased by 1. 105 | return(index)) 106 | return(None()) 107 | 108 | endswith <- fun[suffix self]: 109 | return(str_endswith(suffix self . str)) 110 | 111 | # Assumes arr is an array of str but really want String? 112 | join <- fun[arr class]: 113 | return(class . child(str_join(arr arr . length))) 114 | 115 | print <- fun[self]: 116 | print("s\q") 117 | print(self . str) 118 | print("\q") 119 | 120 | File <- ns_class[]: 121 | # child should be instance here? Since this isn't good for subclassing 122 | child <- fun[filename parent]: 123 | fd = file.open("r" filename) 124 | new_obj = call(hashtable(100) parent parent . parent . child) 125 | new_obj . attr . set("fd" fd) 126 | return(new_obj) 127 | 128 | # Don't remember why I put this here. Not obvious how to call this class method anymore. 129 | # Just changed child to take a filename instead of fd. Might as well? 130 | open <- fun[filename class]: 131 | return(class . child(file.open("r" filename))) 132 | 133 | write <- fun[value self]: 134 | return(fd_write(value self . fd)) 135 | 136 | # This should be a @property. Could override attrib but that solution 137 | # feels kind of ugly. I guess in some sense, that's how previous 138 | # classes did it. 139 | position <- fun[self]: 140 | return(fd_position(self . fd)) 141 | 142 | position_set <- fun[value self]: 143 | return(fd_position_set(self . fd)) 144 | 145 | startswith <- fun[value self]: 146 | return(fd_startswith(self . fd)) 147 | 148 | next_token <- fun[self]: 149 | return(fd_next_token(self . fd)) 150 | 151 | next_char <- fun[self]: 152 | return(fd_next_char(self . fd)) 153 | 154 | next_line <- fun[self]: 155 | return(fd_next_line(self . fd)) 156 | 157 | readlines <- fun[self]: 158 | result = resizable(0) 159 | cond = True 160 | repeat_if: 161 | drop1(`cond) 162 | elem = self . next_line() 163 | cond = not(elem == None()) 164 | if cond: 165 | result . append(elem) 166 | return(result) 167 | 168 | close <- fun[self]: 169 | return(file.close(self . fd)) 170 | 171 | StringIO <- ns_class[]: 172 | child <- fun[str parent]: 173 | # parent . parent . child(hashtable(100)) but with "self" set 174 | # as parent instead of parent . parent 175 | new_obj = call(hashtable(100) parent parent . parent . child) 176 | new_obj . attr . set("str" str) 177 | new_obj . attr . set("pos" 0) 178 | return(new_obj) 179 | 180 | next_token <- fun[self]: 181 | new_pos token = str_next_token(self . pos self . str) 182 | self . attr . set("pos" new_pos) 183 | return(String(token)) 184 | 185 | reset <- fun[self]: 186 | self . attr . set("pos" 0) 187 | 188 | to_res <- fun[self]: 189 | self . reset() 190 | new_resizable = resizable(0) 191 | repeat: 192 | token = self . next_token() 193 | if token . len() == 0: 194 | return(new_resizable) 195 | new_resizable . append(`token) 196 | 197 | get_class_name <- fun[pointer]: 198 | return(StringIO(get_mem_hint(pointer)) . next_token() . str) 199 | 200 | set_method <- fun[creator key value]: 201 | class_hash = names2() . get(get_class_name(creator)) . attr 202 | class_hash . set(key value) 203 | 204 | val_to_str <- fun[value]: 205 | if is_basic(value): 206 | return(to_str(value)) 207 | else: 208 | return(value . str()) 209 | 210 | map_in_place <- fun[arr f]: 211 | simple_for(arr . len 0 fast_fun[index]: 212 | arr . set(index call(arr . get(index) f))) 213 | 214 | str_cat3 <- fast_fun[]: 215 | # make_resizable(*args) 216 | arr = make_resizable_rev() 217 | map_in_place(arr to_str) 218 | joined = str_join(arr . array + 1 arr . len) 219 | # return joined 220 | shuffle("13") 221 | 222 | string_test <- fun[]: 223 | s = String("hello world") 224 | tprint(s) 225 | printeol() 226 | tprint(s . slice(1 3)) 227 | printeol() 228 | tprint(s . get(1)) 229 | 230 | # string_test() 231 | 232 | top_level_exception_handler <- fun[error]: 233 | error_handler_index = 0 234 | cond = True 235 | repeat_if: 236 | drop1(`cond) 237 | handler = all_data_stack_pick(error_handler_index "exception_handler") 238 | if handler == None(): 239 | drop1(`handler) 240 | debugger() # unhandled error 241 | else: 242 | result = call(error handler) 243 | cond = (result == None()) 244 | result cond error_handler_index = shuffle("412") 245 | error_handler_index = `error_handler_index + 1 246 | error_handler_index cond = s21() 247 | return(result) 248 | 249 | error_handler_set(top_level_exception_handler) 250 | 251 | yield <- fast_fun[value]: 252 | # Implicit value already on stack is returned. 253 | return_two(make_resizable_rev(Done local_call_stack())) 254 | 255 | next <- local_fun[call_stack_copy]: 256 | load_call_stack(call_stack_copy . array + 1 call_stack_copy . len 1) 257 | 258 | end_yield <- fast_fun[]: 259 | return_two(None() None()) -------------------------------------------------------------------------------- /lib/stage7b.flpc: -------------------------------------------------------------------------------- 1 | # To parse from stage7a 2 | 3 | print("hello_world") 4 | printeol() 5 | print("hi_world") 6 | printeol() 7 | 8 | uhoh <- fun[]: 9 | debuggerv2() 10 | print_state() 11 | rewind(4) 12 | 13 | inner <- fun[]: 14 | # Change this line after rewinding. 15 | print("Inner_1") 16 | printeol() 17 | uhoh() 18 | 19 | outer <- fun[]: 20 | print("Outer") 21 | printeol() 22 | i = 4 23 | inner() 24 | 25 | #outer() 26 | 27 | print_array2 <- fun[iterable]: 28 | l = iterable . len 29 | simple_for(l 0 fast_fun[]: 30 | tprint(iterable . get(l - index - 1))) 31 | 32 | test1 <- fun[]: 33 | foo = { "Hello_" 3 "and" 4 } 34 | foo . print() 35 | printeol() 36 | print_array2({ "Hello_" 3 "_and_" 4 "\n" }) 37 | 38 | test1() 39 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Forth Lisp Python Continuum 2 | 3 | *(Preview version. Even more of a code dump than usual. Should still run. Please report any issues.)* 4 | 5 | The Forth Lisp Python Continuum is a language made under the following incorrect assumption. 6 | 7 | > Python is Lisp with syntactic sugar and Lisp is Forth with syntactic sugar. 8 | 9 | ## Highlights 10 | 11 | - Almost all of Flpc is written in Flpc itself and defined at runtime. This means almost everything is modifiable at runtime using `rebind:` including the loop for reading input, compiling functions, looking up names and `rebind:` itself! 12 | - Alter the Flpc syntax by writing only in Flpc! [1] 13 | - Mix and match. Make your code as Forthy, Lispy or Pythonic as you like. 14 | - Low LoC count (relatively) to easily modify the boot sequence for your needs. 15 | - Save and load state (save not yet implemented). 16 | 17 | [1] The first time around, the description of the syntax change has to be written in the old Flpc of course. 18 | 19 | ## Syntax 20 | 21 | All of the of the following are equivalent in (the default syntax of) Flpc. Python-like syntax 22 | 23 | fib <- fun[i]: 24 | if i < 3: 25 | return(1) 26 | return(fib(x - 1) + fib(x - 2)) 27 | 28 | Lisp-like syntax 29 | 30 | bind("fib" fun([i] 31 | [if(<(i 3) [return(1)]) 32 | return(+(fib(-(i 1)) fib(-(i 2))))])) 33 | 34 | Forth-like syntax 35 | 36 | bind("fib" ["i" assign_() i 3 <() [1 return()] if() 37 | i 1 -() fib() i 2 -() fib() +() return()]) 38 | 39 | More Forth-like syntax 40 | 41 | F' 42 | [ 1 return2 ] bind: base-case 43 | [ newfunc1 assign: i 44 | pick: i pushi: 3 < pushf: base-case if 45 | pick: i 1 - fib pick: i 2 - fib + return1 46 | ] bind: fib 47 | 'F 48 | 49 | or just 50 | 51 | F' 52 | [ pick1 pushi: 3 < [ drop1 1 return ] if 53 | pick1 1 - fib pick2 - fib + s21 drop1 return ] bind: fib 54 | 'F 55 | 56 | Or anything *in between*. For example, Lisp with sweet expressions: 57 | 58 | bind("fib" fun([i] 59 | [if(i < 3 [return(1)]) 60 | return(fib(i - 1) + fib(i - 2))])) 61 | 62 | Eventually, the grammar itself will be modifiable at runtime (needs the Flpc compiler written in Flpc to be complete for that). 63 | 64 | With the use optional linters to enforce the style combination of your choosing (not yet implemented or designed). 65 | 66 | For technical reasons, all of the above need to be prepended with the line (this is because of the recursive call). 67 | 68 | bind("fib" ["Dummy"]) 69 | 70 | ## Running 71 | 72 | Run FlpcPython programs precompiled to FlpcForth with 73 | 74 | nim c --gc:orc -d:danger flpc.nim 75 | ./flpc precompiled/interpreter.f 76 | 77 | (or one of `precompiled/self.f`, `precompiled/flpc-gen.f`, `precompiled/compiler.f`, ). Tested with Nim Compiler Version 1.4.6. 78 | 79 | Recompile `.f` files with 80 | 81 | python compiler.py -o 82 | 83 | `compiler.py` depends on [pymetaterp](https://github.com/asrp/pymetaterp). Install it with `pip install -r requirements.txt`. 84 | 85 | The existing precompiled files were created with 86 | 87 | python compiler.py lib/stage{0,1{a,b,b2,b3,c,d},3{a,b}}.flpc lib/flpc_grammar.flpc lib/stage{6{a,b},7a2,7a}.flpc -o precompiled/interpreter.f 88 | python compiler.py lib/stage{0,1{a,b,b2,b3,c,d},3{a,b}}.flpc lib/flpc_grammar.flpc lib/stage6{a,b}.flpc -o precompiled/compiler.f 89 | python compiler.py lib/stage{0,1{a,b,b2,b3,c,d}}.flpc lib/grammar.flpc lib/stage{2,3a}.flpc test/stage3-test.flpc -o precompiled/flpc-gen.f 90 | python compiler.py lib/stage{0,1{a,b,b2,b3,c,d},3{a,b}}.flpc lib/flpc_grammar.flpc lib/stage6{a,b}.flpc test/self.flpc -o precompiled/self.f 91 | 92 | To run tests (in `test/`), compile up to the needed test and append the test. 93 | 94 | python compiler.py lib/stage{0,1{a,b,c}} test/stage1c-test.flpc -o precompiled/test.f 95 | 96 | See Bootstrapping Sequence to get an idea of combinations that may work. 97 | 98 | ## Bootstrapping sequence 99 | 100 | Almost everything is modifiable at runtime using `rebind:` including the loop for reading input, compiling functions, looking up names and `rebind:` itself! 101 | 102 | This is a long list but the size of each file is relatively small. 103 | 104 | - **boot.flpc**: Preloaded into memory (instead of at runtime) by reading the file `init_memory.dat` (a text file despite the name). Contains the REPL and compilation loop. `init_memory.dat` also contains `names.get` which implicitly represents the function names dictionary. 105 | - **stage0.flpc**: Defines `bind:`, `rebind:` and the debugger. 106 | - **stage1a.flpc**: Basic object system (`boot_obj`, `boot_array`, `boot_dict`) 107 | - **objects.flpc** (was `stage1b.flpc`): Object system (abandoned and unused for now; runs but is too slow without some kind of caching) 108 | - **stage1b.flpc**: Hashtable class 109 | - **stage1b2.flpc**: Replace function name resolution `names.get` with hashtable lookups. Rewire existing name map. 110 | - **stage1b3.flpc**: Replace class attribute lookup `obj . attrib` with hashtable lookups. Rewire existing `attrib`s. 111 | - **stage1c.flpc**: More objects: `resizable` arrays, `node` and `Input` for reading files (unfortunately all in the style of the basic object system instead of the intended one from stage1b) 112 | - **stage1d.flpc**: Semantics for nodes of a grammar 113 | - **grammar.flpc**: Rules of a grammar parsing grammar 114 | - **stage2.flpc**: Use the grammar parsing grammar to parse flpc.grammar into a grammar tree 115 | - **stage3a.flpc**: Generate FlpcPython from the grammar tree in stage2. Can generate the content of `flpc_grammar.flpc` (by adding the content of `stage1-test.flpc`). 116 | - **stage3b.flpc**: Defines some semantics and trickier rules for a Flpc parsing grammar. 117 | - **flpc_grammar.flpc**: Rules of a FlpcPython parsing grammar. 118 | - **stage4.flpc**: Parses a FlpcPython source file (by default `stage1.flpc`; change the hard-coded value for a different file) into its Abstract Syntax Tree. 119 | - **stage5.flpc**: Pretty-prints the AST from stage4. 120 | - **stage6a.flpc**: Missing language features for implementing `compiler.py`: loops, list comprehension, string manipulation, some classes. 121 | - **stage6b.flpc**: Rest of the compiler. More or less a direct translation of `compiler.py` to FLPC. 122 | - **stage7a.flpc**: Starts a FlpcPython interpreter and triple quote. 123 | - **stage7a2.flpc**: Objects using hashtable for method lookup. 124 | - **stage7a3.flpc**: Python FFI. See `test/pyexec.flpc` for sample usage. 125 | - **stage7a4.flpc**: Other helpers. Currently contains easier dictionary creation (see `test/make_dict.flpc`). 126 | - **stage7b.flpc**: Compiled and run by the compiler from stages 1-6. 127 | 128 | ## What's next? 129 | 130 | Its not clear what should go first, both as the next thing to write *and* the next thing to run in the boot sequence. (In fact, maybe the current boot sequence should be reordered). 131 | 132 | - **Flpc AST to FlpcForth compiler. COMPLETE** This is the most obvious as it would remove the need for `compiler.py` (so the only remaining source file in the project that is not Flpc would be `flpc.c`). However, competing with that are 133 | - **Garbage collection.** If the concatenation of all `stage1*.flpc` files are compiled, it takes up millions of memory cells. A number of those could be reclaimed. 134 | - **Caching mechanism.** This woud let us use the actual intended object system (hopefully its fast enough!) and replaces `names.get` with the method of an actual dictionary (as in `stage1b.flpc`). Binding and rebinding would be much easier and we can maybe also replace the memoizer. 135 | - **Modules.** We can't keep adding new features (like syscalls) as primitives. Ideally, they'd be referenced by name in some module system. 136 | - **Nested FlpcForth parser.** The number of auto-generated functions is pretty high and makes it a bit unreadable. Maybe this should even come right after the debugger (stage0). 137 | - **Direct Flpc AST interpreter** Maybe with an interpreter, we won't need the compiler (except at the very beginning). Everything can be rebound at runtime anyways. 138 | - **Foreign function interface. Early prototype COMPLETE** We probably don't want to reimplement everything (at least, not at first). Is there some language we can connect to and just use its functions as primitives? 139 | 140 | ## Debugging 141 | 142 | Hopefully these will also help with determining what some of the undocumented functions do with just some trial. 143 | 144 | ### printstate 145 | 146 | `ps` or `printstate` prints the formatted debug stack, formatted call_stack and next command. 147 | 148 | ![Example stack trace](stack.png) 149 | 150 | Each element of the data stack is printed as `: `, except for separators which are shown as `-----` (five dashes). 151 | 152 | `print_stack` prints only the stack portion. 153 | 154 | ### debugger 155 | 156 | Once `debugger` is defined, enters the debugger. Special commands are 157 | 158 | - `s` step (step into) 159 | - `n` next (step over) 160 | - `r` return (step until return) 161 | - `l` prints stack, same as `ps` 162 | 163 | Other commands are run (added to the call stack) with control resuming after the command is finished. 164 | 165 | `rebind:` either `debugger_inner` or `debugger` for the debugger to behave differently. 166 | 167 | ### tprint 168 | 169 | Typed print. Prints (and consumes) the top of the data stack. The value is formatted according to its type. 170 | 171 | ### mpr 172 | 173 | Prints the function-end separated memory with one character representing each cell. 174 | 175 | ### debugging primitives 176 | 177 | gcc -gdwarf-2 -g3 flpc_all.c -o flpc 178 | gdb ./flpc 179 | (gdb) b _error 180 | (gdb) b bp 181 | (gdb) r 182 | 183 | `call ps()` and `p cstring(input_next_token())` should help determine the program state when a breakpoint or error is reached. 184 | 185 | ## Primitives 186 | 187 | The end of the C source contains a complete list (starting from `int (*primitives[])(void) = ...`) 188 | 189 | - Integer and arithmetic operations `+ - * 0 1 pushi:` 190 | - Boolean operations `|| &&` 191 | - Memory and stack access `memory.set memory.get memory.append push: pushf: functions_end functions_end.increase` 192 | - Stack shuffling and naming `assign: pick: check: pick1 s21 shuffle: newfuncX returnX return_no_valueX` 193 | - Very basic branch and loop `if if-else repeat repeat_if return_if` 194 | - Display and debugging `print print_state mpr` 195 | - stdin reading `input.next_token next_token2` 196 | - File read [1] `file_open fd_*` 197 | - File write `set_output` 198 | - String manipulation (*) `is_str is_alpha string_equal char_between str_join sub_str int_to_str` 199 | - Memoizer helper [2] `memoizer_get memoizer_set memoizer_reset` 200 | 201 | [1] Should be in a module. But there's no module system yet. 202 | [2] Should be defined using other primitives instead 203 | 204 | Most everything else is defined at runtime and can be `rebind:` (once `rebind:` itself is defined). 205 | 206 | TODO: document this more 207 | 208 | ## Other things to try 209 | 210 | - Generate the content of `flpc_grammar.flpc` and `grammar.flpc` 211 | - Write some FlpcPython, compile it using `compiler.py` and run it. 212 | 213 | ## Interpreter 214 | 215 | To document. 216 | 217 | ## Boot object model 218 | 219 | To document. 220 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | -e git://github.com/asrp/pymetaterp#egg=pymetaterp 2 | -------------------------------------------------------------------------------- /stack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asrp/flpc/69633f282c72fe949a4cb62bab3bf08962018812/stack.png -------------------------------------------------------------------------------- /test/file.flpc: -------------------------------------------------------------------------------- 1 | 2 | file_test <- fun[]: 3 | f = file.open("r" "test/file.flpc") 4 | value = fd_next_token(f) 5 | tprint(value) 6 | 7 | file_test() 8 | 9 | file_write_test <- fun[]: 10 | f = file.open("w" "test/write-out") 11 | set_output(f) 12 | print("hello_world") 13 | printeol() 14 | set_output(None()) 15 | print("hi_world") 16 | printeol() 17 | # cat test/write-out to see output 18 | 19 | file_write_test() -------------------------------------------------------------------------------- /test/list_comp_test.flpc: -------------------------------------------------------------------------------- 1 | list_comp_test <- fun[]: 2 | list1 = { 2 3 1 3 } 3 | list2 = { x + 1 for x in list1 } 4 | list2 . print() 5 | printeol() 6 | 7 | list_comp_test() -------------------------------------------------------------------------------- /test/multi_if.flpc: -------------------------------------------------------------------------------- 1 | 2 | # python compiler.py lib/stage0.flpc lib/multi_if.flpc > precompiled/test.f 3 | foo <- fun[]: 4 | print("foo") 5 | printeol() 6 | 7 | bar <- fun[]: 8 | print("bar") 9 | printeol() 10 | 11 | baz <- fun[]: 12 | print("baz") 13 | printeol() 14 | 15 | test <- fun[]: 16 | # multi-if(foo 1 bar 0 baz 0 3) 17 | multi-if(0 baz 0 bar 1 foo) 18 | 19 | test() 20 | 21 | test2 <- fun[]: 22 | x = 4 23 | if x < 3: 24 | baz() 25 | elif x < 4: 26 | bar() 27 | elif x < 10: 28 | foo() 29 | 30 | test2() 31 | 32 | test3 <- fun[]: 33 | x = 2 34 | if x < 3: 35 | print("baz") 36 | printeol() 37 | elif x < 4: 38 | print("bar") 39 | printeol() 40 | elif x < 10: 41 | print("foo") 42 | printeol() 43 | 44 | test3() 45 | -------------------------------------------------------------------------------- /test/prime-test.flpc: -------------------------------------------------------------------------------- 1 | print(is_prime(2)) 2 | print(is_prime(4)) 3 | print(is_prime(5)) 4 | bp() 5 | # 1013 6 | print(next_prime(1010)) 7 | # 1733 8 | print(next_prime(1724)) 9 | bp() 10 | -------------------------------------------------------------------------------- /test/pyexec.flpc: -------------------------------------------------------------------------------- 1 | pyexec_test <- fun[]: 2 | pyexec("x=3" "exec") 3 | pyexec("x" "eval") 4 | 5 | pyexec_test() 6 | 7 | pyval_test <- fun[]: 8 | PyValue_class_attrib = PyValue_class - 1 9 | print(PyValue_class_attrib) 10 | print(memory.get(PyValue_class_attrib)) 11 | memory.set(PyValue_class_attrib PyValue_class . attrib) 12 | print(memory.get(PyValue_class_attrib)) 13 | pyexec("lastpy=3" "exec") 14 | py_x = PyValue("x") 15 | py_xr = py_bind(py_x . real "xr") 16 | print(py_x . str()) 17 | printeol() 18 | print(py_xr . str()) 19 | printeol() 20 | py_xadd = py_bind(py_x . __add__ "xadd") 21 | py_y = py_bind(py_xadd . call("4") "y") 22 | print(py_y . str()) 23 | printeol() 24 | 25 | pyval_test() 26 | -------------------------------------------------------------------------------- /test/self.flpc: -------------------------------------------------------------------------------- 1 | # init_g("gen/fgen-output2.flpc") 2 | # compile_file("lib/stage6b.flpc") 3 | # compile_file("lib/stage6.flpc") 4 | # compile_file("test/multi_if2.flpc") 5 | # compile_file("test/simplify_source4.flpc") 6 | # compile_file("test/compile_source.flpc") 7 | 8 | compile_self <- fun[]: 9 | filenames = make_resizable(Done "test/self.flpc" "lib/stage6b.flpc" "lib/stage6a.flpc" "lib/flpc_grammar.flpc" "lib/stage3b.flpc" "lib/stage3a.flpc" "lib/stage1d.flpc" "lib/stage1c.flpc" "lib/stage1b3.flpc" "lib/stage1b2.flpc" "lib/stage1b.flpc" "lib/stage1a.flpc" "lib/stage0.flpc") 10 | compile_all(filenames "gen/output.f") 11 | 12 | compile_self() -------------------------------------------------------------------------------- /test/stage1a-test.flpc: -------------------------------------------------------------------------------- 1 | boot_obj_test <- fun[]: 2 | print(boot_obj . str()) 3 | obj2 = boot_obj . instance() 4 | print(obj2 . str()) 5 | 6 | boot_array_test <- fun[]: 7 | a1 = boot_array_class . instance(4) 8 | print(a1 . get(0)) 9 | a1 . set(0 2) 10 | print(a1 . get(0)) 11 | a1 . print() 12 | 13 | boot_dict_test <- fun[]: 14 | d1 = boot_dict_class . instance(5) 15 | d1 . set("a" "foo") 16 | d1 . set("b" "bar") 17 | d1 . print() 18 | print(d1 . get("b")) 19 | print(d1 . len) 20 | print(d1 . keys . len) 21 | 22 | boot_obj_test() 23 | boot_array_test() 24 | boot_dict_test() -------------------------------------------------------------------------------- /test/stage1b-test.flpc: -------------------------------------------------------------------------------- 1 | obj_test <- fun[]: 2 | attr = obj_class . attr 3 | null_attr = null_newobj - 2 4 | print(attr . keys . len) 5 | # Problem: calls not run because of current compiler limitations 6 | print(null_attr . len) 7 | print(attr . len) 8 | print(attr . keys) 9 | print(attr . values) 10 | print(attr . keys . len) 11 | print(attr . values . len) 12 | print(null_attr . keys . len) 13 | print(null_attr . values . len) 14 | obj1 = obj_class . instance() 15 | obj1 . attr . print() 16 | 17 | int_test <- fun[]: 18 | i = 10 19 | print(i) 20 | 21 | dict_test2 <- fun[]: 22 | dict_class = obj_class . instance() 23 | attr = dict_class . attr 24 | # Recycling probably doesn't work because of caching... 25 | attr . set("get" dict.get) 26 | attr . set("set" dict.set) 27 | attr . set("increase" dict.increase) 28 | attr . set("instance" dict.instance) 29 | 30 | d2 = dict_class . instance(4) 31 | d2 . set("a" "b") 32 | d2 . set("abc" "def") 33 | # d2 . print() 34 | print(d2 . get("abc")) 35 | 36 | obj_test() 37 | int_test() 38 | dict_test2() -------------------------------------------------------------------------------- /test/stage1c-test.flpc: -------------------------------------------------------------------------------- 1 | resizable_test <- fun[]: 2 | a1 = resizable_class . instance(4) 3 | print(a1 . get(0)) 4 | a1 . set(0 2) 5 | print(a1 . get(0)) 6 | a1 . print() 7 | a2 = resizable_class . instance(1) 8 | a2 . append(1) 9 | a2 . append(2) 10 | a2 . append(3) 11 | a2 . append(4) 12 | a2 . append(5) 13 | a2 . append(6) 14 | a2 . print() 15 | print(a2 . len) 16 | a2 . array . print() 17 | 18 | node_test <- fun[]: 19 | print("Running_node_test") 20 | printeol() 21 | a1 = resizable_class . instance(3) 22 | a1 . set(1 2) 23 | 24 | n1 = node_class . instance("test" a1) 25 | n1 . print() 26 | print(n1 . get(0)) 27 | print(n1 . get(1)) 28 | 29 | input_test <- fun[]: 30 | inp = Input_class . instance("grammar/rules.grammar") 31 | print(inp . next()) 32 | printeol() 33 | print(inp . next()) 34 | printeol() 35 | print(inp . next()) 36 | printeol() 37 | print(inp . next()) 38 | printeol() 39 | 40 | resizable_test() 41 | node_test() 42 | input_test() 43 | -------------------------------------------------------------------------------- /test/stage1d-test.flpc: -------------------------------------------------------------------------------- 1 | match_test <- fun[]: 2 | print(token("hello")) 3 | saved = source . position() 4 | print(saved) 5 | print(token("world")) 6 | source . position_set(saved) 7 | print(token("world")) 8 | print(or([[token("hello")] [token("hi")]])) 9 | out([token("world")]) . print() 10 | 11 | match_test2 <- fun[]: 12 | and([[token("hello")] [token("world")]]) . print() 13 | and([[token("hi")] [token("world2")]]) . print() 14 | and([[token("hi")] [token("world")]]) . print() 15 | bound([quantified([token("foo")] "+")] "bound_test") . print() 16 | quantified([token("foo")] "+") . print() 17 | 18 | match_test3 <- fun[]: 19 | negation([token("hello")]) . print() 20 | print(negation([token("world")])) 21 | 22 | test_rule <- fun[]: 23 | return(and([[token("hello")] [token("world")]])) 24 | 25 | match_test4 <- fun[]: 26 | apply("test_rule") . print() 27 | 28 | match_test5 <- fun[]: 29 | print(between("a" "z")) 30 | 31 | match_test5 <- fun[]: 32 | print(between("a" "z")) 33 | 34 | match_test6 <- fun[]: 35 | rule.name() . print() 36 | 37 | resize_extend_test <- fun[]: 38 | r1 = resizable_class . instance(0) 39 | r2 = resizable_class . instance(0) 40 | r3 = resizable_class . instance(0) 41 | r1 . append(1) 42 | r1 . append(2) 43 | r2 . append(3) 44 | r2 . append(4) 45 | r1 . print() 46 | r2 . print() 47 | r1 . extend(r2) 48 | r1 . print() 49 | 50 | resize_extend_test() 51 | match_test6() 52 | -------------------------------------------------------------------------------- /test/stage3-test.flpc: -------------------------------------------------------------------------------- 1 | write_parsed(bootg "grammar/boot.grammar" "gen/grammar.flpc") 2 | # Wrong place to make modifications 3 | bootg.base . append("add_indent_rules") 4 | bootg . set(0 "flpcg") 5 | write_parsed(bootg "grammar/flpc.grammar" "gen/flpc_grammar.flpc") 6 | -------------------------------------------------------------------------------- /test/stage6a-test.flpc: -------------------------------------------------------------------------------- 1 | make_resizable_test <- fun[]: 2 | dprint("make_resizable:_" make_resizable("second" "first" 2)) 3 | 4 | make_resizable_test() 5 | 6 | str_cat_test <- fun[]: 7 | out = str_cat("world" "hello" 2) 8 | dprint("str_cat_out:_" out) 9 | dprint("str_cat_out2:_" str_cat("three_" "two_" "one_" 3)) 10 | 11 | str_cat_test() 12 | 13 | flist_test <- fun[]: 14 | output = make_resizable(1 2 3 3) 15 | dprint("Output:_" output) 16 | dprint("is_FList_class:_" is_instance(output FList_class)) 17 | dprint("output.get(1):_" output . get(1)) 18 | change_class(output FList_class) 19 | # debugger() 20 | dprint("output_after_change:_" output) 21 | dprint("is_FList_class:_" is_instance(output FList_class)) 22 | dprint("output.get(1):_" output . get(1)) 23 | 24 | flist_test() 25 | 26 | flatten_test <- fun[]: 27 | input = make_resizable(make_resizable(1 2 2) make_resizable(3 4 5 3) make_resizable(6 1) 3) 28 | dprint("Input:_" input) 29 | output = flatten(input resizable_class) 30 | dprint("Output:_" output) 31 | 32 | flatten_test() 33 | 34 | fquote_test <- fun[]: 35 | fq = FQuote("hello" make_resizable(1 2 3 3)) 36 | dprint("fq:_" fq) 37 | 38 | fquote_test() 39 | -------------------------------------------------------------------------------- /test/stage6b-test.flpc: -------------------------------------------------------------------------------- 1 | 2 | # TODO: Use real parsed inputs on small files. 3 | # source <- Input("test/simplify_source2.flpc") 4 | source <- Input("test/compile_source.flpc") 5 | # source <- Input("test/multi_if2.flpc") 6 | # source <- Input("lib/stage1b3.flpc") 7 | memoizer.reset() 8 | printeol() 9 | print("Running_flpc_grammar") 10 | printeol() 11 | parsed <- apply("grammar") 12 | # parsed . print() 13 | 14 | simplify_test <- fun[]: 15 | # Node("func_call", [Node("name", "hello"), Node("name", "world") 16 | children = resizable(0) 17 | children . append(node("name" "hello")) 18 | children . append(node("name" "world")) 19 | children . append(node("EMPTY_LINE" "foo")) 20 | #children . append("world") 21 | root = node("suite" children) 22 | print("Simplify_test") 23 | printeol() 24 | print("Input:_") 25 | tprint(root) 26 | printeol() 27 | simplified = simplify(root) 28 | print("Simplified:_") 29 | simplified . print() 30 | return(simplified) 31 | 32 | simplify_test() 33 | 34 | to_forth_test <- fun[root]: 35 | print("to_forth_test") 36 | printeol() 37 | print("Input:_") 38 | tprint(root) 39 | printeol() 40 | simplified = simplify(root) 41 | print("Simplified:_") 42 | simplified . print() 43 | printeol() 44 | # Why doesn't this work when compiled? Get a lookup error. 45 | forthed = to_forth(simplified) 46 | # forthed = simplified 47 | printeol() 48 | print("ToForth:_") 49 | forthed . print() 50 | 51 | # to_forth_test(parsed) 52 | 53 | write_test <- fun[root]: 54 | print("write_test") 55 | printeol() 56 | print("Input:_") 57 | tprint(root) 58 | printeol() 59 | simplified = simplify(root) 60 | print("Simplified:_") 61 | simplified . print() 62 | printeol() 63 | # Why doesn't this work when compiled? Get a lookup error. 64 | forthed = to_forth(simplified) 65 | # forthed = simplified 66 | printeol() 67 | print("ToForth:_") 68 | forthed . print() 69 | printeol() 70 | printeol() 71 | init_g() 72 | write_suite(forthed None()) 73 | 74 | write_test(parsed) 75 | --------------------------------------------------------------------------------