previndexinfonext

code guessing, round #41 (completed)

started at ; stage 2 at ; ended at

specification

yet another interpreter... your challenge is to implement FALSE. submissions may be written in any language.

oh boy, this is gonna be a long spec. you can read more about the language here (note that this challenge changes some details from the original language)

FALSE is a simple imperative stack-based language. most instructions are a single character. you've seen this formula a hundred times before. if the source or input contains invalid instructions or any code point outside the ranges 9-10 and 32-126, the behaviour is undefined.

there are 3 types of value: signed 32-bit integers, variable references, and quotes. attempting to interpret a value as the wrong type (e.g. using an integer as a quote) is undefined behaviour.

there is a single stack of values. there are also 26 variables, named a to z, each of which stores a value. accessing uninitialized data (for example, popping an empty stack or reading an uninitialized variable) is undefined behaviour.

the instructions are as follows:

your challenge is to create a FALSE implementation that accepts a program and some input, executes the program and displays its output. IO is not required to be interactive. as any language is allowed, there is no fixed API.

results

  1. 👑 olive +9 -3 = 6
    1. razetime (was olus2000)
    2. Lizzy Fleckenstein
    3. navi
    4. Palaiologos
    5. luatic
    6. moshikoi (was kotnen)
    7. kimapr
    8. Rabbitgaming
    9. Olive
    10. taswelll
    11. LyricLy
    12. kotnen (was moshikoi)
    13. olus2000 (was razetime)
  2. razetime +7 -1 = 6
    1. olus2000
    2. Lizzy Fleckenstein
    3. navi
    4. LyricLy (was Palaiologos)
    5. luatic
    6. Palaiologos (was kotnen)
    7. kimapr
    8. olive (was Rabbitgaming)
    9. Olive
    10. Rabbitgaming (was taswelll)
    11. taswelll (was LyricLy)
    12. kotnen (was olive)
    13. moshikoi
  3. kimapr +11 -7 = 4
    1. olus2000
    2. Lizzy Fleckenstein
    3. navi
    4. Palaiologos
    5. luatic
    6. kotnen
    7. Rabbitgaming
    8. Olive
    9. taswelll
    10. LyricLy
    11. olive
    12. razetime (was moshikoi)
    13. moshikoi (was razetime)
  4. moshikoi +8 -4 = 4
    1. olus2000
    2. Lizzy Fleckenstein
    3. Rabbitgaming (was navi)
    4. olive (was Palaiologos)
    5. luatic
    6. kotnen
    7. kimapr
    8. navi (was Rabbitgaming)
    9. Olive
    10. taswelll
    11. LyricLy
    12. razetime (was olive)
    13. Palaiologos (was razetime)
  5. Rabbitgaming +8 -4 = 4
    1. LyricLy (was olus2000)
    2. Lizzy Fleckenstein
    3. navi
    4. razetime (was Palaiologos)
    5. luatic
    6. kotnen
    7. kimapr
    8. olus2000 (was Olive)
    9. taswelll
    10. Olive (was LyricLy)
    11. olive
    12. moshikoi
    13. Palaiologos (was razetime)
  6. LyricLy +8 -5 = 3
    1. olus2000
    2. Lizzy Fleckenstein
    3. razetime (was navi)
    4. Palaiologos
    5. luatic
    6. kotnen
    7. olive (was kimapr)
    8. Rabbitgaming
    9. Olive
    10. taswelll
    11. kimapr (was olive)
    12. navi (was moshikoi)
    13. moshikoi (was razetime)
  7. olus2000 +7 -7 = 0
    1. Lizzy Fleckenstein
    2. olive (was navi)
    3. razetime (was Palaiologos)
    4. luatic
    5. kotnen
    6. kimapr
    7. navi (was Rabbitgaming)
    8. Olive
    9. taswelll
    10. LyricLy
    11. moshikoi (was olive)
    12. Palaiologos (was moshikoi)
    13. Rabbitgaming (was razetime)
  8. Palaiologos +4 -4 = 0
    1. razetime (was olus2000)
    2. Lizzy Fleckenstein
    3. kotnen (was navi)
    4. luatic
    5. navi (was kotnen)
    6. olive (was kimapr)
    7. kimapr (was Rabbitgaming)
    8. Olive
    9. LyricLy (was taswelll)
    10. Rabbitgaming (was LyricLy)
    11. taswelll (was olive)
    12. moshikoi
    13. olus2000 (was razetime)
  9. taswelll +5 -6 = -1
    1. olus2000
    2. Lizzy Fleckenstein
    3. luatic (was navi)
    4. navi (was Palaiologos)
    5. olive (was luatic)
    6. kotnen
    7. moshikoi (was kimapr)
    8. LyricLy (was Rabbitgaming)
    9. Olive
    10. Rabbitgaming (was LyricLy)
    11. kimapr (was olive)
    12. Palaiologos (was moshikoi)
    13. razetime
  10. Lizzy Fleckenstein +8 -10 = -2
    1. olus2000
    2. navi
    3. moshikoi (was Palaiologos)
    4. luatic
    5. kotnen
    6. kimapr
    7. Rabbitgaming
    8. Olive
    9. LyricLy (was taswelll)
    10. Palaiologos (was LyricLy)
    11. olive
    12. razetime (was moshikoi)
    13. taswelll (was razetime)
  11. kotnen +6 -8 = -2
    1. olus2000
    2. LyricLy (was Lizzy Fleckenstein)
    3. taswelll (was navi)
    4. Palaiologos
    5. luatic
    6. kimapr
    7. razetime (was Rabbitgaming)
    8. Olive
    9. navi (was taswelll)
    10. olive (was LyricLy)
    11. Rabbitgaming (was olive)
    12. moshikoi
    13. Lizzy Fleckenstein (was razetime)
  12. navi +3 -5 = -2
    1. moshikoi (was olus2000)
    2. Lizzy Fleckenstein
    3. kimapr (was Palaiologos)
    4. luatic
    5. kotnen
    6. olive (was kimapr)
    7. Olive (was Rabbitgaming)
    8. Rabbitgaming (was Olive)
    9. olus2000 (was taswelll)
    10. Palaiologos (was LyricLy)
    11. razetime (was olive)
    12. LyricLy (was moshikoi)
    13. taswelll (was razetime)
  13. luatic +1 -11 = -10
    1. olive (was olus2000)
    2. moshikoi (was Lizzy Fleckenstein)
    3. kimapr (was navi)
    4. kotnen (was Palaiologos)
    5. Lizzy Fleckenstein (was kotnen)
    6. razetime (was kimapr)
    7. olus2000 (was Rabbitgaming)
    8. Rabbitgaming (was Olive)
    9. Palaiologos (was taswelll)
    10. LyricLy
    11. taswelll (was olive)
    12. navi (was moshikoi)
    13. Olive (was razetime)
  14. Olive +0 -10 = -10

    entries

    you can download all the entries

    entry #1

    written by olus2000
    submitted at
    1 like

    guesses
    comments 0

    post a comment


    dir FALSE
    FALSE-docs.factor Unicode text, UTF-8 text, with very long lines (343)
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    ! Copyright (C) 2023 Aleksander Sabak.
    ! See https://factorcode.org/license.txt for BSD license.
    USING: assocs help.markup help.markup.private help.syntax kernel sequences strings urls ;
    IN: FALSE
    
    HELP: <FALSE-state>
    { $values
        { "stack" sequence } { "dictionary" assoc }
        { "state" FALSE-state }
    }
    { $description "Creates a new FALSE state with clones of " { $snippet "stack" } " and " { $snippet "dictionary" } " as the initial stack and initial variable dictionary respectively." }
    { $see-also <empty-FALSE-state> with-FALSE } ;
    
    HELP: <empty-FALSE-state>
    { $values
        { "state" FALSE-state }
    }
    { $description "Creates a new, empty FALSE state. It has no bound variables and an empty stack." }
    { $see-also <FALSE-state> with-FALSE } ;
    
    HELP: FALSE-state
    { $class-description "The class of tuples holding states of FALSE execution to be operated on by compiled FALSE programs. Implements " { $link "sequence-protocol" } " for access to stack and " { $link "assocs-protocol" } " for access to variables." }
    { $see-also <FALSE-state> <empty-FALSE-state> } ;
    
    HELP: FALSE[
    { $syntax "FALSE[ 0 0[ß^$$47>\\58\\>&][48-\\10*+]#%[$1>][$1-]#[\\$0=~][*]#%.]" }
    { $description "Syntax for a FALSE program. It will run on a " { $link FALSE-state } " object. Syntax and semantics of FALSE language are explained in " { $link "FALSE" } "." }
    { $errors "Throws an error when the unsupported " { $snippet "`" } " command is encountered." }
    { $examples
      { $example
        "USING: kernel accessors FALSE prettyprint ;"
        "{ 2 1 3 7 } { } <FALSE-state>
        FALSE[ +-*] call stack>> ."
        "V{ -18 }"
      }
      { $example
        "USING: FALSE prettyprint ;"
        "\"Hello\" FALSE[ \\1+] with-FALSE ."
        "\"Helom\""
      }
    }
    { $see-also with-FALSE } ;
    
    HELP: scan-FALSE
    { $values
        { "quote" { $quotation ( state -- state' ) } }
    }
    { $description "Reads a FALSE program from parser input until a closing " { $snippet "[" } " and compiles into a quotation to run on a " { $link FALSE-state } "." }
    { $errors "Throws an error when the unsupported " { $snippet "`" } " command is encountered." }
    { $see-also POSTPONE: FALSE[ } ;
    
    HELP: unsupported-FALSE-command
    { $values
        { "command" object }
    }
    { $description "Throws an " { $link unsupported-FALSE-command } " error." }
    { $error-description "Thrown during FALSE compilation if the " { $snippet "`" } " command is encountered." } ;
    
    HELP: with-FALSE
    { $values
        { "seq" sequence } { "q" { $quotation ( ..A state -- ..B state' ) } }
        { "seq'" sequence }
    }
    { $description "Wrapper around quotations transforming FALSE state. Creates a new " { $link FALSE-state } " instance with " { $snippet "seq" } " as its initial stack, runs " { $snippet "q" } " on it and extracts the final stack into a new sequence of the same type as " { $snippet "seq" } "." }
    { $examples
      { $example
        "USING: FALSE prettyprint ;"
        "{ 2 1 3 7 } FALSE[ +-*] with-FALSE ."
        "{ -18 }"
      }
      { $example
        "USING: FALSE prettyprint ;"
        "\"Hello\" FALSE[ \\1+] with-FALSE ."
        "\"Helom\""
      }
    }
    { $see-also <FALSE-state> <empty-FALSE-state> }
    ;
    
    ARTICLE: "FALSE" "FALSE language"
    { { $url URL"https://esolangs.org/wiki/FALSE" "FALSE" } " is a stack-based esoteric language designed by " { $url URL"https://strlen.com/" "Wouter van Oortmerssen" } " in 1993, with the goal of creating a powerful and obfuscated language with as small a compiler as possible." }
    
    { $heading "Overview of FALSE" }
    FALSE has a simple concatenative syntax where each character is one command, apart from numbers which can span multiple characters. It operates on a stack but it can also store values in 26 variables named { $snippet "a" } through { $snippet "z" } . It works with three types of values:
    { $list
      { "Signed integers, for which literals are strings of digits or " { $snippet "'" } " followed by a character" }
      { "Variable references, for which literals are their names" }
      { "Quotations, for which literals are programs enclosed in " { $snippet "[...]" } }
    }
    It provides a set of builtin operators:
    { $table 
      { { $snippet "$" } { $snippet ( x -- x x ) } "Duplicates top of the stack" }
      { { $snippet "%" } { $snippet ( x -- ) } "Drop top of the stack" }
      { { $snippet "\\" } { $snippet ( x y -- y x ) } "Swaps top two elements on the stack" }
      { { $snippet "@" } { $snippet ( x y z -- y z x ) } "Pulls the third element from the stack to the top" }
      { { $snippet "ø" } { $snippet ( x n*x n -- x n*x x ) } "Replaces a number from top of the stack with an element that deep into the stack" }
      { { $snippet "O" } { $snippet ( x n*x n -- x n*x x ) } "Nonstandard, same as ø" }
      { { $snippet "+" } { $snippet ( x y -- z ) } "Adds top two numbers on the stack" }
      { { $snippet "-" } { $snippet ( x y -- z ) } "Subtracts top from second on the stack" }
      { { $snippet "*" } { $snippet ( x y -- z ) } "Multiplies top two numbers on the stack" }
      { { $snippet "/" } { $snippet ( x y -- z ) } "Divides second on the stack by top" }
      { { $snippet "_" } { $snippet ( x -- y ) } "Negates top of the stack" }
      { { $snippet "&" } { $snippet ( x y -- z ) } { "Performs a bitwise " { $snippet "and" } " on top two values o the stack" } }
      { { $snippet "|" } { $snippet ( x y -- z ) } { "Performs a bitwise " { $snippet "or" } " on top two values o the stack" } }
      { { $snippet "~" } { $snippet ( x -- y ) } "Performs a bitwise negation on top of the stack" }
      { { $snippet ">" } { $snippet ( x y -- z ) } "Pushes -1 if second on the stack is greater than top, otherwise pushes 0" }
      { { $snippet "=" } { $snippet ( x y -- z ) } "Pushes -1 if top two on the stack are equal, otherwise pushes 0" }
      { { $snippet "!" } { $snippet ( quot -- ) } "Executes top of stack" }
      { { $snippet "?" } { $snippet ( ? quot -- ) } "Executes top of stack if second on stack is non-zero" }
      { { $snippet "#" } { $snippet ( pred body -- ) } { "Executes " { $snippet "pred" } ", pops its return value, and loops calling " { $snippet "body" } ", " { $snippet "pred" } " and popping until the value popped is zero" } }
      { { $snippet ";" } { $snippet ( ref -- x ) } "Fetch from a variable reference" }
      { { $snippet ";" } { $snippet ( x ref -- ) } "Store into a variable reference" }
      { { $snippet "^" } { $snippet ( -- x ) } "Fetch a character from input stream, or -1 if input stream is exhausted" }
      { { $snippet "," } { $snippet ( x -- ) } "Print a character with a given code to the output stream" }
      { { $snippet "." } { $snippet ( x -- ) } "Print a number to the output stream" }
      { { $snippet "ß" } { $snippet ( -- ) } "Flush the input/output stream" }
      { { $snippet "B" } { $snippet ( -- ) } "Nonstandard, same as ß" }
      { { $snippet "`" } { $snippet ( -- * ) } "Unsupported" }
    }
    It also has two additional syntax constuctions:
    { $list
      { { $snippet "\"...\"" } " - print string enclosed in quotation marks" }
      { { $snippet "{...}" } " - ignore anything in curly braces" }
    }
    
    { $heading "Vocabulary" }
    The { $vocab-link "FALSE" } vocabulary provides a FALSE to Factor compiler in two words:
    { $subsections scan-FALSE POSTPONE: FALSE[ }
    These offer a way to parse FALSE into quotations that take and return a FALSE state object. State objects can be constructed from a sequence which will form the initial stack and an assoc which will define initial variable bindings. The vocabulary also includes a wrapper word for using a FALSE quotation as a function transforming a sequence:
    { $subsections FALSE-state with-FALSE }
    
    { $heading "Implementation specific features" }
    This FALSE to Factor compiler differs from the standard in several ways:
    { $list
      { "It doesn't support the " { $snippet "`" } " command" }
      { "It supports " { $snippet "O" } " and " { $snippet "B" } " commands as aliases to " { $snippet "ø" } " and " { $snippet "ß" } " respectively" }
      { "Any character not recognised as a FALSE command can be used as a variable reference, and variable references are stored as numbers on the stack which allows any number to be a variable reference as well" }
    }
    
    ;
    
    ABOUT: "FALSE"
    
    FALSE-tests.factor Unicode text, UTF-8 text
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    ! Copyright (C) 2023 Aleksander Sabak.
    ! See https://factorcode.org/license.txt for BSD license.
    USING: io.streams.string kernel tools.test FALSE FALSE.private ;
    IN: FALSE.tests
    
    
    ! scan-FALSE is not tested because testing with a custom lexer
    ! is too much effort
    
    
    { { } } [
        { } [ ] with-FALSE
    ] unit-test
    
    
    { 1 1 } FALSE[ [asd'f{fsd"}"as{fdsaf"[-+*]\]]
    must-infer-as
    
    
    { "AA" } [
        "A" FALSE[ $] with-FALSE
    ] unit-test
    
    
    { "BA" } [
        "AB" FALSE[ \] with-FALSE
    ] unit-test
    
    
    { "A" } [
        "AB" FALSE[ %] with-FALSE
    ] unit-test
    
    
    { "BCA" } [
        "ABC" FALSE[ @] with-FALSE
    ] unit-test
    
    
    { { 2 1 3 7 2 } } [
        { 2 1 3 7 3 } FALSE[ O] with-FALSE
    ] unit-test
    
    
    { { 2 1 3 7 2 } } [
        { 2 1 3 7 3 } FALSE[ ø] with-FALSE
    ] unit-test
    
    
    { "Hello" } [
        "" FALSE[ 'H'e'l'l'o] with-FALSE
    ] unit-test
    
    
    { { 213 7 } } [
        { } FALSE[ 213 7] with-FALSE
    ] unit-test
    
    
    { { 220 } } [
        { } FALSE[ 213 7+] with-FALSE
    ] unit-test
    
    
    { { 206 } } [
        { } FALSE[ 213 7-] with-FALSE
    ] unit-test
    
    
    { { -2137 } } [
        { } FALSE[ 2137_] with-FALSE
    ] unit-test
    
    
    { { 1491 } } [
        { } FALSE[ 213 7*] with-FALSE
    ] unit-test
    
    
    { { 30 } } [
        { } FALSE[ 213 7/] with-FALSE
    ] unit-test
    
    
    { { 1 } } [
        { } FALSE[ 5 3&] with-FALSE
    ] unit-test
    
    
    { { 7 } } [
        { } FALSE[ 5 3|] with-FALSE
    ] unit-test
    
    
    { { -6 } } [
        { } FALSE[ 5~] with-FALSE
    ] unit-test
    
    
    { { -1 } } [
        { } FALSE[ 5 5=] with-FALSE
    ] unit-test
    
    
    { { 0 } } [
        { } FALSE[ 5 6=] with-FALSE
    ] unit-test
    
    
    { { 0 } } [
        { } FALSE[ 5 6>] with-FALSE
    ] unit-test
    
    
    { { 0 } } [
        { } FALSE[ 5 5>] with-FALSE
    ] unit-test
    
    
    { { -1 } } [
        { } FALSE[ 5 4>] with-FALSE
    ] unit-test
    
    
    { { [ ] } } [
        { } FALSE[ []] with-FALSE
    ] unit-test
    
    
    { { 1 } } [
        { } FALSE[ [1]!] with-FALSE
    ] unit-test
    
    
    { { 1 } } [
        { } FALSE[ 1_[1]?] with-FALSE
    ] unit-test
    
    
    { { } } [
        { } FALSE[ 0[1]?] with-FALSE
    ] unit-test
    
    
    { { } } [
        { } FALSE[ [0][7]#] with-FALSE
    ] unit-test
    
    
    { { 6 } } [
        { } FALSE[ 0 1[][6\]#] with-FALSE
    ] unit-test
    
    
    { { 6 5 4 3 2 1 0 } } [
        { } FALSE[ 7[1-$][$]#] with-FALSE
    ] unit-test
    
    
    { { } } [
        { } FALSE[ {1 2 3}] with-FALSE
    ] unit-test
    
    
    { { [ ] } } [
        { } FALSE[ [{]}]] with-FALSE
    ] unit-test
    
    
    { { } "Hello" } [
        [ { } FALSE[ "Hello"] with-FALSE ] with-string-writer
    ] unit-test
    
    
    { "" } [
        [ FALSE[ "Hello"] ] with-string-writer nip
    ] unit-test
    
    
    { { } "{" } [
        [ { } FALSE[ "{"] with-FALSE ] with-string-writer
    ] unit-test
    
    
    { { } "1" } [
        [ { } FALSE[ {"}"1"] with-FALSE ] with-string-writer
    ] unit-test
    
    
    { { } "]" } [
        [ { } FALSE[ ["]"]!] with-FALSE ] with-string-writer
    ] unit-test
    
    
    { "" "Hello" } [
        [ "olleH" FALSE[ ,,,,,] with-FALSE ] with-string-writer
    ] unit-test
    
    
    { { } "2137" } [
        [ { 2137 } FALSE[ .] with-FALSE ] with-string-writer
    ] unit-test
    
    
    { { 2 1 3 7 } } [
        { 2 1 3 7 } FALSE[ B] with-FALSE
    ] unit-test
    
    
    { { 2 1 3 7 } } [
        { 2 1 3 7 } FALSE[ ß] with-FALSE
    ] unit-test
    
    
    { "Hello" } [
        "Hello" [ "" FALSE[ ^^^^^] with-FALSE ] with-string-reader
    ] unit-test
    
    
    { T{ FALSE-state } } [
        <empty-FALSE-state>
    ] unit-test
    
    
    { T{ FALSE-state } } [
        { } { } <FALSE-state>
    ] unit-test
    
    
    {
        T{ FALSE-state
            { stack V{ 97 98 99 } }
            { dictionary H{ { 97 98 } { 99 100 } } }
        }
    } [
        "abc" { "ab" "cd" } <FALSE-state>
    ] unit-test
    
    
    { T{ FALSE-state { stack V{ 0 55 } } } } [
        <empty-FALSE-state> FALSE[ 2 1+3\-'7] call
    ] unit-test
    
    
    {
        T{ FALSE-state
            { dictionary H{ { 97 3 } { 98 2 } { 99 1 } } }
        }
    } [
        { 1 2 3 } { } <FALSE-state> FALSE[ a:b:c:] call
    ] unit-test
    
    
    {
        T{ FALSE-state
            { stack V{ 1 2 3 } }
            { dictionary H{ { 97 1 } { 98 2 } { 99 3 } } }
        }
    } [
        { } { { CHAR: a 1 } { CHAR: b 2 } { CHAR: c 3 } }
        <FALSE-state> FALSE[ a;b;c;] call
    ] unit-test
    
    
    {
        T{ FALSE-state
            { stack V{ 3 2 1 } }
            { dictionary H{ { 97 3 } { 98 2 } { 99 1 } } }
        }
    } [
        { 1 2 3 } { } <FALSE-state> FALSE[ a:b:c:a;b;c;] call
    ] unit-test
    
    
    {
        T{ FALSE-state
            { stack V{ 16 49 } }
            { dictionary H{ { 97 [ ($) (*) ] } } }
        }
    } [
        <empty-FALSE-state> FALSE[ [$*]a:4a;!7a;!] call
    ] unit-test
    
    
    {
        { 15 }
        "12345678910111213141516171819202122233524578helloworld"
    } [
        [ { } FALSE[ {tests by luatic made for cg41}1 .
        1 1 + .
        4 1 - .
        2 2 * .
        10 2 / .
        6 _ _ .
        4 3 | .
        8 63 & .
        1 _ ~ 9 + .
        10 a : a ; .
        5 $ 1 + + .
        12 42 % .
        42 13 \ % .
        14 42 42 @ . % %
        15 42 42 2O . % %
        42 42 = ["16"]?
        42 41 > ["17"]?
        42 41_ > ["18"]?
        42_ 41 > ["FAIL"]?
        42_ 41_ > ["FAIL"]?
        41_ 42_ > ["19"]?
        ["20"]!
        [["2"]!["1"]!]![[]]%
        0 ["FAIL"]?
        42 ["22"]?
        '2,'3,[$ 1 > [1- $ f;! \ 1- f;! +]?]f:
        33 f;!.'h,"elloworld"] with-FALSE ] with-string-writer
    ] long-unit-test
    
    
    { { 97 -1 } } [
        "a" [ { } FALSE[ ^^] with-FALSE ] with-string-reader
    ] unit-test
    
    FALSE.factor Unicode text, UTF-8 text
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    ! Copyright (C) 2023 Aleksander Sabak.
    ! See https://factorcode.org/license.txt for BSD license.
    USING: accessors ascii assocs combinators continuations delegate
    delegate.protocols hashtables io kernel lexer math math.parser
    namespaces quotations sequences unicode vectors ;
    IN: FALSE
    
    
    ERROR: unsupported-FALSE-command command ;
    
    
    DEFER: scan-FALSE
    
    
    <PRIVATE
    
    
    : peek-char ( -- char|f )
      lexer get dup still-parsing?
      [ dup still-parsing-line?
        [ [ column>> ] [ line-text>> ] bi nth ]
        [ drop CHAR: \n ] if ] [ drop f ] if ;
    
    : consume-char ( -- )
      lexer get dup still-parsing-line?
      [ [ 1 + ] change-column drop ] [ next-line ] if ;
    
    : scan-char ( -- char|f ) peek-char dup [ consume-char ] when ;
    
    
    : (scan-FALSE-number) ( digit -- number )
      CHAR: 0 - [ peek-char dup ascii:digit? ]
      [ consume-char CHAR: 0 - swap 10 * + ] while drop ;
    
    
    : (;) ( state -- state )
      dup pop over at* [ drop 0 ] unless suffix! ;
    
    : (:) ( state -- state )
      dup [ pop ] [ pop ] bi swap pick set-at ;
    
    : ($) ( state -- state ) dup last suffix! ;
    
    : (%) ( state -- state ) dup pop* ;
    
    : (\) ( state -- state )
      dup [ pop ] [ pop ] bi [ suffix! ] dip suffix! ;
    
    : (@) ( state -- state )
      dup [ pop ] [ pop ] [ pop ] tri
      [ swap [ suffix! ] dip suffix! ] dip suffix! ;
    
    : (O) ( state -- state )
      dup dup [ length ] [ pop ] bi - 2 - swap nth suffix! ;
    
    : (+) ( state -- state ) dup [ pop ] [ pop ] bi + suffix! ;
    
    : (-) ( state -- state ) dup [ pop ] [ pop ] bi swap - suffix! ;
    
    : (*) ( state -- state ) dup [ pop ] [ pop ] bi * suffix! ;
    
    : (/) ( state -- state )
      dup [ pop ] [ pop ] bi swap /i suffix! ;
    
    : (_) ( state -- state ) dup pop neg suffix! ;
    
    : (&) ( state -- state ) dup [ pop ] [ pop ] bi bitand suffix! ;
    
    : (|) ( state -- state ) dup [ pop ] [ pop ] bi bitor suffix! ;
    
    : (~) ( state -- state ) dup pop bitnot suffix! ;
    
    : (=) ( state -- state )
      dup [ pop ] [ pop ] bi = [ -1 ] [ 0 ] if suffix! ;
    
    : (>) ( state -- state )
      dup [ pop ] [ pop ] bi < [ -1 ] [ 0 ] if suffix! ;
    
    : (!) ( state -- state ) dup pop call( state -- state ) ;
    
    : (?) ( state -- state )
      dup [ pop ] [ pop ] bi 0 =
      [ drop ] [ call( state -- state ) ] if ;
    
    : (#) ( state -- state )
      dup [ pop [ call( state -- state ) ] curry ]
      [ pop [ call( state -- state ) dup pop 0 = ] curry ] bi
      swap until ;
    
    : (^) ( state -- state ) read1 -1 or suffix! ;
    
    : (,) ( state -- state ) dup pop write1 ;
    
    : (.) ( state -- state ) dup pop number>string write ;
    
    ALIAS: (B) flush
    
    
    CONSTANT: FALSE-dictionary
      H{
        { CHAR: ; (;) }
        { CHAR: : (:) }
        { CHAR: $ ($) }
        { CHAR: % (%) }
        { CHAR: \ (\) }
        { CHAR: @ (@) }
        { CHAR: O (O) }
        { CHAR: ø (O) }
        { CHAR: + (+) }
        { CHAR: - (-) }
        { CHAR: * (*) }
        { CHAR: / (/) }
        { CHAR: _ (_) }
        { CHAR: & (&) }
        { CHAR: | (|) }
        { CHAR: ~ (~) }
        { CHAR: = (=) }
        { CHAR: > (>) }
        { CHAR: ! (!) }
        { CHAR: ? (?) }
        { CHAR: # (#) }
        { CHAR: ^ (^) }
        { CHAR: , (,) }
        { CHAR: . (.) }
        { CHAR: B (B) }
        { CHAR: ß (B) }
      }
    
    
    CONSTANT: FALSE-sigils
      H{
        { CHAR: {
          [ [ scan-char
              { { CHAR: } [ f ] }
                { f [ \ } throw-unexpected-eof ] }
                [ drop t ] } case ] loop ] }
        { CHAR: "
          [ V{ } clone
            [ scan-char
              { { CHAR: " [ f ] }
                { f [ \ " throw-unexpected-eof ] }
                [ suffix! t ] } case ] loop suffix!
            \ write suffix! ] }
        { CHAR: ' [ scan-char suffix! \ suffix! suffix! ] }
        { CHAR: [ [ scan-FALSE suffix! \ suffix! suffix! ] }
        { CHAR: ` [ CHAR: ` unsupported-FALSE-command ] }
      }
    
    
    PRIVATE>
    
    
    ! FALSE state
    
    TUPLE: FALSE-state { stack vector } { dictionary hashtable } ;
    
    : <FALSE-state> ( stack dictionary -- state )
      [ V{ } clone-like ] [ H{ } assoc-clone-like ] bi*
      FALSE-state boa ;
    
    CONSULT: assoc-protocol FALSE-state dictionary>> ;
    
    CONSULT: sequence-protocol FALSE-state stack>> ;
    
    M: FALSE-state like drop { } <FALSE-state> ;
    
    M: FALSE-state new-sequence
      state>> new-sequence { } <FALSE-state> ;
    
    M: FALSE-state new-resizable
      state>> new-resizable { } <FALSE-state> ;
    
    M: FALSE-state new-assoc
      dictionary>> new-assoc { } swap <FALSE-state> ;
    
    M: FALSE-state assoc-like
      dictionary>> assoc-like { } swap <FALSE-state> ;
    
    INSTANCE: FALSE-state sequence
    
    INSTANCE: FALSE-state assoc
    
    : <empty-FALSE-state> ( -- state ) { } { } <FALSE-state> ;
    
    
    : with-FALSE
      ( ..A seq q: ( ..A state -- ..B state' ) -- ..B seq' )
      swap [ H{ } <FALSE-state> swap call stack>> ] keep
      clone-like ; inline
    
    
    : scan-FALSE ( -- quote )
      V{ } clone
      [ scan-char dup CHAR: ] = ]
      [ { { [ FALSE-dictionary ?at ] [ suffix! ] }
          { [ FALSE-sigils ?at ] [ call( x -- x ) ] }
          { [ dup ascii:digit? ]
            [ (scan-FALSE-number) suffix! \ suffix! suffix! ] }
          { [ dup unicode:blank? ] [ drop ] }
          [ suffix! \ suffix! suffix! ] } cond ] until
      drop >quotation ;
    
    
    SYNTAX: FALSE[ scan-FALSE suffix! ;
    
    authors.txt ASCII text
    1
    Aleksander Sabak
    
    summary.txt ASCII text
    1
    A FALSE to Factor compiler.
    
    tags.txt ASCII text
    1
    2
    3
    languages
    parsing
    syntax
    

    entry #2

    written by Lizzy Fleckenstein
    submitted at
    3 likes

    guesses
    comments 0

    post a comment


    dir paradox
    dir examples
    brainfuck.false Unicode text, UTF-8 text
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    {
    	to compile:
    
    	(echo "[\"$(head -c30007 /dev/zero)\"]" && cat brainfuck.false) | ../paradox \
    		 > brainfuck.asm && nasm -f elf64 brainfuck.asm && ld -o brainfuck brainfuck.o
    
    	REQUIRES PARADOX due to pointer arithmetic.
    
    	stdin is used for both the brainfuck program and its input, separated by a zero byte.
    	to read the program from a file and enter input interactively:
    
    	(cat your_program.b && echo -ne '\0' && cat) | ./brainfuck
    
    	example hello world brainfuck program to try:
    	echo '+[>>>->-[>->----<<<]>>]>.---.>+..+++.>>.<.>>---.<<<.+++.------.<-.>>+.' | ./brainfuck
    }
    2+;$$t:h:l:
    0d: { change this to 0d: to disable debugging, 1_d: to enable debugging }
    0[^$$1_=~\0=~&][\1+]#% $n:
    [
    	r:\r;+
    	1[$0=~][\
    		$2+ø
    		$'[=[@r;-@@]?
    		$']=[@r;+@@]?
    		%r;+
    	\]#%
    	r;-\
    ]b:
    [$0=~][
    	d;[
    		"src: "
    		n;[$0=~][
    			$2ø=$[27,"[31m"]?
    			\$2+ø,1-\
    			[27,"[0m"]?
    		]#%
    		"mem: "
    		t;h; 1ø1ø>~[\]?% h:
    		l;[$h;>~][
    			$t;=$[27,"[31m"]?
    			\$;255&." "\
    			[27,"[0m"]?
    			1+
    		]#%
    		^%
    	]?
    
    	$ø
    	$'>=[t;1+$l;30000+=[%l;]?t:]?
    	$'<=[t;$l;=[%l;30000+]?1-t:]?
    	$'+=[t;$;$255~&\1+255&|\:]?
    	$'-=[t;$;$255~&\1-255&|\:]?
    	$'.=[t;;,ß]?
    	$',=[t;$;255~&^|\:]?
    	$'[=[t;;255&0=[1_b;!]?]?
    	$']=[t;;255&0=~[1b;!]?]?
    	%1-
    ]#%
    
    LICENSE ASCII text
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
                        GNU GENERAL PUBLIC LICENSE
                           Version 3, 29 June 2007
    
     Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
     Everyone is permitted to copy and distribute verbatim copies
     of this license document, but changing it is not allowed.
    
                                Preamble
    
      The GNU General Public License is a free, copyleft license for
    software and other kinds of works.
    
      The licenses for most software and other practical works are designed
    to take away your freedom to share and change the works.  By contrast,
    the GNU General Public License is intended to guarantee your freedom to
    share and change all versions of a program--to make sure it remains free
    software for all its users.  We, the Free Software Foundation, use the
    GNU General Public License for most of our software; it applies also to
    any other work released this way by its authors.  You can apply it to
    your programs, too.
    
      When we speak of free software, we are referring to freedom, not
    price.  Our General Public Licenses are designed to make sure that you
    have the freedom to distribute copies of free software (and charge for
    them if you wish), that you receive source code or can get it if you
    want it, that you can change the software or use pieces of it in new
    free programs, and that you know you can do these things.
    
      To protect your rights, we need to prevent others from denying you
    these rights or asking you to surrender the rights.  Therefore, you have
    certain responsibilities if you distribute copies of the software, or if
    you modify it: responsibilities to respect the freedom of others.
    
      For example, if you distribute copies of such a program, whether
    gratis or for a fee, you must pass on to the recipients the same
    freedoms that you received.  You must make sure that they, too, receive
    or can get the source code.  And you must show them these terms so they
    know their rights.
    
      Developers that use the GNU GPL protect your rights with two steps:
    (1) assert copyright on the software, and (2) offer you this License
    giving you legal permission to copy, distribute and/or modify it.
    
      For the developers' and authors' protection, the GPL clearly explains
    that there is no warranty for this free software.  For both users' and
    authors' sake, the GPL requires that modified versions be marked as
    changed, so that their problems will not be attributed erroneously to
    authors of previous versions.
    
      Some devices are designed to deny users access to install or run
    modified versions of the software inside them, although the manufacturer
    can do so.  This is fundamentally incompatible with the aim of
    protecting users' freedom to change the software.  The systematic
    pattern of such abuse occurs in the area of products for individuals to
    use, which is precisely where it is most unacceptable.  Therefore, we
    have designed this version of the GPL to prohibit the practice for those
    products.  If such problems arise substantially in other domains, we
    stand ready to extend this provision to those domains in future versions
    of the GPL, as needed to protect the freedom of users.
    
      Finally, every program is threatened constantly by software patents.
    States should not allow patents to restrict development and use of
    software on general-purpose computers, but in those that do, we wish to
    avoid the special danger that patents applied to a free program could
    make it effectively proprietary.  To prevent this, the GPL assures that
    patents cannot be used to render the program non-free.
    
      The precise terms and conditions for copying, distribution and
    modification follow.
    
                           TERMS AND CONDITIONS
    
      0. Definitions.
    
      "This License" refers to version 3 of the GNU General Public License.
    
      "Copyright" also means copyright-like laws that apply to other kinds of
    works, such as semiconductor masks.
    
      "The Program" refers to any copyrightable work licensed under this
    License.  Each licensee is addressed as "you".  "Licensees" and
    "recipients" may be individuals or organizations.
    
      To "modify" a work means to copy from or adapt all or part of the work
    in a fashion requiring copyright permission, other than the making of an
    exact copy.  The resulting work is called a "modified version" of the
    earlier work or a work "based on" the earlier work.
    
      A "covered work" means either the unmodified Program or a work based
    on the Program.
    
      To "propagate" a work means to do anything with it that, without
    permission, would make you directly or secondarily liable for
    infringement under applicable copyright law, except executing it on a
    computer or modifying a private copy.  Propagation includes copying,
    distribution (with or without modification), making available to the
    public, and in some countries other activities as well.
    
      To "convey" a work means any kind of propagation that enables other
    parties to make or receive copies.  Mere interaction with a user through
    a computer network, with no transfer of a copy, is not conveying.
    
      An interactive user interface displays "Appropriate Legal Notices"
    to the extent that it includes a convenient and prominently visible
    feature that (1) displays an appropriate copyright notice, and (2)
    tells the user that there is no warranty for the work (except to the
    extent that warranties are provided), that licensees may convey the
    work under this License, and how to view a copy of this License.  If
    the interface presents a list of user commands or options, such as a
    menu, a prominent item in the list meets this criterion.
    
      1. Source Code.
    
      The "source code" for a work means the preferred form of the work
    for making modifications to it.  "Object code" means any non-source
    form of a work.
    
      A "Standard Interface" means an interface that either is an official
    standard defined by a recognized standards body, or, in the case of
    interfaces specified for a particular programming language, one that
    is widely used among developers working in that language.
    
      The "System Libraries" of an executable work include anything, other
    than the work as a whole, that (a) is included in the normal form of
    packaging a Major Component, but which is not part of that Major
    Component, and (b) serves only to enable use of the work with that
    Major Component, or to implement a Standard Interface for which an
    implementation is available to the public in source code form.  A
    "Major Component", in this context, means a major essential component
    (kernel, window system, and so on) of the specific operating system
    (if any) on which the executable work runs, or a compiler used to
    produce the work, or an object code interpreter used to run it.
    
      The "Corresponding Source" for a work in object code form means all
    the source code needed to generate, install, and (for an executable
    work) run the object code and to modify the work, including scripts to
    control those activities.  However, it does not include the work's
    System Libraries, or general-purpose tools or generally available free
    programs which are used unmodified in performing those activities but
    which are not part of the work.  For example, Corresponding Source
    includes interface definition files associated with source files for
    the work, and the source code for shared libraries and dynamically
    linked subprograms that the work is specifically designed to require,
    such as by intimate data communication or control flow between those
    subprograms and other parts of the work.
    
      The Corresponding Source need not include anything that users
    can regenerate automatically from other parts of the Corresponding
    Source.
    
      The Corresponding Source for a work in source code form is that
    same work.
    
      2. Basic Permissions.
    
      All rights granted under this License are granted for the term of
    copyright on the Program, and are irrevocable provided the stated
    conditions are met.  This License explicitly affirms your unlimited
    permission to run the unmodified Program.  The output from running a
    covered work is covered by this License only if the output, given its
    content, constitutes a covered work.  This License acknowledges your
    rights of fair use or other equivalent, as provided by copyright law.
    
      You may make, run and propagate covered works that you do not
    convey, without conditions so long as your license otherwise remains
    in force.  You may convey covered works to others for the sole purpose
    of having them make modifications exclusively for you, or provide you
    with facilities for running those works, provided that you comply with
    the terms of this License in conveying all material for which you do
    not control copyright.  Those thus making or running the covered works
    for you must do so exclusively on your behalf, under your direction
    and control, on terms that prohibit them from making any copies of
    your copyrighted material outside their relationship with you.
    
      Conveying under any other circumstances is permitted solely under
    the conditions stated below.  Sublicensing is not allowed; section 10
    makes it unnecessary.
    
      3. Protecting Users' Legal Rights From Anti-Circumvention Law.
    
      No covered work shall be deemed part of an effective technological
    measure under any applicable law fulfilling obligations under article
    11 of the WIPO copyright treaty adopted on 20 December 1996, or
    similar laws prohibiting or restricting circumvention of such
    measures.
    
      When you convey a covered work, you waive any legal power to forbid
    circumvention of technological measures to the extent such circumvention
    is effected by exercising rights under this License with respect to
    the covered work, and you disclaim any intention to limit operation or
    modification of the work as a means of enforcing, against the work's
    users, your or third parties' legal rights to forbid circumvention of
    technological measures.
    
      4. Conveying Verbatim Copies.
    
      You may convey verbatim copies of the Program's source code as you
    receive it, in any medium, provided that you conspicuously and
    appropriately publish on each copy an appropriate copyright notice;
    keep intact all notices stating that this License and any
    non-permissive terms added in accord with section 7 apply to the code;
    keep intact all notices of the absence of any warranty; and give all
    recipients a copy of this License along with the Program.
    
      You may charge any price or no price for each copy that you convey,
    and you may offer support or warranty protection for a fee.
    
      5. Conveying Modified Source Versions.
    
      You may convey a work based on the Program, or the modifications to
    produce it from the Program, in the form of source code under the
    terms of section 4, provided that you also meet all of these conditions:
    
        a) The work must carry prominent notices stating that you modified
        it, and giving a relevant date.
    
        b) The work must carry prominent notices stating that it is
        released under this License and any conditions added under section
        7.  This requirement modifies the requirement in section 4 to
        "keep intact all notices".
    
        c) You must license the entire work, as a whole, under this
        License to anyone who comes into possession of a copy.  This
        License will therefore apply, along with any applicable section 7
        additional terms, to the whole of the work, and all its parts,
        regardless of how they are packaged.  This License gives no
        permission to license the work in any other way, but it does not
        invalidate such permission if you have separately received it.
    
        d) If the work has interactive user interfaces, each must display
        Appropriate Legal Notices; however, if the Program has interactive
        interfaces that do not display Appropriate Legal Notices, your
        work need not make them do so.
    
      A compilation of a covered work with other separate and independent
    works, which are not by their nature extensions of the covered work,
    and which are not combined with it such as to form a larger program,
    in or on a volume of a storage or distribution medium, is called an
    "aggregate" if the compilation and its resulting copyright are not
    used to limit the access or legal rights of the compilation's users
    beyond what the individual works permit.  Inclusion of a covered work
    in an aggregate does not cause this License to apply to the other
    parts of the aggregate.
    
      6. Conveying Non-Source Forms.
    
      You may convey a covered work in object code form under the terms
    of sections 4 and 5, provided that you also convey the
    machine-readable Corresponding Source under the terms of this License,
    in one of these ways:
    
        a) Convey the object code in, or embodied in, a physical product
        (including a physical distribution medium), accompanied by the
        Corresponding Source fixed on a durable physical medium
        customarily used for software interchange.
    
        b) Convey the object code in, or embodied in, a physical product
        (including a physical distribution medium), accompanied by a
        written offer, valid for at least three years and valid for as
        long as you offer spare parts or customer support for that product
        model, to give anyone who possesses the object code either (1) a
        copy of the Corresponding Source for all the software in the
        product that is covered by this License, on a durable physical
        medium customarily used for software interchange, for a price no
        more than your reasonable cost of physically performing this
        conveying of source, or (2) access to copy the
        Corresponding Source from a network server at no charge.
    
        c) Convey individual copies of the object code with a copy of the
        written offer to provide the Corresponding Source.  This
        alternative is allowed only occasionally and noncommercially, and
        only if you received the object code with such an offer, in accord
        with subsection 6b.
    
        d) Convey the object code by offering access from a designated
        place (gratis or for a charge), and offer equivalent access to the
        Corresponding Source in the same way through the same place at no
        further charge.  You need not require recipients to copy the
        Corresponding Source along with the object code.  If the place to
        copy the object code is a network server, the Corresponding Source
        may be on a different server (operated by you or a third party)
        that supports equivalent copying facilities, provided you maintain
        clear directions next to the object code saying where to find the
        Corresponding Source.  Regardless of what server hosts the
        Corresponding Source, you remain obligated to ensure that it is
        available for as long as needed to satisfy these requirements.
    
        e) Convey the object code using peer-to-peer transmission, provided
        you inform other peers where the object code and Corresponding
        Source of the work are being offered to the general public at no
        charge under subsection 6d.
    
      A separable portion of the object code, whose source code is excluded
    from the Corresponding Source as a System Library, need not be
    included in conveying the object code work.
    
      A "User Product" is either (1) a "consumer product", which means any
    tangible personal property which is normally used for personal, family,
    or household purposes, or (2) anything designed or sold for incorporation
    into a dwelling.  In determining whether a product is a consumer product,
    doubtful cases shall be resolved in favor of coverage.  For a particular
    product received by a particular user, "normally used" refers to a
    typical or common use of that class of product, regardless of the status
    of the particular user or of the way in which the particular user
    actually uses, or expects or is expected to use, the product.  A product
    is a consumer product regardless of whether the product has substantial
    commercial, industrial or non-consumer uses, unless such uses represent
    the only significant mode of use of the product.
    
      "Installation Information" for a User Product means any methods,
    procedures, authorization keys, or other information required to install
    and execute modified versions of a covered work in that User Product from
    a modified version of its Corresponding Source.  The information must
    suffice to ensure that the continued functioning of the modified object
    code is in no case prevented or interfered with solely because
    modification has been made.
    
      If you convey an object code work under this section in, or with, or
    specifically for use in, a User Product, and the conveying occurs as
    part of a transaction in which the right of possession and use of the
    User Product is transferred to the recipient in perpetuity or for a
    fixed term (regardless of how the transaction is characterized), the
    Corresponding Source conveyed under this section must be accompanied
    by the Installation Information.  But this requirement does not apply
    if neither you nor any third party retains the ability to install
    modified object code on the User Product (for example, the work has
    been installed in ROM).
    
      The requirement to provide Installation Information does not include a
    requirement to continue to provide support service, warranty, or updates
    for a work that has been modified or installed by the recipient, or for
    the User Product in which it has been modified or installed.  Access to a
    network may be denied when the modification itself materially and
    adversely affects the operation of the network or violates the rules and
    protocols for communication across the network.
    
      Corresponding Source conveyed, and Installation Information provided,
    in accord with this section must be in a format that is publicly
    documented (and with an implementation available to the public in
    source code form), and must require no special password or key for
    unpacking, reading or copying.
    
      7. Additional Terms.
    
      "Additional permissions" are terms that supplement the terms of this
    License by making exceptions from one or more of its conditions.
    Additional permissions that are applicable to the entire Program shall
    be treated as though they were included in this License, to the extent
    that they are valid under applicable law.  If additional permissions
    apply only to part of the Program, that part may be used separately
    under those permissions, but the entire Program remains governed by
    this License without regard to the additional permissions.
    
      When you convey a copy of a covered work, you may at your option
    remove any additional permissions from that copy, or from any part of
    it.  (Additional permissions may be written to require their own
    removal in certain cases when you modify the work.)  You may place
    additional permissions on material, added by you to a covered work,
    for which you have or can give appropriate copyright permission.
    
      Notwithstanding any other provision of this License, for material you
    add to a covered work, you may (if authorized by the copyright holders of
    that material) supplement the terms of this License with terms:
    
        a) Disclaiming warranty or limiting liability differently from the
        terms of sections 15 and 16 of this License; or
    
        b) Requiring preservation of specified reasonable legal notices or
        author attributions in that material or in the Appropriate Legal
        Notices displayed by works containing it; or
    
        c) Prohibiting misrepresentation of the origin of that material, or
        requiring that modified versions of such material be marked in
        reasonable ways as different from the original version; or
    
        d) Limiting the use for publicity purposes of names of licensors or
        authors of the material; or
    
        e) Declining to grant rights under trademark law for use of some
        trade names, trademarks, or service marks; or
    
        f) Requiring indemnification of licensors and authors of that
        material by anyone who conveys the material (or modified versions of
        it) with contractual assumptions of liability to the recipient, for
        any liability that these contractual assumptions directly impose on
        those licensors and authors.
    
      All other non-permissive additional terms are considered "further
    restrictions" within the meaning of section 10.  If the Program as you
    received it, or any part of it, contains a notice stating that it is
    governed by this License along with a term that is a further
    restriction, you may remove that term.  If a license document contains
    a further restriction but permits relicensing or conveying under this
    License, you may add to a covered work material governed by the terms
    of that license document, provided that the further restriction does
    not survive such relicensing or conveying.
    
      If you add terms to a covered work in accord with this section, you
    must place, in the relevant source files, a statement of the
    additional terms that apply to those files, or a notice indicating
    where to find the applicable terms.
    
      Additional terms, permissive or non-permissive, may be stated in the
    form of a separately written license, or stated as exceptions;
    the above requirements apply either way.
    
      8. Termination.
    
      You may not propagate or modify a covered work except as expressly
    provided under this License.  Any attempt otherwise to propagate or
    modify it is void, and will automatically terminate your rights under
    this License (including any patent licenses granted under the third
    paragraph of section 11).
    
      However, if you cease all violation of this License, then your
    license from a particular copyright holder is reinstated (a)
    provisionally, unless and until the copyright holder explicitly and
    finally terminates your license, and (b) permanently, if the copyright
    holder fails to notify you of the violation by some reasonable means
    prior to 60 days after the cessation.
    
      Moreover, your license from a particular copyright holder is
    reinstated permanently if the copyright holder notifies you of the
    violation by some reasonable means, this is the first time you have
    received notice of violation of this License (for any work) from that
    copyright holder, and you cure the violation prior to 30 days after
    your receipt of the notice.
    
      Termination of your rights under this section does not terminate the
    licenses of parties who have received copies or rights from you under
    this License.  If your rights have been terminated and not permanently
    reinstated, you do not qualify to receive new licenses for the same
    material under section 10.
    
      9. Acceptance Not Required for Having Copies.
    
      You are not required to accept this License in order to receive or
    run a copy of the Program.  Ancillary propagation of a covered work
    occurring solely as a consequence of using peer-to-peer transmission
    to receive a copy likewise does not require acceptance.  However,
    nothing other than this License grants you permission to propagate or
    modify any covered work.  These actions infringe copyright if you do
    not accept this License.  Therefore, by modifying or propagating a
    covered work, you indicate your acceptance of this License to do so.
    
      10. Automatic Licensing of Downstream Recipients.
    
      Each time you convey a covered work, the recipient automatically
    receives a license from the original licensors, to run, modify and
    propagate that work, subject to this License.  You are not responsible
    for enforcing compliance by third parties with this License.
    
      An "entity transaction" is a transaction transferring control of an
    organization, or substantially all assets of one, or subdividing an
    organization, or merging organizations.  If propagation of a covered
    work results from an entity transaction, each party to that
    transaction who receives a copy of the work also receives whatever
    licenses to the work the party's predecessor in interest had or could
    give under the previous paragraph, plus a right to possession of the
    Corresponding Source of the work from the predecessor in interest, if
    the predecessor has it or can get it with reasonable efforts.
    
      You may not impose any further restrictions on the exercise of the
    rights granted or affirmed under this License.  For example, you may
    not impose a license fee, royalty, or other charge for exercise of
    rights granted under this License, and you may not initiate litigation
    (including a cross-claim or counterclaim in a lawsuit) alleging that
    any patent claim is infringed by making, using, selling, offering for
    sale, or importing the Program or any portion of it.
    
      11. Patents.
    
      A "contributor" is a copyright holder who authorizes use under this
    License of the Program or a work on which the Program is based.  The
    work thus licensed is called the contributor's "contributor version".
    
      A contributor's "essential patent claims" are all patent claims
    owned or controlled by the contributor, whether already acquired or
    hereafter acquired, that would be infringed by some manner, permitted
    by this License, of making, using, or selling its contributor version,
    but do not include claims that would be infringed only as a
    consequence of further modification of the contributor version.  For
    purposes of this definition, "control" includes the right to grant
    patent sublicenses in a manner consistent with the requirements of
    this License.
    
      Each contributor grants you a non-exclusive, worldwide, royalty-free
    patent license under the contributor's essential patent claims, to
    make, use, sell, offer for sale, import and otherwise run, modify and
    propagate the contents of its contributor version.
    
      In the following three paragraphs, a "patent license" is any express
    agreement or commitment, however denominated, not to enforce a patent
    (such as an express permission to practice a patent or covenant not to
    sue for patent infringement).  To "grant" such a patent license to a
    party means to make such an agreement or commitment not to enforce a
    patent against the party.
    
      If you convey a covered work, knowingly relying on a patent license,
    and the Corresponding Source of the work is not available for anyone
    to copy, free of charge and under the terms of this License, through a
    publicly available network server or other readily accessible means,
    then you must either (1) cause the Corresponding Source to be so
    available, or (2) arrange to deprive yourself of the benefit of the
    patent license for this particular work, or (3) arrange, in a manner
    consistent with the requirements of this License, to extend the patent
    license to downstream recipients.  "Knowingly relying" means you have
    actual knowledge that, but for the patent license, your conveying the
    covered work in a country, or your recipient's use of the covered work
    in a country, would infringe one or more identifiable patents in that
    country that you have reason to believe are valid.
    
      If, pursuant to or in connection with a single transaction or
    arrangement, you convey, or propagate by procuring conveyance of, a
    covered work, and grant a patent license to some of the parties
    receiving the covered work authorizing them to use, propagate, modify
    or convey a specific copy of the covered work, then the patent license
    you grant is automatically extended to all recipients of the covered
    work and works based on it.
    
      A patent license is "discriminatory" if it does not include within
    the scope of its coverage, prohibits the exercise of, or is
    conditioned on the non-exercise of one or more of the rights that are
    specifically granted under this License.  You may not convey a covered
    work if you are a party to an arrangement with a third party that is
    in the business of distributing software, under which you make payment
    to the third party based on the extent of your activity of conveying
    the work, and under which the third party grants, to any of the
    parties who would receive the covered work from you, a discriminatory
    patent license (a) in connection with copies of the covered work
    conveyed by you (or copies made from those copies), or (b) primarily
    for and in connection with specific products or compilations that
    contain the covered work, unless you entered into that arrangement,
    or that patent license was granted, prior to 28 March 2007.
    
      Nothing in this License shall be construed as excluding or limiting
    any implied license or other defenses to infringement that may
    otherwise be available to you under applicable patent law.
    
      12. No Surrender of Others' Freedom.
    
      If conditions are imposed on you (whether by court order, agreement or
    otherwise) that contradict the conditions of this License, they do not
    excuse you from the conditions of this License.  If you cannot convey a
    covered work so as to satisfy simultaneously your obligations under this
    License and any other pertinent obligations, then as a consequence you may
    not convey it at all.  For example, if you agree to terms that obligate you
    to collect a royalty for further conveying from those to whom you convey
    the Program, the only way you could satisfy both those terms and this
    License would be to refrain entirely from conveying the Program.
    
      13. Use with the GNU Affero General Public License.
    
      Notwithstanding any other provision of this License, you have
    permission to link or combine any covered work with a work licensed
    under version 3 of the GNU Affero General Public License into a single
    combined work, and to convey the resulting work.  The terms of this
    License will continue to apply to the part which is the covered work,
    but the special requirements of the GNU Affero General Public License,
    section 13, concerning interaction through a network will apply to the
    combination as such.
    
      14. Revised Versions of this License.
    
      The Free Software Foundation may publish revised and/or new versions of
    the GNU General Public License from time to time.  Such new versions will
    be similar in spirit to the present version, but may differ in detail to
    address new problems or concerns.
    
      Each version is given a distinguishing version number.  If the
    Program specifies that a certain numbered version of the GNU General
    Public License "or any later version" applies to it, you have the
    option of following the terms and conditions either of that numbered
    version or of any later version published by the Free Software
    Foundation.  If the Program does not specify a version number of the
    GNU General Public License, you may choose any version ever published
    by the Free Software Foundation.
    
      If the Program specifies that a proxy can decide which future
    versions of the GNU General Public License can be used, that proxy's
    public statement of acceptance of a version permanently authorizes you
    to choose that version for the Program.
    
      Later license versions may give you additional or different
    permissions.  However, no additional obligations are imposed on any
    author or copyright holder as a result of your choosing to follow a
    later version.
    
      15. Disclaimer of Warranty.
    
      THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
    APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
    HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
    OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
    IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
    ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
    
      16. Limitation of Liability.
    
      IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
    WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
    THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
    GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
    USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
    DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
    PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
    EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
    SUCH DAMAGES.
    
      17. Interpretation of Sections 15 and 16.
    
      If the disclaimer of warranty and limitation of liability provided
    above cannot be given local legal effect according to their terms,
    reviewing courts shall apply local law that most closely approximates
    an absolute waiver of all civil liability in connection with the
    Program, unless a warranty or assumption of liability accompanies a
    copy of the Program in return for a fee.
    
                         END OF TERMS AND CONDITIONS
    
                How to Apply These Terms to Your New Programs
    
      If you develop a new program, and you want it to be of the greatest
    possible use to the public, the best way to achieve this is to make it
    free software which everyone can redistribute and change under these terms.
    
      To do so, attach the following notices to the program.  It is safest
    to attach them to the start of each source file to most effectively
    state the exclusion of warranty; and each file should have at least
    the "copyright" line and a pointer to where the full notice is found.
    
        <one line to give the program's name and a brief idea of what it does.>
        Copyright (C) <year>  <name of author>
    
        This program is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.
    
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
    
        You should have received a copy of the GNU General Public License
        along with this program.  If not, see <https://www.gnu.org/licenses/>.
    
    Also add information on how to contact you by electronic and paper mail.
    
      If the program does terminal interaction, make it output a short
    notice like this when it starts in an interactive mode:
    
        <program>  Copyright (C) <year>  <name of author>
        This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
        This is free software, and you are welcome to redistribute it
        under certain conditions; type `show c' for details.
    
    The hypothetical commands `show w' and `show c' should show the appropriate
    parts of the General Public License.  Of course, your program's commands
    might be different; for a GUI interface, you would use an "about box".
    
      You should also get your employer (if you work as a programmer) or school,
    if any, to sign a "copyright disclaimer" for the program, if necessary.
    For more information on this, and how to apply and follow the GNU GPL, see
    <https://www.gnu.org/licenses/>.
    
      The GNU General Public License does not permit incorporating your program
    into proprietary programs.  If your program is a subroutine library, you
    may consider it more useful to permit linking proprietary applications with
    the library.  If this is what you want to do, use the GNU Lesser General
    Public License instead of this License.  But first, please read
    <https://www.gnu.org/licenses/why-not-lgpl.html>.
    
    README.md Unicode text, UTF-8 text, with very long lines (319)
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    # Paradox: A self-hosted FALSE compiler for Linux x86-64
    
    Paradox is a FALSE compiler emitting 64-bit NASM, written in FALSE itself and targeting the Linux syscall ABI.
    
    Made for [code guessing, round #41](https://cg.esolangs.gay/41/).
    
    Prerequisites: You need NASM and a linker in addition to paradox to compile programs.
    
    You can use an existing FALSE implementation or the included bootstrap.lua to bootstrap paradox.
    
    ## Bootstrapping
    
    ### Using bootstrap.lua
    
    For any given correct input, bootstrap.lua output is (supposed to be) equal to paradox output.
    This means you can use bootstrap.lua as a feature-complete substitue for paradox.
    
    ```sh
    # compile paradox using bootstrap.lua
    ./bootstrap.lua < paradox.false > paradox.asm && nasm -f elf64 paradox.asm && ld paradox.o -o paradox
    ```
    
    ### Using an existing FALSE implementation
    
    Note: paradox uses ø and ß rather than O and B in its own source code. It still supports O and B; to bootstrap paradox with a FALSE implementation that does not support these symbols, use `sed -i 's/ø/O/g;s/ß/B/g' paradox.false` to substitute them.
    
    Note: bootstrapping paradox has been tested with several standard compliant FALSE implementations. If it does not work with a certain implementation, it's likely due to a bug in that implementation.
    
    ```sh
    # make paradox build itself using an existing false implementation to run paradox
    existing_run_false paradox.false < paradox.false > paradox.asm && nasm -f elf64 paradox.asm && ld paradox.o -o paradox
    ```
    
    ## Recompiling self
    
    Paradox can (obviously) rebuild itself once it has been bootstrapped, and the result should be equal.
    
    ```sh
    # rebuild paradox using itself
    ./paradox < paradox.false > paradox2.asm && nasm -f elf64 paradox2.asm && ld paradox2.o -o paradox2
    
    # verify the resulting binaries are equal
    diff paradox paradox2
    ```
    
    ## Additional notes
    
    ### run.sh
    
    For convenience and in accordance with the CG spec, paradox includes a `run.sh` script that will automatically compile and execute a file.
    
    ```sh
    ./run.sh my_file.false
    ```
    
    ### Error handling
    
    Due to lack of `stderr` access in FALSE, syntax errors are emitted as `%fatal` NASM-directives, so you will see them at the assembly stage. `bootstrap.lua` uses stderr and a nonzero exit code to signal errors.
    
    ### I/O Buffering
    
    Paradox implements buffered I/O. You can use ß or B to flush buffered output.
    
    By default, paradox will use a buffer size of 8192, but this can be changed from the source code by using the "U" postfix on a number literal for example:
    
    ```
    1024U
    ```
    
    Sets the buffer size for the program to 1024 **statically, at compile time**. It is not possible to change the buffer size at runtime. If multiple of these statements are found, the one that comes last in the file will determine the buffer size. Note that there may not be a space between the integer literal and the U.
    
    To find out an appropriate buffer size for your system, you can use the following command, if you have a C compiler installed:
    
    ```
    echo '#include <stdio.h>\nBUFSIZ' | cpp | tail -n1
    ```
    
    ### Adjusting stack size
    
    By default, paradox will use 8MiB for both call stack and data stack each. Changing this works similar to changing the buffer size, except S is used instead of U:
    
    ```
    16777216S
    ```
    
    Will set the stack size to 16MiB. This affects both call stack and data stack.
    
    ### Inline assembly
    
    Paradox has its own inline assembly syntax: anything between backticks is emitted as assembly, like so:
    
    ```
    "hi"
    
    { issue exit(0) syscall }
    `mov rax, 60
    mov rdi, 0
    syscall
    `
    
    "bye"
    ```
    
    The output should be just "hi", without "bye".
    
    ### Pointer arithmetic
    
    Paradox (coincidentally) supports pointer arithmetic. Pointers and numbers can be added and subtracted using `+` and `-`.
    
    Note that addition and subtraction (as well as other arithmetic and bitwise operations) operate on 32-bit numbers while pointers are 64-bit, so it will only work reliably as long as the pointers are in the appropriate range.
    
     `;` can be used to read from a pointer; `:` can be used to write to a pointer. Both operations read/write 64 bits.
    
    To read and write individual bytes, one can use bitwise operations.
    
    Variables and lambdas are pointers.
    
    #### String pointers
    
    `["my_stringy"]$2+;$@11+;+\[$@$@>][1-$;,\]#%%10,` will print my_stringy in reverse (ygnirts_ym). This works with any string. This is due to the binary layout of lambdas containing a single string (consisting of just a call to write with the necessary parameters):
    
    ```
    0000000000401002 <fun_1>:
      401002:	48 be 00 20 40 00 00 	movabs rsi,0x402000
      401009:	00 00 00
      40100c:	b9 09 00 00 00       	mov    ecx,0x9
      401011:	e8 86 00 00 00       	call   40109c <write>
      401016:	c3                   	ret
    ```
    
    (generated by `objdump -D -M intel some_binary_here`)
    
    A pointer to the string (0x402000) is stored at offset 2, and the length of the string (0x9) is stored at offset 11.
    
    Strings are stored in the data section, so it is possible to write to them.
    
    It is possible to make memory allocations using strings by compiling your program like so:
    
    ```sh
    (echo "[\"$(head -c YOUR_ALLOCATION_SIZE /dev/zero)\"]" && cat your_source_file.false) | ./paradox
    ```
    
    In the program, you can then use `2+;` at the beginning of the file to extract a pointer to your allocation.
    
    Since all operations fetch 64-bits, it is recommended to set the allocation size to 7 bytes higher than desired (if you wish to fetch/write the last few bytes of the allocation individually).
    
    As an example for pointer arithmetic, see `examples/brainfuck.false` which implements brainfuck using paradox pointer arithmetic.
    
    ### Building untrue
    
    For maximum FALSE meta, you can use paradox to compile the [untrue](https://github.com/appgurueu/codeguessing/blob/master/41/untrue.false) FALSE interpreter and the resulting binary can be used to run paradox.
    Note: Untrue will need an increased stack size to run many programs.
    
    ```
    # download untrue
    curl https://raw.githubusercontent.com/appgurueu/codeguessing/master/41/untrue.false -o untrue.false
    
    # append command to set stack size to 128MiB
    echo "134217728S" >> untrue.false
    
    # build untrue
    ./paradox < untrue.false > untrue.asm && nasm -f elf64 untrue.asm && ld untrue.o -o untrue
    
    # now, we will use untrue to run paradox to compile untrue!
    
    # untrue expects O and B symbols, substitute
    sed 's/ø/O/g;s/ß/B/g' paradox.false > paradox_subst.false
    
    # untrue expects program and input to be separated by '<'
    (cat paradox_subst.false && echo -n '<' && cat untrue.false) | time ./untrue | tee untrue2.asm
    
    # verify resulting assembly is equal
    diff untrue.asm untrue2.asm
    ```
    
    Using untrue to run paradox to build paradox has also been tested (but takes significantly longer).
    
    bootstrap.lua ASCII text
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    #!/usr/bin/env lua
    
    local macros = {
    	["$"] = [[
    mov rax, [r12]
    sub r12, 8
    mov [r12], rax
    ]],
    	["%"] = [[
    add r12, 8
    ]],
    	["\\"] = [[
    mov rax, [r12]
    mov rbx, [r12+8]
    mov [r12], rbx
    mov [r12+8], rax
    ]],
    	["@"] = [[
    mov rax, [r12]
    mov rbx, [r12+8]
    mov rcx, [r12+16]
    mov [r12], rcx
    mov [r12+8], rax
    mov [r12+16], rbx
    ]],
    	["O"] = [[
    mov rax, [r12]
    lea rax, [r12+8*rax]
    mov rax, [rax+8]
    mov [r12], rax
    ]],
    	["+"] = [[
    mov eax, [r12]
    add r12, 8
    add [r12], eax
    ]],
    	["-"] = [[
    mov eax, [r12]
    add r12, 8
    sub [r12], eax
    ]],
    	["*"] = [[
    mov eax, [r12+8]
    imul dword[r12]
    add r12, 8
    mov [r12], eax
    ]],
    	["/"] = [[
    xor edx, edx
    mov eax, [r12+8]
    idiv dword[r12]
    add r12, 8
    mov [r12], eax
    ]],
    	["_"] = [[
    neg dword[r12]
    ]],
    	["&"] = [[
    mov eax, [r12]
    and eax, [r12+8]
    add r12, 8
    mov [r12], eax
    ]],
    	["|"] = [[
    mov eax, [r12]
    or eax, [r12+8]
    add r12, 8
    mov [r12], eax
    ]],
    	["~"] = [[
    not dword[r12]
    ]],
    	[">"] = [[
    mov ebx, 0
    mov ecx, -1
    add r12, 8
    mov eax, [r12]
    cmp eax, [r12-8]
    cmovg ebx, ecx
    mov [r12], ebx
    ]],
    	["="] = [[
    mov ebx, 0
    mov ecx, -1
    add r12, 8
    mov eax, [r12]
    cmp eax, [r12-8]
    cmove ebx, ecx
    mov [r12], ebx
    ]],
    	["!"] = [[
    add r12, 8
    call [r12-8]
    ]],
    	["?"] = [[
    call conditional
    ]],
    	["#"] = [[
    call loop
    ]],
    	[":"] = [[
    add r12, 16
    mov rax, [r12-16]
    mov rbx, [r12-8]
    mov [rax], rbx
    ]],
    	[";"] = [[
    mov rax, [r12]
    mov rax, [rax]
    mov [r12], rax
    ]],
    	[","] = [[
    mov rsi, r12
    mov rcx, 1
    call write
    add r12, 8
    ]],
    	["^"] = [[
    call read
    sub r12, 8
    mov [r12], eax
    ]],
    	["."] = [[
    call print_num
    ]],
    	["B"] = [[
    call flush
    ]],
    }
    
    local fn_counter = 0
    local str_counter = 0
    local current_int
    
    local line_number = 1
    local line_position = 0
    
    local stack_size = 8388608
    local buffer_size = 8192
    
    local c
    
    local function read_char()
    	local char = io.read(1)
    
    	if char == "\n" then
    		line_number = line_number + 1
    		line_position = 0
    	else
    		line_position = line_position + 1
    	end
    
    	return char
    end
    
    local function syntax_error(msg)
    	error("FALSE syntax error at "..line_number..":"..line_position..": " .. msg)
    end
    
    local function compile_fn()
    	local fn_id = fn_counter
    	fn_counter = fn_counter + 1
    
    	print("fun_" .. fn_id .. ":")
    
    	local strings = ""
    
    	c = nil
    
    	while true do
    		if not c then
    			c = read_char()
    		end
    
    		if c and c:match("%d") then
    			current_int = current_int or 0
    			current_int = current_int * 10 + tonumber(c)
    			c = nil
    		elseif current_int then
    			if c == "S" then
    				stack_size = current_int
    				c = nil
    			elseif c == "U" then
    				buffer_size = current_int
    				c = nil
    			else
    				print("sub r12, 8")
    				print("mov qword[r12], " .. current_int)
    			end
    			current_int = nil
    		elseif c and c:match("[a-z]") then
    			print("sub r12, 8")
    			print("mov qword[r12], var_" .. c)
    			c = nil
    		elseif c == "'" then
    			local x = read_char()
    			if not x then
    				syntax_error("unterminated char literal")
    			end
    			print("sub r12, 8")
    			print("mov qword[r12], " .. x:byte(1))
    			c = nil
    		elseif c == "\"" then
    			local str = {}
    			while true do
    				local x = read_char()
    				if not x then
    					syntax_error("unterminated string literal")
    				end
    				if x == "\"" then
    					break
    				end
    				table.insert(str, x:byte(1))
    			end
    			print("mov rsi, str_" .. str_counter)
    			print("mov rcx, " .. #str)
    			print("call write")
    			strings = "str_" .. str_counter .. ": db " .. table.concat(str, ",") .. "\n" .. strings
    			str_counter = str_counter + 1
    			c = nil
    		elseif c == "`" then
    			while true do
    				local x = read_char()
    				if not x then
    					syntax_error("unterminated inline assembly")
    				end
    				if x == "`" then
    					break
    				end
    				io.write(x)
    			end
    			c = nil
    		elseif c == "[" then
    			local lambda = fn_counter
    			print("jmp end_" .. lambda)
    			compile_fn()
    			if c ~= "]" then
    				syntax_error("unterminated lambda")
    			end
    			print("sub r12, 8")
    			print("mov qword[r12], fun_" .. lambda)
    			c = nil
    		elseif c and c:match("%s") then
    			c = nil
    		elseif not c or c == "]" then
    			break
    		elseif c and c:byte(1) == 195 then
    			c = read_char()
    
    			if c and c:byte(1) == 184 then
    				c = "O"
    			elseif c and c:byte(1) == 159 then
    				c = "B"
    			else
    				syntax_error("unknown UTF-8 character")
    			end
    		elseif c and c:byte(1) == 248 then
    			c = "O"
    		elseif c and c:byte(1) == 223 then
    			c = "B"
    		elseif c == "{" then
    			while read_char() ~= "}" do end
    			c = nil
    		elseif c and macros[c] then
    			io.write(macros[c])
    			c = nil
    		else
    			syntax_error("unknown character: " .. c)
    		end
    	end
    
    	print("ret")
    
    	print("section .data")
    	io.write(strings)
    	print("section .text")
    
    	print("end_" .. fn_id .. ":")
    end
    
    print("section .text")
    
    compile_fn()
    
    print("%define STKSIZ " .. stack_size)
    print("%define BUFSIZ " .. buffer_size)
    
    io.write([[
    section .data
    readbuf_len: dq 0
    readbuf_cursor: dq 0
    writebuf_len: dq 0
    section .bss
    readbuf: resb BUFSIZ
    writebuf: resb BUFSIZ
    section .text
    read:
    mov rax, [readbuf_cursor]
    cmp rax, [readbuf_len]
    jb .has
    mov rax, 0
    mov rdi, 0
    mov rsi, readbuf
    mov rdx, BUFSIZ
    syscall
    mov [readbuf_len], rax
    mov qword[readbuf_cursor], 0
    cmp rax, 0
    jne .has
    mov eax, -1
    ret
    .has:
    mov rax, [readbuf_cursor]
    movzx eax, byte[readbuf+rax]
    inc qword[readbuf_cursor]
    ret
    write:
    mov rdi, [writebuf_len]
    mov rax, BUFSIZ
    sub rax, rdi
    add rdi, writebuf
    mov rdx, rcx
    sub rdx, rax
    jna .simple
    mov rcx, rax
    rep movsb
    push rsi
    push rdx
    mov qword[writebuf_len], BUFSIZ
    call flush
    pop rdx
    pop rsi
    cmp rdx, BUFSIZ
    ja .direct
    mov rcx, rdx
    mov rdi, writebuf
    .simple:
    add [writebuf_len], rcx
    rep movsb
    ret
    .direct:
    mov rax, 1
    mov rdi, 1
    syscall
    ret
    flush:
    mov rdx, [writebuf_len]
    cmp rdx, 0
    je .return
    mov rax, 1
    mov rdi, 1
    mov rsi, writebuf
    syscall
    mov qword[writebuf_len], 0
    .return:
    ret
    conditional:
    add r12, 16
    mov eax, [r12-8]
    cmp eax, 0
    je .return
    call [r12-16]
    .return:
    ret
    loop:
    add r12, 16
    sub rsp, 16
    mov rax, [r12-8]
    mov [rsp], rax
    mov rax, [r12-16]
    mov [rsp+8], rax
    .loop:
    call [rsp]
    add r12, 8
    mov eax, [r12-8]
    cmp eax, 0
    je .return
    call [rsp+8]
    jmp .loop
    .return:
    add rsp, 16
    ret
    print_num:
    mov rcx, rsp
    sub rsp, 16
    mov eax, dword[r12]
    add r12, 8
    mov ebx, eax
    neg ebx
    cmp eax, 0
    cmovl eax, ebx
    mov edi, 10
    .loop:
    dec rcx
    xor edx, edx
    idiv edi
    add dl, '0'
    mov byte[rcx], dl
    cmp eax, 0
    jne .loop
    cmp ebx, 0
    jle .print
    dec rcx
    mov byte[rcx], '-'
    .print:
    mov rsi, rcx
    lea rcx, [rsp+16]
    sub rcx, rsi
    call write
    add rsp, 16
    ret
    global _start
    _start:
    lea r12, [data_stack+STKSIZ]
    lea rsp, [call_stack+STKSIZ]
    call fun_0
    call flush
    mov rax, 60
    mov rdi, 0
    syscall
    section .bss
    data_stack: resq STKSIZ
    call_stack: resq STKSIZ
    ]])
    
    print("section .data")
    for x = ("a"):byte(1), ("z"):byte(1) do
    	print("var_" .. string.char(x) .. ": dq 0")
    end
    
    paradox.false Unicode text, UTF-8 text
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    {
    	variables:
    
    	c: current_char
    	q: state: 0=CONTINUE, 1=DONE, 2=ERROR
    
    	f: fn_counter
    	s: str_counter
    
    	i: current_int
    
    	l: line_number
    	p: line_position
    
    	t: stack_size
    	u: buffer_size
    
    	x: compile_fn
    	r: read_char
    	e: error
    }
    
    0  f: { fn_counter <- 0 }
    0  s: { str_counter <- 0 }
    1_ i: { current_int <- -1 }
    
    1  l: { line_number <- 1 }
    0  p: { line_position <- 0 }
    
    8388608 t: { stack_size <- 8MiB }
    8192    u: { buffer_size <- 8KiB }
    
    { read_char() }
    [
    	^ { input <- getchar() }
    	{ if input = newline }
    	$10=$[
    		l; 1+ l: { increment line_number }
    		0 p:     { reset line_position }
    	]?
    	{ else }
    	~[
    		p; 1+ p: { increment line_position }
    	]?
    ]r:
    
    { error(condition, message) }
    [
    	{ if condition}
    	\ [
    		10,"%fatal FALSE syntax error at " { first part of error message }
    		l;.":"p;.": "                      { print line_number and line_position }
    		$! 10,                             { call message }
    		2q:                                { state <- ERROR }
    	]?
    	% { pop message }
    ]e:
    
    { compile_fn() }
    [
    	f;      { push fn_counter }
    	$ 1+ f: { increment fn_counter }
    
    	"fun_" $. ":" 10, { emit label }
    
    	{
    		string stack layout, from top to bottom:
    
    		repeat:
    			id (if -1, we've reached the end)
    			length
    			last .. first char
    	}
    	1_ { string stack end }
    
    	0  q: { state <- CONTINUE }
    	1_ c: { current_char <- EOF }
    
    	{ while state == CONTINUE }
    	[q;0=][
    		{ if current_char = EOF }
    		c;1_=[
    			r;! c: { current_char <- read_char() }
    		]?
    
    		{ if '0'-1 < c < '9'+1 }
    		c;$ '0 1- > \ '9 1+ \ > & $[
    			i;1_=[0 i:]?       { if current_int = -1: current_int <- 0 }
    			i; 10* c; '0- + i: { current_int = current_int * 10 + current_char - '0' }
    			1_ c:              { consume current_char }
    		]?
    
    		{ elseif current_int != -1 }
    		i;1_=~ $[%~1_\]?[
    			{ if current_char = S }
    			c;'S= $[
    				i; t: { stack_size <- current_int }
    				1_ c: { consume current_char }
    			]?
    			{ elseif current_char = U }
    			c;'U= $[%~1_\]?[
    				i; u: { buffer_size <- current_int }
    				1_ c: { consume current_char }
    			]?
    			{ else }
    			~[
    				{ emit push int }
    				"sub r12, 8" 10,
    				"mov qword[r12], " i;. 10,
    			]?
    
    			1_ i: { clear current_int }
    		]?
    
    		{ elseif a-1 < c < z+1 }
    		c;$ 'a 1- > \ 'z 1+ \ > & $[%~1_\]?[
    			{ emit push var ref }
    			"sub r12, 8" 10,
    			"mov qword[r12], var_" c;, 10,
    
    			1_ c: { consume current_char }
    		]?
    
    		{ elseif c = ' }
    		c;''= $[%~1_\]?[
    			r;! { read character literal }
    			$1_=["unterminated char literal"]e;! { check for EOF }
    			{ if state != ERROR }
    			q;2=~ [
    				{ emit push char }
    				"sub r12, 8" 10,
    				"mov qword[r12], " . 10,
    
    				1_ c: { consume current_char }
    			]?
    		]?
    
    		{ elseif c = " }
    		c;'"= $[%~1_\]?[
    			% { drop true to manipulate stack below }
    			0 { length <- 0 }
    
    			{ while read_char() != " and state != ERROR }
    			[
    				r;!           { push read_char() }
    				$1_=["unterminated string literal"]e;! { check for EOF }
    				$'"=~ q;2=~ & { condition }
    			][
    				\  { swap length to top }
    				1+ { increment length }
    			]#
    			% { drop " or EOF }
    
    			{ if state != ERROR }
    			q;2=~ [
    				s;      { id <- str_counter }
    				$ 1+ s: { increment str_counter }
    
    				{ emit print string }
    				"mov rsi, str_" 0 ø . 10,
    				"mov rcx, "     1 ø . 10,
    				"call write" 10,
    
    				1_ c: { consume current_char }
    			]?
    
    			1_ { push true }
    		]?
    
    		{ elseif c = ` }
    		c;'`= $[%~1_\]?[
    			{ while read_char() != ` and state != ERROR }
    			[
    				r;!           { push read_char() }
    				$1_=["unterminated inline assembly"]e;! { check for EOF }
    				$'`=~ q;2=~ & { condition }
    			][,]#
    			% { drop ` or EOF }
    
    			1_ c: { consume current_char }
    		]?
    
    		{ elseif c = (opening bracket) }
    		c;91= $[%~1_\]?[
    			f;                 { backup fn_id }
    			"jmp end_" f;. 10, { skip generated code }
    			x;!                { call compile_fn }
    
    			{ if state = ERROR }
    			q;2=[
    				{ stack is corrupted now }
    				1_ { push true to skip remaining elseif branches }
    			]?
    
    			q;2=~ c;93=~ & ["unterminated lambda"]e;! { ensure current_char was (closing bracket) }
    
    			{ if state != ERROR }
    			q;2=~ [
    				{ emit push fn ref }
    				{ fn_id is top }
    				"sub r12, 8" 10,
    				"mov qword[r12], fun_" . 10,
    
    				0  q: { state <- CONTINUE }
    				1_ c: { clear current_char }
    			]?
    		]?
    
    		{ elseif c is whitespace }
    		c;9= c;10= | c;32= | $[%~1_\]?[
    			1_ c: { consume current_char }
    		]?
    
    		{ elseif c = EOF or c = (closing bracket) }
    		c;1_= c;93= | $[%~1_\]?[
    			1 q: { state <- DONE }
    		]?
    
    		{ elseif c is UTF-8 }
    		c;195= $[%~1_\]?[
    			r;! c: { c <- read_char() }
    
    			c;184=         $[ 'O c:	]? { if c = ø then c <- O }
    			c;159= $[%~1_\]?[ 'B c:	]? { if c = ß then c <- B }
    			~["unknown UTF-8 character"]e;! { else error }
    		]?
    
    		{ elseif c = ø then c <- O }
    		c;248= $[%~1_\]?[ 'O c: ]?
    
    		{ elseif c = ß then c <- B }
    		c;223= $[%~1_\]?[ 'B c: ]?
    
    		{ elseif c = (opening brace) }
    		c;123= $[%~1_\]?[
    			[r;!125=~][]# { while read_char() != (closing brace) }
    			1_ c:         { clear current_char }
    		]?
    
    		{ elseif c = $ }
    		c;'$= $[%~1_\]?[
    "mov rax, [r12]
    sub r12, 8
    mov [r12], rax
    "
    		1_ c:]?
    
    		{ elseif c = % }
    		c;'%= $[%~1_\]?[
    "add r12, 8
    "
    		1_ c:]?
    
    		{ elseif c = \ }
    		c;'\= $[%~1_\]?[
    "mov rax, [r12]
    mov rbx, [r12+8]
    mov [r12], rbx
    mov [r12+8], rax
    "
    		1_ c:]?
    
    		{ elseif c = @ }
    		c;'@= $[%~1_\]?[
    "mov rax, [r12]
    mov rbx, [r12+8]
    mov rcx, [r12+16]
    mov [r12], rcx
    mov [r12+8], rax
    mov [r12+16], rbx
    "
    		1_ c:]?
    
    		{ elseif c = O }
    		c;'O= $[%~1_\]?[
    "mov rax, [r12]
    lea rax, [r12+8*rax]
    mov rax, [rax+8]
    mov [r12], rax
    "
    		1_ c:]?
    
    		{ elseif c = + }
    		c;'+= $[%~1_\]?[
    "mov eax, [r12]
    add r12, 8
    add [r12], eax
    "
    		1_ c:]?
    
    		{ elseif c = - }
    		c;'-= $[%~1_\]?[
    "mov eax, [r12]
    add r12, 8
    sub [r12], eax
    "
    		1_ c:]?
    
    		{ elseif c = * }
    		c;'*= $[%~1_\]?[
    "mov eax, [r12+8]
    imul dword[r12]
    add r12, 8
    mov [r12], eax
    "
    		1_ c:]?
    
    		{ elseif c = / }
    		c;'/= $[%~1_\]?[
    "xor edx, edx
    mov eax, [r12+8]
    idiv dword[r12]
    add r12, 8
    mov [r12], eax
    "
    		1_ c:]?
    
    		{ elseif c = _ }
    		c;'_= $[%~1_\]?[
    "neg dword[r12]
    "
    		1_ c:]?
    
    		{ elseif c = & }
    		c;'&= $[%~1_\]?[
    "mov eax, [r12]
    and eax, [r12+8]
    add r12, 8
    mov [r12], eax
    "
    		1_ c:]?
    
    		{ elseif c = | }
    		c;'|= $[%~1_\]?[
    "mov eax, [r12]
    or eax, [r12+8]
    add r12, 8
    mov [r12], eax
    "
    		1_ c:]?
    
    		{ elseif c = ~ }
    		c;'~= $[%~1_\]?[
    "not dword[r12]
    "
    		1_ c:]?
    
    		{ elseif c = > }
    		c;'>= $[%~1_\]?[
    "mov ebx, 0
    mov ecx, -1
    add r12, 8
    mov eax, [r12]
    cmp eax, [r12-8]
    cmovg ebx, ecx
    mov [r12], ebx
    "
    		1_ c:]?
    
    		{ elseif c = '=' }
    		c;'== $[%~1_\]?[
    "mov ebx, 0
    mov ecx, -1
    add r12, 8
    mov eax, [r12]
    cmp eax, [r12-8]
    cmove ebx, ecx
    mov [r12], ebx
    "
    		1_ c:]?
    
    		{ elseif c = ! }
    		c;'!= $[%~1_\]?[
    "add r12, 8
    call [r12-8]
    "
    		1_ c:]?
    
    		{ elseif c = ? }
    		c;'?= $[%~1_\]?[
    "call conditional
    "
    		1_ c:]?
    
    		{ elseif c = # }
    		c;'#= $[%~1_\]?[
    "call loop
    "
    		1_ c:]?
    
    		{ elseif c = : }
    		c;':= $[%~1_\]?[
    "add r12, 16
    mov rax, [r12-16]
    mov rbx, [r12-8]
    mov [rax], rbx
    "
    		1_ c:]?
    
    		{ elseif c = ; }
    		c;';= $[%~1_\]?[
    "mov rax, [r12]
    mov rax, [rax]
    mov [r12], rax
    "
    		1_ c:]?
    
    		{ elseif c = , }
    		c;',= $[%~1_\]?[
    "mov rsi, r12
    mov rcx, 1
    call write
    add r12, 8
    "
    		1_ c:]?
    
    		{ elseif c = ^ }
    		c;'^= $[%~1_\]?[
    "call read
    sub r12, 8
    mov [r12], eax
    "
    		1_ c:]?
    
    		{ elseif c = . }
    		c;'.= $[%~1_\]?[
    "call print_num
    "
    		1_ c:]?
    
    		{ elseif c = B }
    		c;'B= $[%~1_\]?[
    "call flush
    "
    		1_ c:]?
    
    		{ else error }
    		~["unknown character: "c;,]e;!
    	]#
    
    	{ if state != ERROR }
    	q;2=~[
    		"ret" 10, { emit return to caller }
    
    		"section .data" 10,
    
    		{ string stack is top }
    		{ while top != -1 }
    		[$1_=~][
    			{ id is top }
    			"str_" . ": db " { emit label }
    
    			{ length is top }
    			$ { copy length }
    
    			{ print string }
    			{ while length > 0}
    			[$ 0 >][
    				$ 1+ ø .     { print nth item }
    				1-           { decrement length }
    				$ 0 > [","]? { if length > 0 emit , }
    			]#
    			% { drop 0 }
    
    			{ remove string }
    			{ while length > 0 }
    			[$ 0 >][
    				\  { swap last char with length }
    				%  { drop last char }
    				1- { decrement length }
    			]#
    			% { drop 0 }
    
    			10, { newline }
    		]#
    		% { drop string stack end }
    
    		"section .text" 10,
    
    		{ function counter is top now }
    		"end_" . ":" 10, { end label }
    	]?
    ] x:
    
    "section .text" 10,
    
    x;! { call compile_fn }
    
    { if state != ERROR }
    q;2=~[
    
    { emit constants }
    "%define STKSIZ " t;. 10,
    "%define BUFSIZ " u;. 10,
    
    { emit builtin functions }
    "section .data
    readbuf_len: dq 0
    readbuf_cursor: dq 0
    writebuf_len: dq 0
    section .bss
    readbuf: resb BUFSIZ
    writebuf: resb BUFSIZ
    section .text
    read:
    mov rax, [readbuf_cursor]
    cmp rax, [readbuf_len]
    jb .has
    mov rax, 0
    mov rdi, 0
    mov rsi, readbuf
    mov rdx, BUFSIZ
    syscall
    mov [readbuf_len], rax
    mov qword[readbuf_cursor], 0
    cmp rax, 0
    jne .has
    mov eax, -1
    ret
    .has:
    mov rax, [readbuf_cursor]
    movzx eax, byte[readbuf+rax]
    inc qword[readbuf_cursor]
    ret
    write:
    mov rdi, [writebuf_len]
    mov rax, BUFSIZ
    sub rax, rdi
    add rdi, writebuf
    mov rdx, rcx
    sub rdx, rax
    jna .simple
    mov rcx, rax
    rep movsb
    push rsi
    push rdx
    mov qword[writebuf_len], BUFSIZ
    call flush
    pop rdx
    pop rsi
    cmp rdx, BUFSIZ
    ja .direct
    mov rcx, rdx
    mov rdi, writebuf
    .simple:
    add [writebuf_len], rcx
    rep movsb
    ret
    .direct:
    mov rax, 1
    mov rdi, 1
    syscall
    ret
    flush:
    mov rdx, [writebuf_len]
    cmp rdx, 0
    je .return
    mov rax, 1
    mov rdi, 1
    mov rsi, writebuf
    syscall
    mov qword[writebuf_len], 0
    .return:
    ret
    conditional:
    add r12, 16
    mov eax, [r12-8]
    cmp eax, 0
    je .return
    call [r12-16]
    .return:
    ret
    loop:
    add r12, 16
    sub rsp, 16
    mov rax, [r12-8]
    mov [rsp], rax
    mov rax, [r12-16]
    mov [rsp+8], rax
    .loop:
    call [rsp]
    add r12, 8
    mov eax, [r12-8]
    cmp eax, 0
    je .return
    call [rsp+8]
    jmp .loop
    .return:
    add rsp, 16
    ret
    print_num:
    mov rcx, rsp
    sub rsp, 16
    mov eax, dword[r12]
    add r12, 8
    mov ebx, eax
    neg ebx
    cmp eax, 0
    cmovl eax, ebx
    mov edi, 10
    .loop:
    dec rcx
    xor edx, edx
    idiv edi
    add dl, '0'
    mov byte[rcx], dl
    cmp eax, 0
    jne .loop
    cmp ebx, 0
    jle .print
    dec rcx
    mov byte[rcx], '-'
    .print:
    mov rsi, rcx
    lea rcx, [rsp+16]
    sub rcx, rsi
    call write
    add rsp, 16
    ret
    global _start
    _start:
    lea r12, [data_stack+STKSIZ]
    lea rsp, [call_stack+STKSIZ]
    call fun_0
    call flush
    mov rax, 60
    mov rdi, 0
    syscall
    section .bss
    data_stack: resq STKSIZ
    call_stack: resq STKSIZ
    "
    
    { emit variables }
    
    "section .data" 10,
    
    'a { iter <- a}
    { while iter != z+1}
    [$ 'z1+ =~][
    	"var_" $, ": dq 0" 10, { emit allocation }
    	1+                     { increment iter }
    ]#
    % { drop iter }
    
    ]?
    
    ß
    
    run.sh ASCII text
    1
    2
    3
    4
    5
    6
    #!/bin/bash
    set -e
    ./paradox < "$1" > "/tmp/$1.asm"
    nasm -f elf64 "/tmp/$1.asm" -o "/tmp/$1.o"
    ld "/tmp/$1.o" -o "$1.bin"
    ./"$1.bin"
    

    entry #3

    written by navi
    submitted at
    1 like

    guesses
    comments 0

    post a comment


    main.c ASCII text
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <signal.h>
    #include <ctype.h>
    
    
    enum exec_result {
    	PARSE_OK,
    	ERR_EXPECTED_INT,
    	ERR_EXPECTED_REF,
    	ERR_EXPECTED_QUOTE,
    	ERR_STACK_EMPTY,
    	ERR_INVALID_INT,
    	ERR_INVALID_LITERAL,
    	ERR_EOF
    };
    
    const char *exec_err(enum exec_result res) {
    	switch(res) {
    		case PARSE_OK:
    			return "parsed successfully";
    		case ERR_INVALID_LITERAL:
    			return "invalid literal";
    		case ERR_EXPECTED_INT:
    			return "expected int on the stack";
    		case ERR_EXPECTED_REF:
    			return "expected reference on the stack";
    		case ERR_EXPECTED_QUOTE:
    			return "expected quote on the stack";
    		case ERR_STACK_EMPTY:
    			return "tried to pop empty stack";
    		case ERR_INVALID_INT:
    			return "invalid int";
    		case ERR_EOF:
    			return "end of file";
    	}
    	return "";
    }
    
    struct string {
    	char *data;
    	size_t size;
    	size_t index;
    };
    
    struct string load_file(char *filename) {
    	struct string str = {0};
    	FILE *fp = fopen(filename, "r");
    	if (!fp) exit(1);
    	fseek(fp, 0, SEEK_END);
    	str.size = ftell(fp);
    	fseek(fp , 0, SEEK_SET);
    	str.data = calloc(str.size + 1, sizeof(char));
    	fread(str.data, 1, str.size, fp);
    	fclose(fp);
    
    	return str;
    }
    
    struct value {
    	enum {
    		VALUE_INT,
    		VALUE_REF,
    		VALUE_QUOTE
    	} type;
    	union {
    		int32_t i;
    		int ref_index;
    		char *quote;
    	};
    };
    
    struct program {
    	struct value **stack;
    	size_t nvals, maxvals;
    	struct value *vars[26];
    };
    
    struct program *program_init() {
    	struct program *p = malloc(sizeof(*p));
    	p->maxvals = 1024;
    	p->stack = calloc(p->maxvals, sizeof(*p->stack));
    	p->nvals = 0;
    	return p;
    }
    
    struct value *pop(struct program *stack) {
    	if (stack->nvals == 0) {
    		return NULL;
    	}
    	stack->nvals--;
    	struct value *val = stack->stack[stack->nvals];
    	stack->stack[stack->nvals] = NULL;
    
    	return val;
    }
    
    void push(struct program *stack, struct value *val) {
    	if (stack->nvals + 1 >= stack->maxvals) {
    		stack->maxvals *= 2;
    		stack->stack = realloc(stack->stack, stack->maxvals * sizeof(*stack->stack));
    	}
    
    	stack->stack[stack->nvals++] = val;
    }
    
    struct value *make_integer(int32_t val) {
    	struct value *sval = malloc(sizeof(*sval));
    	sval->type = VALUE_INT;
    	sval->i = val;
    	return sval;
    }
    
    struct value *make_reference(char val) {
    	struct value *sval = malloc(sizeof(*sval));
    	sval->type = VALUE_REF;
    	sval->ref_index = val - 'a';
    	return sval;
    }
    
    struct value *make_quote(char *val) {
    	struct value *sval = malloc(sizeof(*sval));
    	sval->type = VALUE_QUOTE;
    	sval->quote = val;
    	return sval;
    }
    
    struct value *dup_value(struct value *src) {
    	struct value *sval = malloc(sizeof(*sval));
    	*sval = *src;
    	if (src->type == VALUE_QUOTE) {
    		sval->quote = strdup(src->quote);
    	}
    	return sval;
    }
    
    void free_value(struct value *val) {
    	if (val->type == VALUE_QUOTE)
    		free(val->quote);
    	free(val);
    }
    
    enum exec_result execute_program(struct program *p, struct string *data) {
    	enum exec_result ret = PARSE_OK;
    	char *end = data->data + data->size;
    	for (char *c = data->data; c < end; c++) {
    		/* skip whitespaces */
    		for (; c < end && (*c == '\t' || *c == '\n' || *c == ' '); c++);
    
    		/* if we end at a whitespace it won't break */
    		if (c == end || *c == '\0') break;
    
    		switch (*c) {
    			case '{':
    				for (; c < end && *c != '}'; c++);
    				break;
    			case '\'':
    				if (c + 1 >= end) {
    					ret = ERR_EOF;
    					goto end;
    				}
    				push(p, make_integer(*(++c)));
    				break;
    			case '"':
    				for (++c; c < end && *c != '"'; c++)
    					fputc(*c, stdout);
    				break;
    			case '[': {
    				char *closing = ++c;
    				int nest = 0;
    				for (; closing < end; closing++) {
    					if (*closing == '[') {
    						nest++;
    					} else if (*closing == ']' && nest-- == 0) {
    						break;
    					}
    				};
    				push(p, make_quote(strndup(c, closing - c)));
    				c = closing;
    				break;
    			}
    			case ';': {
    				struct value *ref = pop(p);
    				if (ref->type != VALUE_REF) {
    					ret = ERR_EXPECTED_REF;
    					free_value(ref);
    					goto end;
    				}
    				push(p, dup_value(p->vars[ref->ref_index]));
    				free_value(ref);
    				break;
    			}
    			case ':': {
    				if (p->nvals < 2) {
    					ret = ERR_STACK_EMPTY;
    					goto end;
    				}
    				struct value *ref = pop(p);
    				struct value *val = pop(p);
    				if (ref->type != VALUE_REF) {
    					ret = ERR_EXPECTED_REF;
    					free_value(ref);
    					free_value(val);
    					goto end;
    				}
    				p->vars[ref->ref_index] = val;
    				free_value(ref);
    				break;
    			}
    			case '$':
    				push(p, dup_value(p->stack[p->nvals - 1]));
    				break;
    			case '%':
    				free_value(pop(p)); // todo memory leak
    				break;
    			case '\\': {
    				if (p->nvals < 2)
    					exit(1);
    				struct value *tmp = p->stack[p->nvals - 1];
    				p->stack[p->nvals - 1] = p->stack[p->nvals - 2];
    				p->stack[p->nvals - 2] = tmp;
    				break;
    			}
    			case '@': {
    				if (p->nvals < 3)
    					exit(1);
    				struct value *tmp = p->stack[p->nvals - 3];
    				p->stack[p->nvals - 3] = p->stack[p->nvals - 2];
    				p->stack[p->nvals - 2] = p->stack[p->nvals - 1];
    				p->stack[p->nvals - 1] = tmp;
    				break;
    			}
    			case 'O': {
    				struct value *ind = pop(p);
    				if (ind->type != VALUE_INT) {
    					ret = ERR_EXPECTED_INT;
    					free_value(ind);
    					goto end;
    				}
    				if (ind->i > p->nvals) {
    					ret = ERR_STACK_EMPTY;
    					free_value(ind);
    					goto end;
    				}
    				push(p, dup_value(p->stack[p->nvals - ind->i - 1]));
    				free_value(ind);
    				break;
    			}
    			case '+': {
    				if (p->nvals < 2) {
    					ret = ERR_STACK_EMPTY;
    					goto end;
    				}
    				struct value *v1 = pop(p);
    				struct value *v2 = pop(p);
    				if (v1->type != VALUE_INT || v2->type != VALUE_INT) {
    					ret = ERR_EXPECTED_INT;
    					free_value(v1);
    					free_value(v2);
    					goto end;
    				}
    				push(p, make_integer(v1->i + v2->i));
    				free_value(v1);
    				free_value(v2);
    				break;
    			}
    			case '-': {
    				if (p->nvals < 2) {
    					ret = ERR_STACK_EMPTY;
    					goto end;
    				}
    				struct value *v1 = pop(p);
    				struct value *v2 = pop(p);
    				if (v1->type != VALUE_INT || v2->type != VALUE_INT) {
    					ret = ERR_EXPECTED_INT;
    					free_value(v1);
    					free_value(v2);
    					goto end;
    				}
    				push(p, make_integer(v2->i - v1->i));
    				free_value(v1);
    				free_value(v2);
    				break;
    			}
    			case '*': {
    				if (p->nvals < 2) {
    					ret = ERR_STACK_EMPTY;
    					goto end;
    				}
    				struct value *v1 = pop(p);
    				struct value *v2 = pop(p);
    				if (v1->type != VALUE_INT || v2->type != VALUE_INT) {
    					ret = ERR_EXPECTED_INT;
    					free_value(v1);
    					free_value(v2);
    					goto end;
    				}
    				push(p, make_integer(v1->i * v2->i));
    				free_value(v1);
    				free_value(v2);
    				break;
    			}
    			case '/': {
    				if (p->nvals < 2) {
    					ret = ERR_STACK_EMPTY;
    					goto end;
    				}
    				struct value *v1 = pop(p);
    				struct value *v2 = pop(p);
    				if (v1->type != VALUE_INT || v2->type != VALUE_INT) {
    					ret = ERR_EXPECTED_INT;
    					free_value(v1);
    					free_value(v2);
    					goto end;
    				}
    				push(p, make_integer(v2->i / v1->i));
    				free_value(v1);
    				free_value(v2);
    				break;
    			}
    			case '_': {
    				if (p->nvals < 1) {
    					ret = ERR_STACK_EMPTY;
    					goto end;
    				}
    				struct value *val = pop(p);
    				if (val->type != VALUE_INT) {
    					ret = ERR_EXPECTED_INT;
    					free_value(val);
    					goto end;
    				}
    				push(p, make_integer(-val->i));
    				free_value(val);
    				break;
    			}
    			case '&': {
    				if (p->nvals < 2) {
    					ret = ERR_STACK_EMPTY;
    					goto end;
    				}
    				struct value *v1 = pop(p);
    				struct value *v2 = pop(p);
    				if (v1->type != VALUE_INT || v2->type != VALUE_INT) {
    					ret = ERR_EXPECTED_INT;
    					free_value(v1);
    					free_value(v2);
    					goto end;
    				}
    				push(p, make_integer(v2->i & v1->i));
    				free_value(v1);
    				free_value(v2);
    				break;
    			}
    			case '|': {
    				if (p->nvals < 2) {
    					ret = ERR_STACK_EMPTY;
    					goto end;
    				}
    				struct value *v1 = pop(p);
    				struct value *v2 = pop(p);
    				if (v1->type != VALUE_INT || v2->type != VALUE_INT) {
    					ret = ERR_EXPECTED_INT;
    					free_value(v1);
    					free_value(v2);
    					goto end;
    				}
    				push(p, make_integer(v2->i | v1->i));
    				free_value(v1);
    				free_value(v2);
    				break;
    			}
    			case '~': {
    				if (p->nvals < 1) {
    					ret = ERR_STACK_EMPTY;
    					goto end;
    				}
    				struct value *v1 = pop(p);
    				if (v1->type != VALUE_INT) {
    					ret = ERR_EXPECTED_INT;
    					free_value(v1);
    					goto end;
    				}
    				push(p, make_integer(~v1->i));
    				free_value(v1);
    				break;
    			}
    			case '=': {
    				if (p->nvals < 2) {
    					ret = ERR_STACK_EMPTY;
    					goto end;
    				}
    				struct value *v1 = pop(p);
    				struct value *v2 = pop(p);
    				if (v1->type != VALUE_INT || v2->type != VALUE_INT) {
    					ret = ERR_EXPECTED_INT;
    					free_value(v1);
    					free_value(v2);
    					goto end;
    				}
    				push(p, v1->i == v2->i ? make_integer(-1) : make_integer(0));
    				free_value(v1);
    				free_value(v2);
    				break;
    			}
    			case '>': {
    				if (p->nvals < 2) {
    					ret = ERR_STACK_EMPTY;
    					goto end;
    				}
    				struct value *v1 = pop(p);
    				struct value *v2 = pop(p);
    				if (v1->type != VALUE_INT || v2->type != VALUE_INT) {
    					ret = ERR_EXPECTED_INT;
    					free_value(v1);
    					free_value(v2);
    					goto end;
    				}
    				push(p, v2->i > v1->i ? make_integer(-1) : make_integer(0));
    				free_value(v1);
    				free_value(v2);
    				break;
    			}
    			case '!': {
    				if (p->nvals < 1) {
    					ret = ERR_STACK_EMPTY;
    					goto end;
    				}
    				struct value *v1 = pop(p);
    				if (v1->type != VALUE_QUOTE) {
    					ret = ERR_EXPECTED_QUOTE;
    					free_value(v1);
    					goto end;
    				}
    				struct string s = { .data = v1->quote, .size = strlen(v1->quote) };
    				ret = execute_program(p, &s);
    				free_value(v1);
    				if (ret != PARSE_OK) {
    					goto end;
    				}
    				break;
    			}
    			case '?': {
    				if (p->nvals < 2) {
    					ret = ERR_STACK_EMPTY;
    					goto end;
    				}
    				struct value *v1 = pop(p);
    				struct value *v2 = pop(p);
    				if (v1->type != VALUE_QUOTE) {
    					ret = ERR_EXPECTED_QUOTE;
    					free_value(v1);
    					free_value(v2);
    					goto end;
    				}
    				if (v2->type != VALUE_INT) {
    					ret = ERR_EXPECTED_INT;
    					free_value(v1);
    					free_value(v2);
    					goto end;
    				}
    				if (v2->i != 0) {
    					struct string s = { .data = v1->quote, .size = strlen(v1->quote) };
    					ret = execute_program(p, &s);
    					if (ret != PARSE_OK) {
    						free_value(v1);
    						free_value(v2);
    						goto end;
    					}
    				}
    				free_value(v1);
    				free_value(v2);
    				break;
    			}
    			case '#': {
    				if (p->nvals < 2) {
    					ret = ERR_STACK_EMPTY;
    					goto end;
    				}
    				struct value *v1 = pop(p);
    				struct value *v2 = pop(p);
    				if (v1->type != VALUE_QUOTE || v2->type != VALUE_QUOTE) {
    					ret = ERR_EXPECTED_QUOTE;
    					free_value(v1);
    					free_value(v2);
    					goto end;
    				}
    				struct string body_quote = { .data = v1->quote, .size = strlen(v1->quote) };
    				struct string cond_quote = { .data = v2->quote, .size = strlen(v2->quote) };
    				ret = execute_program(p, &cond_quote);
    				if (ret != PARSE_OK) {
    					free_value(v1);
    					free_value(v2);
    					goto end;
    				}
    				struct value *cond = pop(p);
    				if (cond->type != VALUE_INT) {
    					ret = ERR_EXPECTED_INT;
    					free_value(v1);
    					free_value(v2);
    					free_value(cond);
    					goto end;
    				}
    				while (cond->i != 0) {
    					free_value(cond);
    					ret = execute_program(p, &body_quote);
    					if (ret != PARSE_OK) {
    						free_value(v1);
    						free_value(v2);
    						free_value(cond);
    						goto end;
    					}
    					ret = execute_program(p, &cond_quote);
    					if (ret != PARSE_OK) {
    						free_value(v1);
    						free_value(v2);
    						free_value(cond);
    						goto end;
    					}
    					cond = pop(p);
    				}
    				free_value(v1);
    				free_value(v2);
    				free_value(cond);
    				break;
    
    			}
    			case '^': {
    				char in = fgetc(stdin);
    				if (in == EOF) {
    					push(p, make_integer(-1));
    				} else {
    					push(p, make_integer(in));
    				}
    				break;
    			}
    			case ',': {
    				if (p->nvals < 1) {
    					ret = ERR_STACK_EMPTY;
    					goto end;
    				}
    				struct value *val = pop(p);
    				if (val->type != VALUE_INT) {
    					ret = ERR_EXPECTED_INT;
    					free_value(val);
    					goto end;
    				}
    				if (val->i > 255) {
    					ret = ERR_INVALID_INT;
    					free_value(val);
    					goto end;
    				}
    				fputc(val->i, stdout);
    				free_value(val);
    				break;
    			}
    			case '.': {
    				if (p->nvals < 1) {
    					ret = ERR_STACK_EMPTY;
    					goto end;
    				}
    				struct value *val = pop(p);
    				if (val->type != VALUE_INT) {
    					ret = ERR_EXPECTED_INT;
    					free_value(val);
    					goto end;
    				}
    				fprintf(stdout, "%d", val->i);
    				free_value(val);
    				break;
    			}
    			case 'B':
    				break;
    			case '`':
    				break;
    			default: {
    				if (isalpha(*c)) {
    					push(p, make_reference(*c));
    				} else if (isdigit(*c)) {
    					char *end;
    					int32_t v = strtol(c, &end, 10);
    					push(p, make_integer(v));
    					c = end - 1;
    				} else {
    					ret = ERR_INVALID_LITERAL;
    					goto end;
    				}
    				break;
    			}
    		}
    	}
    
    end:
    	return ret;
    }
    
    int main(int argc, char **argv) {
    	if (argc != 2)
    		exit(1);
    
    	struct string program = load_file(argv[1]);
    	struct program *p = program_init();
    
    	enum exec_result ret = execute_program(p, &program);
    
    	if (ret != PARSE_OK) {
    		printf("failed to interpret: %s\n", exec_err(ret));
    	}
    
    	return ret;
    }
    

    entry #4

    written by Palaiologos
    submitted at
    2 likes

    guesses
    comments 0

    post a comment


    false.bf.zst Zstandard compressed data (v0.8+), Dictionary ID: None

    entry #5

    written by luatic
    submitted at
    4 likes

    guesses
    comments 0

    post a comment


    41.zig Unicode text, UTF-8 text
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    // FALSE bytecode compiler & VM for round 41 of code guessing (https://cg.esolangs.gay/41/).
    // Written by Lars Müller. Licensed under the MIT license.
    // Compile using `zig build-exe 41.zig -O ReleaseFast -fstrip -fsingle-threaded`.
    
    const std = @import("std");
    
    const Allocator = std.mem.Allocator;
    
    const Op = enum(u32) {
    	// 🥺
    	Push,
    	GetReg,
    	SetReg,
    	// Stack reordering
    	Dup,
    	Drop,
    	Swap,
    	Rot,
    	Index,
    	// Binops
    	Add,
    	Sub,
    	Mul,
    	Div,
    	And,
    	Or,
    	Eq,
    	Gt,
    	// Unops
    	Inv,
    	Neg,
    	// Control flow
    	Jmp,
    	Call,
    	CallIf,
    	Ret,
    	LoopSetup,
    	LoopTest,
    	LoopBody,
    	// I/O
    	ReadByte,
    	WriteByte,
    	WriteInt, // technically redundant (like plenty of other instructions too) but I'm too laziggy and performance or something
    	Flush,
    };
    
    // teknikhally this is a bytecode builder - 🤓
    const Bytecode = struct {
    	allocator: Allocator,
    	words: std.ArrayList(u32),
    	pub fn init(allocator: Allocator) Bytecode {
    		return Bytecode{.allocator = allocator, .words = std.ArrayList(u32).init(allocator)};
    	}
    	pub fn deinit(self: *Bytecode) void {
    		self.words.deinit();
    	}
    	pub fn getWords(self: *Bytecode) []u32 {
    		return self.words.items;
    	}
    	fn emit(self: *Bytecode, op: Op) !void {
    		try self.words.append(@intFromEnum(op));
    	}
    	fn emitToPatch(self: *Bytecode) !usize {
    		try self.words.append(0xDEADBEEF);
    		return self.words.items.len - 1;
    	}
    	fn patch(self: *Bytecode, i: usize, u: u32) void {
    		self.words.items[i] = u;
    	}
    	fn emitPush(self: *Bytecode, u: u32) !void {
    		try self.emit(.Push);
    		try self.words.append(u);
    	}
    	fn append(self: *Bytecode, other: Bytecode) !u32 {
    		const nextPos: u32 = @intCast(self.words.items.len);
    		try self.words.appendSlice(other.words.items);
    		return nextPos;
    	}
    };
    
    // shot🔫 parser & bytecode emitter
    fn Compiler(comptime R: type) type {
    	return struct {
    		const Self = @This();
    		allocator: Allocator,
    		in: R,
    		b: ?u8 = null,
    		bytecode: Bytecode,
    		pub fn init(allocator: Allocator, in: R) Self {
    			return Self{.allocator = allocator, .in = in, .bytecode = Bytecode.init(allocator)};
    		}
    		pub fn reset(self: *Self) void {
    			self.b = null;
    			self.bytecode = Bytecode.init(self.allocator);
    		}
    		pub fn deinit(self: *Self) void {
    			self.bytecode.deinit();
    		}
    
    		fn readByte(self: *Self) !u8 {
    			const b = self.b;
    			if (b == null)
    				return self.in.readByte();
    			self.b = null;
    			return b.?;
    		}
    		fn unreadByte(self: *Self, b: u8) void {
    			self.b = b;
    		}
    
    		pub fn compileFn(self: *Self) !u32 {
    			var bytecode = Bytecode.init(self.allocator);
    			defer bytecode.deinit();
    			while (true) {
    				const b = self.readByte() catch |err| {
    					if (err == error.EndOfStream) break;
    					return err;
    				};
    				try switch (b) {
    					'\t', ' ', '\n' => {},
    					'{' => while (try self.readByte() != '}') {},
    					'"' => while (true) {
    						const quotedB = try self.readByte();
    						if (quotedB == '"') break;
    						try bytecode.emitPush(@as(u32, quotedB));
    						try bytecode.emit(.WriteByte);
    					},
    					'\'' => {
    						const quotedB = try self.readByte();
    						try bytecode.emitPush(@as(u32, quotedB));
    					},
    					'0' ... '9' => {
    						var u: u32 = b - '0';
    						var nb: u8 = undefined;
    						while (true) {
    							nb = self.readByte() catch |err| {
    								if (err == error.EndOfStream) break;
    								return err;
    							};
    							if (nb < '0' or nb > '9') break;
    							u = 10 * u + nb - '0';
    						}
    						self.unreadByte(nb);
    						try bytecode.emitPush(u);
    					},
    					'a' ... 'z' => try bytecode.emitPush(@as(u32, b - 'a')),
    					'[' => {
    						try bytecode.emit(.Push);
    						const i = try bytecode.emitToPatch();
    						bytecode.patch(i, try self.compileFn());
    						if (try self.readByte() != ']') return error.UnclosedQuote;
    					},
    					']' => {
    						self.unreadByte(']');
    						break;
    					},
    					'!' => bytecode.emit(.Call),
    					'?' => bytecode.emit(.CallIf),
    					'#' => {
    						// too laziggy to relocate addresses for jumps so here you go, loops get three instructions
    						for ([_]Op{.LoopSetup, .LoopTest, .LoopBody}) |op| try bytecode.emit(op);
    					},
    					else => try bytecode.emit(switch (b) {
    						';' => .GetReg,
    						':' => .SetReg,
    						'$' => .Dup,
    						'%' => .Drop,
    						'\\' => .Swap,
    						'@' => .Rot,
    						'O' => .Index,
    						'+' => .Add,
    						'-' => .Sub,
    						'/' => .Div,
    						'*' => .Mul,
    						'|' => .Or,
    						'&' => .And,
    						'=' => .Eq,
    						'>' => .Gt,
    						'~' => .Inv,
    						'_' => .Neg,
    						'^' => .ReadByte,
    						',' => .WriteByte,
    						'.' => .WriteInt,
    						'B' => .Flush,
    						else => return error.InvalidInstruction, // includes '`'
    					}),
    				};
    			}
    			try bytecode.emit(.Ret);
    			return try self.bytecode.append(bytecode);
    		}
    		pub fn compile(self: *Self) !Bytecode {
    			try self.bytecode.emit(.Push);
    			const i = try self.bytecode.emitToPatch();
    			try self.bytecode.emit(.Jmp);
    			self.bytecode.patch(i, try self.compileFn());
    			const bytecode = self.bytecode;
    			self.reset();
    			return bytecode;
    		}
    	};
    }
    
    // we skimp on error checking here (gotta go fast);
    // FALSE programmers can be trusted to not ever make oopsies
    // thus there is no typechecking (num/quote/char/reg etc.) here,
    // no bounds checking, no stack overflow or underflow checking
    // (Zig will trap the "unreachable" code though)
    fn VM(comptime R: type, comptime W: type) type {
    	return struct {
    		const Self = @This();
    		stack: std.ArrayList(u32),
    		retstack: std.ArrayList(u32),
    		regs: [32]u32 = undefined, // did you want zeroes? no zeroes for you.
    		// i already gifted you a few registers, be grateful!
    		in: R,
    		out: W,
    		pub fn init(allocator: Allocator, in: R, out: W) Self {
    			return Self{
    				.stack = std.ArrayList(u32).init(allocator),
    				.retstack = std.ArrayList(u32).init(allocator),
    				.in = in,
    				.out = out,
    			};
    		}
    		pub fn deinit(vm: *Self) void {
    			vm.flush();
    			vm.stack.deinit();
    			vm.retstack.deinit();
    		}
    		fn pop(vm: *Self) u32 {
    			return vm.stack.pop(); // what is an error?
    		}
    		fn push(vm: *Self, u: u32) void {
    			vm.stack.append(u) catch unreachable; // gotta go fast
    		}
    		fn drop(vm: *Self) void {
    			_ = vm.pop();
    		}
    		fn dup(vm: *Self) void {
    			vm.push(vm.stack.getLast());
    		}
    		fn swap(vm: *Self) void {
    			const top = vm.pop();
    			const bot = vm.pop();
    			vm.push(top);
    			vm.push(bot);
    		}
    		fn rot(vm: *Self) void {
    			const top = vm.pop();
    			const mid = vm.pop();
    			const bot = vm.pop();
    			vm.push(mid);
    			vm.push(top);
    			vm.push(bot);
    		}
    		fn index(vm: *Self) void {
    			const j = vm.pop();
    			const i = vm.stack.items.len - j - 1;
    			vm.push(vm.stack.items[i]); // what is an OOB
    		}
    
    		fn binop(vm: *Self, comptime op: fn(lhs: u32, rhs: u32) u32) void {
    			const rhs = vm.pop();
    			const lhs = vm.pop();
    			vm.push(op(lhs, rhs));
    		}
    		// u32, i32, it's all the same (modular arithmetic says hi)
    		fn add(lhs: u32, rhs: u32) u32 { return lhs +% rhs; }
    		fn sub(lhs: u32, rhs: u32) u32 { return lhs -% rhs; }
    		fn mul(lhs: u32, rhs: u32) u32 { return lhs *% rhs; }
    		fn div(lhs: u32, rhs: u32) u32 { return @divTrunc(lhs, rhs); }
    		fn band(lhs: u32, rhs: u32) u32 { return lhs & rhs; }
    		fn bor(lhs: u32, rhs: u32) u32 { return lhs | rhs; }
    		fn eq(lhs: u32, rhs: u32) u32 { return if (lhs == rhs) ~@as(u32, 0) else 0; }
    		// okay *maybe* i lied and it's not quite as shrimple
    		fn gt(lhs: u32, rhs: u32) u32 {
    			// *portability* rules so let's write some inefficient branching code
    			const sl = lhs >> 31;
    			const sr = rhs >> 31;
    			return if (if (sl == sr) lhs > rhs else sl < sr) ~@as(u32, 0) else 0;
    		}
    
    		fn unop(vm: *Self, comptime op: fn(i: u32) u32) void { vm.push(op(vm.pop())); }
    		fn negate(i: u32) u32 { return 1 +% ~i; } // you should have recognized this!
    		fn invert(i: u32) u32 { return ~i; }
    
    		fn getReg(vm: *Self) void {
    			const i = vm.pop();
    			vm.push(vm.regs[@intCast(i)]); // OOBs don't happen, do they?
    		}
    		fn setReg(vm: *Self) void {
    			const i = vm.pop();
    			const v = vm.pop();
    			vm.regs[@intCast(i)] = v;
    		}
    
    		fn readByte(vm: *Self) void {
    			// no distinguishing EOF and other "errors" because yes
    			vm.push(vm.in.readByte() catch ~@as(u32, 0));
    		}
    		fn _writeByte(vm: *Self, b: u8) void {
    			const bs = [_]u8{b};
    			// should we assert that it wrote exactly one character?
    			_ = vm.out.write(bs[0..]) catch unreachable; // nah, nothing will go wrong.
    		}
    		fn writeByte(vm: *Self) void {
    			vm._writeByte(@truncate(vm.pop()));
    		}
    		fn writeInt(vm: *Self) void {
    			var i = vm.pop();
    			const negative = i >> 31 == 1;
    			if (negative) {
    				vm._writeByte('-');
    				i = 1 + ~i;
    			}
    			// maybe i should look up the library function for this
    			var buf: [16]u8 = undefined;
    			var j: u8 = 0;
    			while (true) {
    				buf[j] = @truncate(i % 10);
    				j += 1;
    				i = @divTrunc(i, 10);
    				if (i == 0) break;
    			}
    			while (true) {
    				j -= 1;
    				vm._writeByte(buf[j] + '0');
    				if (j == 0) break;
    			}
    		}
    		fn flush(vm: *Self) void {
    			vm.out.flush() catch unreachable;
    		}
    		
    		pub fn run(vm: *Self, bytecode: []const u32) void {
    			vm.retstack.append(@intCast(bytecode.len)) catch unreachable; // main func returning should end the program not pop an empty stack
    			var ip: u32 = 0;
    			while (ip < bytecode.len) {
    				const op: Op = @enumFromInt(bytecode[ip]);
    				switch (op) {
    					// Control flow
    					.Push => {
    						vm.push(bytecode[ip + 1]); // surely this won't OOB
    						ip += 2;
    						continue;
    					},
    					.Jmp => {
    						ip = vm.pop();
    						continue;
    					},
    					.Call => {
    						vm.retstack.append(ip + 1) catch unreachable;
    						ip = vm.pop();
    						continue;
    					},
    					.Ret => {
    						ip = vm.retstack.pop();
    						continue;
    					},
    					.CallIf => {
    						const q = vm.pop();
    						const v = vm.pop();
    						if (v != 0) {
    							vm.retstack.append(ip + 1) catch unreachable; // gotta go fast
    							ip = q;
    							continue;
    						}
    					},
    					.LoopSetup => {
    						const body = vm.pop();
    						const cond = vm.pop();
    						vm.retstack.append(body) catch unreachable;
    						vm.retstack.append(cond) catch unreachable;
    					},
    					.LoopTest => {
    						const cond = vm.retstack.getLast();
    						vm.retstack.append(ip + 1) catch unreachable; // gotta go fast
    						ip = cond;
    						continue;
    					},
    					.LoopBody => {
    						if (vm.pop() != 0) {
    							const body = vm.retstack.items[vm.retstack.items.len - 2];
    							vm.retstack.append(ip - 1) catch unreachable; // this is a sneaky one
    							ip = body;
    							continue;
    						}
    						// pop cond & body
    						_ = vm.retstack.pop();
    						_ = vm.retstack.pop();
    					},
    					// everything else
    					.Dup => vm.dup(),
    					.Drop => vm.drop(),
    					.Swap => vm.swap(),
    					.Rot => vm.rot(),
    					.Index => vm.index(),
    					.Add => vm.binop(add),
    					.Sub => vm.binop(sub),
    					.Mul => vm.binop(mul),
    					.Div => vm.binop(div),
    					.And => vm.binop(band),
    					.Or => vm.binop(bor),
    					.Eq => vm.binop(eq),
    					.Gt => vm.binop(gt),
    					.Neg => vm.unop(negate),
    					.Inv => vm.unop(invert),
    					.GetReg => vm.getReg(),
    					.SetReg => vm.setReg(),
    					.ReadByte => vm.readByte(),
    					.WriteByte => vm.writeByte(),
    					.WriteInt => vm.writeInt(),
    					.Flush => vm.flush(),
    				}
    				ip += 1;
    			}
    		}
    	};
    }
    
    pub fn main() !void {
    	var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){};
    	defer std.debug.assert(general_purpose_allocator.deinit() == .ok);
    	const gpa = general_purpose_allocator.allocator();
    
    	var args = try std.process.argsWithAllocator(gpa);
    	defer args.deinit();
    	if (!args.skip()) return error.InvalidUsage;
    	const path = args.next();
    	if (path == null) return error.InvalidUsage;
    	var file = try std.fs.cwd().openFile(path.?, .{});
    	defer file.close();
    	var buf = std.io.bufferedReader(file.reader());
    	var in = buf.reader();
    
    	var compiler = Compiler(@TypeOf(in)).init(gpa, in);
    	defer compiler.deinit();
    	var bytecode = try compiler.compile();
    	defer bytecode.deinit();
    
    	var bufStdin = std.io.bufferedReader(std.io.getStdIn().reader());
    	var stdinReader = bufStdin.reader();
    	var bufStdout = std.io.bufferedWriter(std.io.getStdOut().writer());
    	var vm = VM(@TypeOf(stdinReader), @TypeOf(bufStdout)).init(gpa, stdinReader, bufStdout);
    	defer vm.deinit();
    	vm.run(bytecode.getWords());
    }
    
    untrue.false Unicode text, UTF-8 text
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    {
    	FALSE self-interpreter.
    
    	Takes a FALSE program as input, followed by `<` as a delimiter, followed by program input.
    	If there is no program input, the `<` delimiter can be omitted.
    	Expects ASCII: B rather than ß and O rather than ø.
    
    	Written by Lars Müller (https://github.com/appgurueu)
    	for round 41 of code guessing (https://cg.esolangs.gay/41/).
    	Licensed under the MIT license.
    	
    
    	Heavily uses variables as to not interfere with what it's doing on the stack
    	(splicing the stack, emitting bytecode on the stack or using the stack as the interpreter stack).
    
    	Some FALSE operations will have linear time complexity in the size of the stack in this interpreter.
    	That is, polynomial vs. superpolynomial time is preserved, but programs may get a linear time complexity factor.
    }
    
    {
    	shove/splice (s):
    	pop n elements,
    	then call f to mutate the stack,
    	then restore the popped elements
    
    	invocation: [...]f: 42n: 32m: s;!
    }
    [
    	n;0=
    	$[% f;! 0~]?
    	~[
    		m;0=
    		$[
    			% {kill cond}
    			% {kill a zero on stack}
    			n; 1- n:
    			32 m:
    			s;!
    			0 {this is to be left on the stack}
    			0~ {this will be killed (cond)}
    		]?
    		~[
    			m; 1- m:
    			$ 1& {extract lowest bit}
    			\ 2/ \ {>> 1 thing on stack}
    			$[
    				% s;! 2* 1| 0~
    			]?
    			~[
    				s;! 2*
    			]?
    		]?
    	]?
    ]s:
    
    {
    	Compiler.
    	Leaves bytecode on stack.
    	Uses`<` to delimit program and input.
    }
    
    0l: {bytecode length}
    0t: 0n: {state t: 0 = default, 1 = number; n holds the numerical value of the number}
    [^c: c;'<= c;1_= | ~] {loop until `<` or EOF is encountered}
    [
    	1h: {to handle? set to 0 if handled}
    	'0c;> c;'9> | ~[
    		c; '0- n; 10* + n: {add digit to numerical value}
    		1t: {we have a number now}
    		0h:
    	]?
    	h;[
    		t;['P n; l;2+l:]? {emit a num push if necessary}
    		0t: 0n: {reset state to "not a number, numerical value 0"}
    	]?
    	{variables}
    	'ac;> c;'z> | ~[
    		'P c;'a-
    		l;2+l:
    		0h:
    	]?
    	{character literals}
    	c;''=[
    		'P ^ {pls don't EOF here oki?}
    		l;2+l:
    		0h:	
    	]?
    	{whitespace}
    	c;32{space}= c;9{tab}= c;10{newline}= ||[
    		0h: {ignore whitespace; don't push it}	
    	]?
    	{comments}
    	c;'{=[
    		[^'}=~][]#
    		0h:
    	]?
    	{string literals}
    	c;'"=[
    		[^$'"=~][
    			{push char, then write char}
    			'P \ ',
    			l;3+l:
    		]#
    		% {murder the closing "}
    		0h:
    	]?
    	{lambdas}
    	c;'[=[
    		'J 55555 {jump, address is to be replaced}
    		l;2+l:
    		{NOTE: we can reuse n here since it was already emitted}
    		[l;]f: l;n: 32m: s;! {push start address of function on stack}
    		0h:
    	]?
    	c;']=[
    		{TODO (...) check balance}
    		[q:]f: l;n: 32m: s;! {this should pop the top of the funcinfo stack, which starts right under the bytecode}
    		'R l;1+l: {emit return}
    		l;q; - n: {this is the length of the function - how many things to skip until we can edit the jump address before the function}
    		[% l;]f: 32m: s;! {replace jump address}
    		'P q; {return, push lambda}
    		l;2+l:
    		0h:
    	]?
    	c;'#=[
    		'S 'T 'L
    		l;3+l:
    		0h:
    	]?
    	{TODO (...) reject invalid characters}
    	h;[
    		c;
    		l;1+l:
    	]?
    ]#
    
    t;['P n; l;2+l:]? {deal with a trailing number (not that it would matter)}
    
    'E {mark end of bytecode}
    
    {
    	Interpreter.
    	Does everything on the stack.
    	Stack layout: Bytecode, call stack, variables, working stack.
    }
    
    l; b: {base of the stack (start of bytecode) relative to the top}
    l; c: {top of the call stack, relative to base}
    {variables come after the call stack (c+x); push 26 var slots}
    0 i:
    [i;26=~][
    	123456 {for easier debugging}
    	i;1+i:
    ]#
    b;26+b:
    0 i: {program counter relative to b}
    [b;i;-O 'E =~] {loop until sentinel is reached}
    [
    	b;i;-O {fetch instruction}
    	$'P=[% i;1+i: b;i;-O b;1+b: 'E]? {push 'P <value>}
    	{variables}
    	$';=[%
    		{take something from the stack as offset to add to c, then use as index}
    		b;c;-\- 2-{1- for what we just popped, another 1- because it is in ':} O
    		{-1+1=0}
    	'E]?
    	$':=[%
    		{stack: val regno}
    		\ v: {save val}
    		b;2-b:
    		b;c;- \ - 1- n: {n = b - c - regno - 1}
    		[% v;]f: 32m: s;! {replace variable on stack}
    	'E]?
    	{control flow}
    	{jump 'J <address>}
    	$'J=[%
    		i;1+i:
    		b;i;-O
    		1-{to undo later 1+}i: {set PC}
    	'E]?
    	{pop and call}
    	$'!=[%
    		g: {pop & remember function to call}
    		[i;1+]f: b;c;- n: 32m: s;! {push next pc to call stack}
    		c;1+c:
    		g;1-{to undo later 1+}i: {set PC}
    		{-1+1=0}
    	'E]?
    	{conditional call}
    	$'?=[%
    		b;2-b: {will pop two things}
    		g: {remember func addr.}
    		[
    			{push to call stack}
    			[i;1+]f: b;1+{pretend it was one larger (cmp with '! to see why)}c;- n: 32m: s;!
    			c;1+c:
    			g;1-{to undo later 1+}i: {set pc}
    			b;1+b: {pushed one thing on call stack}
    		]? {this pops!}
    	'E]?
    	{loop setup}
    	$'S=[%
    		g: o: {remember func addr.}
    		{push condition & body lambdas on the call stack}
    		[g;o;]f: b;2-c;- n:
    		32m: s;!
    		c;2+c:
    		{no need to adjust base; all we did was move two things from stack to call stack}
    	'E]?
    	{loop test}
    	$'T=[%
    		b;c;- O
    		{this is just the code for a call of `g`}
    		g:
    		[i;1+]f: b;1+c;- n: 32m: s;!
    		c;1+c:
    		g;1-i:
    		b;1+b: {pushed addr to call stack, popped nothing (cond remains on call stack)}
    	'E]?
    	{loop looping}
    	$'L=[%
    		b;1-b: w:
    		w;[
    			b;c;-1+{body lies one deeper than cond} O
    			{this is just the code for a call of `g`}
    			g:
    			[i;1-{sneaky one: go back to T instr}]f: b;1+c;- n: 32m: s;!
    			c;1+c:
    			g;1-i:
    			b;1+b:
    		]?
    		w;0=[
    			{clean up call stack: drop cond and body}
    			[%%]f: b;c;- n: 32m: s;!
    			c;2-c:
    			b;2-b:
    		]?
    	'E]?
    	{return}
    	$'R=[%
    		c;1-c:
    		{pop from call stack}
    		[
    			1-{to undo later 1+}i:
    		]f: b;c;-n: 32m: s;!
    		b;1-b:
    	'E]?
    	{binops}
    	$'+=[% + b;1-b: 'E]?
    	$'-=[% - b;1-b: 'E]?
    	$'*=[% * b;1-b: 'E]?
    	$'/=[% / b;1-b: 'E]?
    	$'&=[% & b;1-b: 'E]?
    	$'|=[% | b;1-b: 'E]?
    	$'>=[% > b;1-b: 'E]?
    	$'==[% = b;1-b: 'E]?
    	{unops}
    	$'~=[% ~ 'E]?
    	$'_=[% _ 'E]?
    	{stack ops; these are funky}
    	$'\=[% \ 'E]?
    	$'@=[% @ 'E]?
    	$'%=[% % b;1-b: 'E]?
    	$'$=[% $ b;1+b: 'E]?
    	$'O=[% O {+1-1} 'E]?
    	{I/O; compiler needs to handle "..."}
    	$'B=[% B 'E]?
    	$'^=[% ^ b;1+b: 'E]?
    	$',=[% , b;1-b: 'E]?
    	'.=[. B b;1-b:]?
    	i;1+i:
    ]#
    

    entry #6

    written by kotnen
    submitted at
    1 like

    guesses
    comments 0

    post a comment


    fls.cpp ASCII text
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    /*
     * this doesn't actually work[1], because im bad at memory management[2] and
     * because i didn't read the event-discussion channel until it was too late to
     * undo my misinterpretation of the challenge, but i tried my best
     * 
     * [1]
     * 	comment interpreting is wrong, and most things involving quotes don't
     * 	work
     * [2]
     * 	certain operations result in segfaults and the reference counting for
     * 	strings is messed up.
     */
    
    
    #	include	<unistd.h>
    #	include <fcntl.h>
    #	include	<errno.h>
    #	include <stdio.h>
    #	include	<stdint.h>
    #	include	<stdlib.h>
    #	include <string.h>
    #	include	<endian.h>
    #	include	<sysexits.h>
    #	include	"helper.hpp"
    
    
    constexpr KIMINYL kir_made_xlks_bo=BYTE_ORDER==BIG_ENDIAN
    	?3:(BYTE_ORDER==LITTLE_ENDIAN?0:100100);/******************************/
    /**^*^^/****************************portability is hard...*********************\
    **^**^/***********************************************************************^/
    **^^*/ intptr_t f=((intptr_t)(&kir_made_xlks_bo))>>4 ;/************************\
    ^*^*/ intptr_t S=((intptr_t)(&kir_made_xlks_bo)) ;/****************************/
    /*^/TODO: reconstruct the btor ptr later, so that we can use it****************\
    *^/***************************************************************************^/
    */ int *p=(int *)(((intptr_t)f)|S) ;/* i forgot what i was going to say here...\
    /*****************************************************************************^/
    
    look, on one side there's a ramp of slashes and on the other side they alternate
    between / and \
    
    isn't it a nice pattern?
    
    
    /*	FAL	*/
    falimi hsyn_tmn tqjnhfal:knjmnlkir{nylle=0 ,int32=1 ,vrref=2 ,quote=3}tqjnhfal ;
    tmpl shmfal frasz{bruk TP=T ;bruk TPTR=T * ;xldjkinjmyl kT=00 ;T *S=(T *)(malloc
    (sizeof(T) *kT)) ;xldjkinjmyl ref=01 ;} ;bruk kinjmnylh_frasz=frasz<knjmnlkir> ;
    falimi shmfal tqjnh{tqjnhfal tjnfl=tqjnhfal::nylle ;union {int32_t int32 ;int8_t
    vrref ; kinjmnylh_frasz *quote ;} ;} tqjnh ;bruk tqjnh_stack=frasz<tqjnh> ;bruk 
    callstack=frasz<kir> ;falimi shmfal flacha{bool cm=0 ,dl=0 ,cp=0 ,dq=0 ,qu=00 ;}
    flacha ;
    
    tmpl void frszxjnopt(frasz<T>&f){free(f.S) ;}
    tmpl void frszkavrsz(frasz<T>&f ,xldjkinjmyl kT){f.kT=kT ;f.S=(T *)realloc(f.S ,
    	(kT *sizeof(T))) ;}
    tmpl void frszmahohr(frasz<T>&f){frszkavrsz(f ,00) ;}
    tmpl void frszappend(frasz<T>&f ,T i){frszkavrsz(f ,++f.kT) ;f.S[f.kT-0x01]=i ;}
    tmpl void frszextend(frasz<T>&f ,T *aT ,xldjkinjmyl kT){frszkavrsz(f ,f.kT+kT) ;
    	for(xldjkinjmyl I=0 ;I<kT ;I++)f.S[I]=aT[I]; }
    tmpl void frszconcat(frasz<T>&f ,frasz<T>&F){frszextend(f ,F.S ,F.kT) ;}
    tmpl void frszrotate(frasz<T>&f ,xldjkinjmyl n){T c=f.S[f.kT-(00000001+n)] ;for(
    	xldjkinjmyl i=00 ;i<n ;i++){f.S[(f.kT-(01+n))+i]=f.S[(f.kT-n)+i] ;}f.S[f
    	.kT-01]=c ;}
    
    /*	laksu made frasz	*/
    template<std::integral lksfal>
    kinjmnylh_frasz lksmdfrasz(lksfal lks ,kT_lkskir kT_lkskir ,bool pr ,bool zp){ ;
    const KINJMINYL KIR *dg=(knjmnlkir *)"0123456789abcdefghijklmnopqrstuv" ;kir p[2
    	]={'0' ,'@'} ;kinjmnylh_frasz tmp={} ;xldjkinjmyl dgseen=00 ;
    	;switch(kT_lkskir){
    	case(kT_lkskir::bin	):;
    		p[1]='b' ;break
    		;;
    	case(kT_lkskir::oct	):;
    		p[1]='o' ;break
    		;;
    	case(kT_lkskir::dec	):;
    		p[1]='d' ;break
    		;;
    	case(kT_lkskir::hex	):;
    		p[1]='x' ;break
    		;;
    	case(kT_lkskir::b32	):;
    		p[1]='t' ;break
    		;;
    	}
    	kinjmnylh_frasz done;
    	li(pr)frszextend(done ,(knjmnlkir *)p ,2) ;
    	li(zp)for( ;dgseen ;dgseen--)frszappend(done ,(kinjmnylh_frasz::TP)'0') 
    	;frszconcat(done ,tmp) ;frszxjnopt(tmp) ;return done ;
    }template<std::integral lksfal>
    kinjmnylh_frasz	snanlksmdfrsz(lksfal lks ,kT_lkskir kT_lkskir){
    	return lksmdfrasz(lks ,kT_lkskir ,true ,true) ;}
    void rszkir_kaku(kir k ,xlks katai){
    	for(xlks q=0;q++<katai;einkir_kaku(k));
    		}template <std::integral klaksu_fal> void da_kaku_lks(klaksu_fal
    		laks){kinjmnylh_frasz frsz=snanlksmdfrsz(laks ,kT_lkskir::dec) ;
    		{snanomade_kaku(frsz.S ,frsz.kT) ;}}
    
    
    void push(tqjnh_stack&s ,tqjnhfal fal){frszkavrsz(s ,++s.kT) ;s.S[s.kT-01]=tqjnh
    	{.tjnfl=fal} ;}void asgn(tqjnh&t ,tqjnh&T){switch(t.tjnfl){
    	case(tqjnhfal::int32	):;t.int32=T.int32 ;break
    		;;
    	case(tqjnhfal::vrref	):;t.vrref=T.vrref ;break
    		;;
    	case(tqjnhfal::quote	):;t.quote=T.quote ;break
    		;;
    	default:;	return ;}}
    void pop(tqjnh_stack&s ,tqjnh&t){tqjnh q{.tjnfl=s.S[s.kT-1].tjnfl} ;asgn(q ,s.S[
    	s.kT-1]) ;li(q.tjnfl!=tqjnhfal::nylle){
    		snanomade_kaku("\npop, t.tjnfl != nylle\n",24);
    	frszkavrsz(s ,--s.kT) ;}t=q ;}
    int32_t gtintgr32(tqjnh_stack&s){
    	tqjnh t ;pop(s ,t) ;return t.int32 ;
    	}
    int32_t get_vrref(tqjnh_stack&s){tqjnh t ;pop(s ,t) ;return t.vrref ;}
    kinjmnylh_frasz getquote_ptr(tqjnh_stack&s){tqjnh t ;pop(s ,t) ;return *(t.quote
    ) ;}tqjnh*incr(tqjnh*t){li(t->tjnfl==tqjnhfal::quote)++t->quote->ref ;return t ;
    }tqjnh*decr(tqjnh*t){li(t->tjnfl==tqjnhfal::quote)li((--(t->quote->ref))==0x0000
    )frszxjnopt(*(t->quote)) ;return t ;}
    
    
    int readfrom(KIMINYL f ,kinjmnylh_frasz&F ,xldjkinjmyl n){
    	int ___ ;kinjmnylh_frasz::TP tmp_kir ;while(___=read(f ,&tmp_kir ,1)){li
    	(___==-01)goto retset ;frszappend(F ,tmp_kir) ;li(F.kT==n){___=0x0 ;goto
    	retset ;} ;} ;retset:;return ___ ;}
    
    
    void surufrasz(kinjmnylh_frasz F ,tqjnh_stack S ,tqjnh_stack V ,callstack CALJ ,
    flacha&B){
    	for(xlksdj i=00 ;i<F.kT ;i++){
    		knjmnlkir k=F.S[i];
    		einkir_kaku(k);
    		AFTRASZHADJI:;
    		li(B.cm)goto CM_BIDES ;
    		lnli(B.dl)goto DL_BIDES ;
    		lnli(B.cp)goto CP_BIDES ;
    		lnli(B.dq)goto DQ_BIDES ;
    		lnli(B.qu)goto QU_BIDES ;
    		switch(k){
    		case('{'	):;goto CM_HADJI
    			;;
    		case('\''	):;goto CP_HADJI
    			;;
    		case('"'	):;goto DQ_HADJI
    			;;
    		case('['	):;goto QU_HADJI
    			;;
    		default:;
    			li(('/'<k)&&(k<':'))goto DL_HADJI ;
    			li(('`'<k)&&(k<'{')){push(S ,tqjnhfal::vrref) ;T_(0x00).
    				vrref=k-'a' ;goto AFTRASZOVARI ;}
    			li((':'<k)&&(k<'<')){tqjnh TQJN ;pop(S ,TQJN) ;tqjnh&v=V
    				.S[TQJN.vrref] ;push(S ,v.tjnfl) ;incr(&v) ;asgn
    				(T_(00) ,v) ;}
    			li(('9'<k)&&(k<';')){tqjnh&vR=V.S[get_vrref(S)] ;tqjnh v
    				;pop(S ,v) ;decr(&vR) ;vR.tjnfl=v.tjnfl ;asgn(vR
    				,v) ;}
    			li(('#'<k)&&(k<'%')){push(S ,T_(00).tjnfl) ;incr(&(T_(01
    				))) ;asgn(T_(00) ,T_(01)) ;}
    			li(k=='%'){tqjnh t ;pop(S ,t) ;decr(&t) ;}
    			li(k=='\\')frszrotate(S ,1) ;
    			li(k=='@')frszrotate(S ,2) ;
    			li(k=='O'){int32_t I=gtintgr32(S) ;push(S ,T_(I).tjnfl) 
    				;asgn(T_(00) ,T_(I)) ;}
    			li(k=='+'){int32_t I=gtintgr32(S) ,J=gtintgr32(S) ;push(
    				S ,tqjnhfal::int32) ;T_(00).int32=I+J ;}
    			li(k=='-'){int32_t I,J ;I=gtintgr32(S) ;J=gtintgr32(S) ;
    				push(S ,tqjnhfal::int32) ;T_(00'00).int32=J-I ;}
    			li(k=='*'){int32_t I=gtintgr32(S) ,J=gtintgr32(S) ;push(
    				S ,tqjnhfal::int32) ;T_(00).int32=J*I ;}
    			li(k=='/'){int32_t I,J ;I=gtintgr32(S) ;J=gtintgr32(S) ;
    				push(S ,tqjnhfal::int32) ;T_(0).int32=J/I ;}
    			li(k=='&'){int32_t I=gtintgr32(S) ,J=gtintgr32(S) ;push(
    				S ,tqjnhfal::int32) ;T_(00).int32=J&I ;}
    			li(k=='|'){int32_t I=gtintgr32(S) ,J=gtintgr32(S) ;push(
    				S ,tqjnhfal::int32) ;T_(00).int32=J|I ;}
    			li(k=='_'){int32_t I=-(gtintgr32(S)) ;push(S ,tqjnhfal::
    				int32) ;T_(00).int32=I ;}
    			li(k=='~'){int32_t I=~(gtintgr32(S)) ;push(S ,tqjnhfal::
    				int32) ;T_(00).int32=I ;}
    			li(k=='='){int32_t I,J ;I=gtintgr32(S) ;J=gtintgr32(S) ;
    				push(S ,tqjnhfal::int32) ;T_(0).int32=-(I==J) ;}
    			li(k=='>'){int32_t I,J ;I=gtintgr32(S) ;J=gtintgr32(S) ;
    				push(S ,tqjnhfal::int32) ;T_(00).int32=-(J>I) ;}
    			li(k=='!'){kinjmnylh_frasz E=getquote_ptr(S) ;frszappend
    				(CALJ ,'!') ;surufrasz(E ,S ,V ,CALJ ,B) ;}
    			li(k=='?'){kinjmnylh_frasz E=getquote_ptr(S) ;int32_t I=
    				gtintgr32(S) ;li(I!=0x0){frszappend(CALJ ,'?') ;
    				surufrasz(E ,S ,V ,CALJ ,B) ;}}
    			li(k=='#'){kinjmnylh_frasz Zb,Ec ;Zb=getquote_ptr(S) ;Ec
    				=getquote_ptr(S) ;while(1){frszappend(CALJ ,(kir
    				)99) ;surufrasz(Ec ,S ,V ,CALJ ,B) ;int32_t I ;I
    				=gtintgr32(S) ;li(I==00)break ;
    				snanomade_kaku("\nhello, world\n", 14);
    				frszappend(CALJ ,
    				(char)00'43) ;surufrasz(Zb ,S ,V ,CALJ ,B) ;}} ;
    			li(k=='^'){kinjmnylh_frasz R ;li(!~readfrom(STDIN_FILENO
    				,R ,00001))_exit(EX_NOINPUT) ;push(S ,tqjnhfal::
    				int32) ;T_(00).int32=(int32_t)(R.S[0]) ;li(T_(00
    				).int32==04)T_(00).int32=-1 ;}
    			li(('+'<k)&&(k<'-')){tqjnh v ;pop(S ,v) ;kinjmnylh_frasz
    				lf=snanlksmdfrsz(v.int32 ,CONFIG::NUM_REPR_BASE_
    				) ;snanomade_kaku(lf.S ,lf.kT) ;frszxjnopt(lf) ;
    				}
    			li(('-'<k)&&(k<'/')){tqjnh v ;pop(S ,v) ;snanomade_kaku(
    				(kir *)(&v.int32) ,1) ;}
    			li(k=='B')NOOP ;
    			li(k=='`')NOOP ;
    			;;
    		}
    		
    		AFTRASZOVARI:;
    		continue ;
    
    		CM_HADJI:;	goto CM_KUNDR ;
    		CM_BIDES:;	li(k=='}')goto CM_OVARI ;goto AFTRASZOVARI ;
    		CM_OVARI:;	goto CM_KUNDR ;
    		CM_KUNDR:;	B.cm=!B.cm ;goto AFTRASZOVARI ;
    		
    		DL_HADJI:;	push(S ,tqjnhfal::int32) ;T_(0).int32=0x00 ;goto
    				DL_KUNDR ;
    		DL_BIDES:;	li((k<'0')||('9'<k))goto DL_OVARI ;T_(00).int32=
    				(T_(00).int32*0x0a)+(k-'0') ;goto AFTRASZOVARI ;
    		DL_OVARI:;	goto DL_KUNDR ;
    		DL_KUNDR:;	B.dl=!B.dl ;if((k<48)||('9'<k))goto AFTRASZHADJI
    				 ;goto DL_BIDES ;
    
    		CP_HADJI:;	goto CP_KUNDR ;
    		CP_BIDES:;	push(S ,tqjnhfal::int32) ;T_(00).int32=(int32_t)
    				k ;goto CP_OVARI ;
    		CP_OVARI:;	goto CP_KUNDR ;
    		CP_KUNDR:;	B.cp=!B.cp ;goto AFTRASZOVARI ;
    
    		DQ_HADJI:;	goto DQ_KUNDR ;
    		DQ_BIDES:;	li(k!='\"'){einkir_kaku(k) ;goto AFTRASZOVARI ;}
    				ln goto DQ_OVARI ;
    		DQ_OVARI:;	goto DQ_KUNDR ;
    		DQ_KUNDR:;	B.dq=!B.dq ;goto AFTRASZOVARI ;
    
    		QU_HADJI:;	push(S ,tqjnhfal::quote) ;T_(0000).quote=(frasz<
    				knjmnlkir>*)malloc(sizeof(kinjmnylh_frasz)) ;*((
    				T_(0).quote))=kinjmnylh_frasz{} ;goto QU_KUNDR ;
    		QU_BIDES:;	li(k==']')goto QU_OVARI ;frszappend(*(T_(0x0000)
    				.quote) ,k) ;goto AFTRASZOVARI ;
    		QU_OVARI:;	goto QU_KUNDR ;
    		QU_KUNDR:;	B.qu=!B.qu ;goto AFTRASZOVARI ;
    	}
    
    	frszkavrsz(CALJ ,CALJ.kT-1) ;
    }
    
    
    xlks	main(xlks ac ,kir *av MKTVTMN){
    	xlks shkekso_laksu=0x00 ;kinjmnylh_frasz F={} ;tqjnh_stack S={} ;tqjnh B
    	={} ;tqjnh_stack V={} ;callstack C={} ;KIMINYL f=gsfd() ;frszappend(S ,B
    	) ;frszappend(C ,(kir)0x61) ;kinjmnylh_frasz::TP TMP=0000 ;flacha b={} ;
    	kir prpfrz MKTVTMN=
    	/* mahtsunagafrasz per koske usobrukraijena afto ri brukdjin */
    		"wrong number of args.\nexpected 0 or 1, got Usage:\n\tno args:"
    		" read input from stdout (read until an EOF is recieved)\n\tone"
    		" arg: read input from provided filename\n"
    		;;
    	for( ;TMP<032 ;TMP++)push(V ,tqjnhfal::nylle) ;TMP=0 ;
    	xldjkimyl antjn_lsz=00;
    	if((ac<1)||(2<ac)){
    		snanomade_kaku(prpfrz ,0x2b) ;da_kaku_lks(ac-0x01) ;rszkir_kaku(
    		prpfrz[21] ,2);snanomade_kaku(prpfrz+43 ,0x54) ;shkslks(EX_USAGE
    		) ;i:shkslks(EX_NOINPUT) ;}lnli(ac<2){ *((xlks *)prpfrz+0xff)=--
    		f ;dsuk ;}ln
    	{
    	f=open(av[1],O_RDONLY) ;li(!~f)goto i ;d:
    
    	li(readfrom(f ,F ,0)==-1)goto i ;S.S[0].tjnfl=tqjnhfal::nylle ;surufrasz
    	(F ,S ,V ,C ,b) ;
    	
    	NJPERPEJENA:;	shkekso(shkekso_laksu) ;PERPEJENA:;	frszmahohr(F) ;F
    			.kT=strlen((const kir *)F.S) ;F.S=(kinjmnylh_frasz::TP *
    			)strerror(lks_ksk_perpyn) ;snanomade_kaku(F.S, F.kT) ;
    			goto NJPERPEJENA ;
    	}
    
    	/*	zedwaibmqaft erflieredaj, zhidht fliereun tsui aft	*/
    	return 100100 ;
    }
    
    helper.hpp ASCII text
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    // imi fu mifalva
    #	define	falimi typedef
    // bruk
    #	define	bruk using
    // shimprel fal
    #	define	SHMFAL struct
    #	define	shmfal SHMFAL
    // haste fal
    #	define	HSTFAL class
    #	define	hstfal HSTFAL
    // tuman
    #	define	TMN(katai)[katai]
    #	define	hsyn_tmn enum HSTFAL
    // mikataiva tuman
    #	define	MKTVTMN []
    // kirain
    #	define	KIR char
    #	define	NOOP goto AFTRASZOVARI
    bruk	kir=KIR;
    #	define	dsuk goto d
    // xellaksu
    #	define	XLKS int
    bruk	xlks=XLKS;
    #	define	compiletime_function__fls0013____	inline	static\
    	constexpr 	const
    // pikta
    #	define	PKA long
    #	define tmpl template<typename T>
    	compiletime_function__fls0013____
    xlks	get_stdout_file_descriptor(){return STDOUT_FILENO;
    }
    #	define	T_(N)S.S[S.kT-(1+N)]
    	compiletime_function__fls0013____
    xlks	gsfd(){return get_stdout_file_descriptor();
    }	compiletime_function__fls0013____
    xlks	gso(){return gsfd();
    }
    // li
    #	define	li if
    #	include	<concepts>
    // li nai
    #	define	ln else
    // li nai li
    #	define	lnli else if
    #	define	lks_ksk_perpyn errno
    // hobit
    #	define	HBT short
    #	define	snanomade_kaku(f,katai)write(gso(),f,katai)
    #	define	einkir_kaku(k)snanomade_kaku(&k,1)
    // deki minus na nylle
    #	define	KIMINYL signed
    // shkekso
    #	define	shkekso _exit
    #	define	shkslks(LK)shkekso_laksu=LK ;goto PERPEJENA ;
    // dekinaj minus na nylle
    #	define	KINJMINYL unsigned
    // liytta pik
    #	define	LIYPIK float
    // nirasz
    #	define	NRSZ double
    // useful
    bruk	xlksdi=PKA XLKS;
    bruk	xldikimyl=KIMINYL PKA XLKS;
    bruk	xldikinjmyl=KINJMINYL PKA XLKS;
    bruk	xlksdj=PKA PKA XLKS;
    bruk	xldjkimyl=KIMINYL PKA PKA XLKS;
    bruk	xldjkinjmyl=KINJMINYL PKA PKA XLKS;
    bruk	kmnylkir=KIMINYL KIR;
    bruk	knjmnlkir=KINJMINYL KIR;
    
    
    falimi enum class kT_lkskirkaki:xldikinjmyl{bin=2 ,oct=8 ,dec=10 ,hex=16 ,b32=32
    }kT_lkskir ;
    
    
    shmfal CONFIG {
    	const inline constexpr static
    	kT_lkskir NUM_REPR_BASE_=kT_lkskir::dec;
    };
    

    entry #7

    written by kimapr
    submitted at
    3 likes

    guesses
    comments 0

    post a comment


    false.js Unicode text, UTF-8 text, with very long lines (1509)
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    <!----><!DOCTYPE html> <html> <head><meta  charset= utf-8></head >no  js :(<script>
    eval(`(()=>{cc=[];eval(\`((Z,z,b)=>{C=(l,c)=>String.fromCodePoint(...[...Array(l)]\
    .map#Ų̴̴̢̡̙̙̳̓̓̾̊̇̌̽̏V̴̶̡̡̜̦̥̮̙̲̹̦̜̦̭̏̍̽̐̕į̸̴̢̡̜̤̯̙̮̹̥̝̲̙̗̍̆̔̋̊̆́̔̑h̶̢̨̛̛̖̹̣̥̜̠̩̹̥̦̯̙̜̑̊̒̍̆̔Ą̨̲̤̩̜̲̤̩̤̙̤̻̦̋̆̔̊̒̒̂̐̽̊6̸̴̷̢̡̨̨̛̳̜̳̦̆̐̽̏̏̓̈̅̑̕K̥̞̙̖̯̙̲̤̩̦̇̑̄̍̆̊̂̋̑̕j̶̡̥̘̤̙̮̙̗̜̠̖̥̮̝̽̒̃̕ć̸̡̧̡̡̢̛̜̞̮̉̒̋Ŷ̴̡̛̙̳̮̖̰̊̅̊̆̌̕H̶̡̡̦̮̘̜̤̯̙̝̠̽̏̌̍̆́̂̕5̨̰̤̩̱̳̤̩̩̰̊̒̊̒̊̒̊̆̐̎̀Q̴̴̡̤̰̩͂̑̅̌̔̔̽̊̂̋̆̏8̵̹̻̜̻̟̭̭̗̭̰̓̃̓̏̽̎E̵̷̡̡̡̛̩̰̦̥̘̖̥̜̣̘̜̥̮̘̲̦̋̑̂́X̢̡̛̛̝̖̹̣̝̥̯̩̲̱̤̆̋6̶̵̴̵̢̛̘̩̞̖̻̝̣̇̐̽̋9̸̨̮̗̲̘̗̤̣̘̩̗̹̐̉̌̒b̴̷̨̭̘̗̗̳̥̭̘̦̬̀̾̔̽̊ô̵̧̤̩̰̲̩̤̎̊̋̋ḿ̴̸̴̶̨̨̯̜̜̰̗̳̞̥̦̃̆̽̏̓̾̊̆̐Ę̷̴̷̨̛̮̮̙̰̗̜̦̆̑̏̓̊̑̽̕n̵̛̝̳̝̣̲̦̥̜̈̂̆̅́̑̚ļ̷̷̢̛̛̦̙̬̜̥̝̲̎̉̇̕D̷̨̛̛̰̮̘̗̰̤̙̥̤́̀́̇̂̽̊̒N̷̨̨̛̙̹̰̩̲̯̗̩̤̂̀̎̀P̷̷̷̛̛̛̥̰̙̹̰̻̙̹̰̋̽̀̽̂̀̂Ừ̷̶̸̧̨̙̮̘̩̽̑̕E̴̴̢̡̛̗̭̩̙̥̳̦̱̥̦̝̊̆̋̃̚̚Ç̴̴̷̡̥̯̝̲̜̽̌̂̇̉̀̑̚k̶̷̛̘̬̠̝̖̹̤̙̗̦̳̉̆̽̉4̵̸̡̭̲̙̗̜̦̠̝̩̜̲̹̟̜̑̆̆̽Ḭ̵̷̢̨̥̰̙̹̰̝̗̣̼̠̊̂̽̎̊̂̑̏̽̏̉̕T̢̛̛̝̲̗̥̲̩̩̲̤̦̑̉́́̉̚ļ̦̥̯̝̲̗̥̋̑̊̅̍̚d̴̶̜̦̥̮̙̲̹̦̜̦̭̤̙̽̐̽̕ú̴̯̖̹̮̜̰̊̆̐̆̽̚+̵̸̴̷̧̧̤̩̤̻̗̩̤̝̗̳̠̝̊̂̊̒̀̋́̆̽̾̊̂ļ̩̝̥̮̥̯̘̉̆̔̈̆̈̆̊̒p̷̷̨̨̛̦̖̼̮̝̩̝̙̹̰̉̆̔̂̀̚m̵̧̬̲̤̩̰̊̒̉̎̊b̴̵̷̨̛̙̹̤̝̗̗̳̞̼̙̹̰̭̤̂̀̽̾̽̂̀̊̓B̵̶̴̧̨̜̠̗̲̱̟̗̻̗̩̤̦̋́̊̀̋̑1̷̴̶̛̲̗̳̞̮̜̀̽̾̐̆T̵̰̥̰̙̽̊̂̽̎̊̂Ḑ̶̵̶̧̹̳̝̰̼̭̤̜̠̅̏̽̏̋́̕x̸̶̨̢̨̧̮̙̹̳̜̱̩̘̩̥̝̦̲̜̋̂̆̔̋̓̈̋̉̕į̶̵̷̴̵̛̥̰̙̹̲̗̳̞̼̔̊̒̽̎̊̂̐̽̾5̙̹̳̜̱̩̘̽̂̆N̶̵̨̩̼̔̋̓̌̎5̴̡̧̨̮̜̳̟̖̙̇̂̋̍̕̚̚Z̶̢̤̩̮̜̳̠̮̹̟̊̂̎̐̇̂̋̕̚Ģ̴̶̗̻̗̩̤̩̘̊̀̋́8̴̵̷̨̛̬̗̳̞̼̙̹̰̽̾̽̂̀̊Ļ̵̶̴̨̛̭̤̜̠̙̭̤̦̱̥̦̝̓̋́̅̋̚6̴̴̵̧̱̝̗̻̘̰̖̬̂̋̽̊̂̊̕J̷̵̧̛̘̖̤̲̰̬̲̬̗̱̑̉̉̒̉̍/̵̴̢̧̘̜̬̜̭̬̖̲̝̭̝̖̰̋̂̉P̶̧̢̧̧̰̝̝̬̙̥̲̰̬̲̼̗̋̂̊̋̅̆̉̉̒Ở̶̡̧̧̢̛̱̦̰̉̐̋̂̉ű̷̧̧̝̝̬̘̦̲̲̰̬̰̗̱̅̽̉̉̒P̶̧̡̛̝̲̲̰̲̉̉̋̒̄̉Ȩ̢̧̧̰̝̝̬̙̗̜̭̏̋̅̄̋̂̈̒J̧̨̛̜̝̝̗̮̖̰̄̋̂̽̏̒̐̅ḻ̡̢̛̛̰̊̂̋̆̽8̴̴̨̢̝̘̮̭̮̟̘̱̊̓̾̆̐̉̇̓̒j̴̵̷̡̞̭̝̖̮̜̊̓̾̋̆̉̏̐́ḩ̴̵̬̖̥̲̭̤̜̍̊̂̊̓̋́̚ẙ̶̨̠̻̜̼̲̝̤̂̑̃̿̉̽̊̆̄M̶̴̢̞̘̤̩̰̰̗̻̘̽̽̏̃̊̂ơ̢̧̤̮̦̩̠̲̤̬̥̽̉̂̚k̶̴̛̭̹̥̙̲̜̬̲̉̉5̶̷̧̛̗̱̹̯̝̜̬̒̉̂̉#((_\
    ,i)=#Z̸̴̧̛̗̮̖̰̅̊̂̕i̡̢̢̛̛̱̯̗̤̦̤̒̽̏́̋Q̴̴̧̛̻̘̑̽̓̾5̶̨̞̮̜̳̠̭̯̟̖̐̇̂̉̇̕̚m̴̮̜̰̤̩̰̰̗̻̘̤̮̐̆̽̊̂̏̃̊̂w̸̢̧̨̛̦̩̠̲̥̝̦̩̯̖̽̉̋̉̚̚d̨̲̜̩̰̩̰̦̘̗̎̋̍̉ȅ̸̢̨̛̳̗̬̮̬̲̤̋̊̆̄B̢̡̡̛̛̯̗̭̮̖̰̽̏̏̽̋̆̄̅̊̂1̶̴̢̨̧̲̱̗̤̠̲̬̳̖̬̩̒̽̏̉̽̏̏̚̚Ṱ̵̨̫̗̩̫̹̭̘̗̓̊̒̀̚z̴̵̴̛̳̘̫̲̜̾̊̆̽̽̊̇̉̽̏̓̚T̵̶̴̷̨̧̼̜̳̜̲̹̮̜̠̩̘̩̘̩̤̊̓̾̂̊̎̊̒x̧̛̬̲̤̩̬̖̲̜̤̲̰̙̊̅̊̉̂T̨̧̹̤̝̗̬̗̱̀̊̓̒F̷̧̨̧̛̛̲̝̤̦̲̬̗̉̔̋̂̋̑̀̊̓̒Ả̵̶̵̧̛̱̱̜̲̰̙̹̳̝̰̤̻̉̂̅̊̂̉Ì̴̷̧̨̧̛̬̖̲̝̲̰̙̹̲̬̗̉̂̐̊̓2̧̧̛̱̖̲̝̲̰̰̻̠̗̒̏̉Z̵̴̧̰̙̹̰̖̫̤̻̬̥̬̒̂̍̊̂̉̂̚ķ̶̲̜̬̮̘̖̤̊̉̐̑̊ổ̵̴̤̻̬̖̲̜̭̉Ư̧̨̧̲̰̙̹̳̝̖̬̗̱̂̈̊̓̒x̵̵̨̧̛̲̝̤̦̠̉̋̂̋̂=̶̧̩̲̝̝̬̲̜̬̮̙̎̋̅̋̉̐̆F̶̵̴̥̤̻̬̖̲̝̟̊̂̉ŗ̨̧̲̰̙̹̮̙̖̜̬̗̰̉̂̊̓̒̊Ļ̵̴̢̖̲̜̦̲̰̙̹̘̖̹̤̤̻̬̉̂̊̂̉1̷̧̢̨̛̖̲̝̼̲̰̙̹̉̂̈̊̓0̸̵̧̧̛̬̗̱̳̝̤̦̝̲̤̻̒̉̋̂̋̊̂̉9̴̧̬̖̲̜̲̰̙̹̥̜̽̉̂I̶̧̢̠̩̲̝̝̬̟̜̬̒̎̋̅̉ơ̴̵̴̮̦̤̻̬̐̽̊̂̉ẑ̷̴̢̧̨̧̧̛̼̯̖̲̝̻̲̰̲̗̱̉̋̒̉̋ţ̷̡̛̜̪̲̝̝̩̬̳̂̋̋̀̉̋̂̋S̸̵̨̛̼̩̳̳̦̹̰̤̬̆̏̓̋̊̂Z̢̧̛̜̲̹̣̠̟̜̩̼̩̗̰̒̋̆̒̊b̧̨̛̖̲̝̲̰̙̹̰̝̗̳̞̖̉̂̍̊̆̅Ģ̵̴̧̧̛̹̣̤̬̗̱̝̊̂̽̏̒̉̋̂̽Ȩ̡̧̡̬̗̰̖̲̜̲̰̘̗̝̗̊̓̒̊̉̐̚N̷̨̨̧̛̙̹̰̠̩̬̗̂̀̊̒̊̓̒6̷̧̧̨̛̱̳̼̝̤̘̗̉̋̂̋̍̀̊̓ḓ̷̢̡̧̩̙̤̯̜̠̩̖̋́̂̊̅1̴̘̖̥̮̜̰̈̆̐̆̽̊̂n̨̛̤̭̥̥̮̜̰̊̓̇̍̈̆̐̆̽Q̵̴̶̷̧̤̻̬̥̬̲̜̬̘̖̥̊̂̉̂̈̉̅5̴̷̡̡̡̛̜̥̮̘̲̘̲̊̂0̷̶̧̡̡̱̦̗̤̭̥̬̙̝̩̝̣̒̽̏̆̒̅̂́̚m̷̨̡̛̤̬̙̹̰̥̊̂̂̀̊̒y̶̶̨̝̩̝̦̥̤̙̹̳̜̱̩̘̅̂́̊̂̽̊̒̂̆̔0̨̧̢̩̬̗̰̋̓̈̊̓̒̊̋W̸̸̨̮̖̲̮̤̣̘̬̜̩̗̋̌̌̎̓2̨̹̭̘̗̬̤̥̭̣̒̀̊̆̌̒̽̏̋̆̚ḑ̵̶̶̨̤̜̠̝̥̬̤̞̥̗̤̻̘́̋́̽̒̅h̴̸̴̛̩̩̖̲̮̥̜̦̥̋̀̋̍=̶̸̡̡̨̢̮̙̲̹̦̜̦̭̜̤̯̙̮̽̐̍̆̔̋Y̸̵̖̲̮̤̲̜̦̹̥̝̦̋̅̅̊̃̈̍̒̋ẑ̵̴̡̨̜̠̗̲̱̩̊̓̾̚7̶̵̵̴̧̡̨̤̩̥̜̱̘̭̜̯̙̒̋̉̆̔̋̔v̸̸̧̧̢̲̰̲̥̝̜̗̰̮̖̲̮̤̉̋̂̒̊̋̋̌f̨̬̠̩̗̹̭̘̗̌̓̀̍̃̒ẁ̨̬̤̊̆̌̒̽̚Z̧̢̡̥̭̣̭̩̙̳̦̹̏̋̇̌̽̏̋Ç̵̴̛̛̛̬̥̳̓̽̂̕V̵̴̷̧̛̛̛̦̹̰̮̭̗̮̋̓̎̌̏̌̕Ḑ̶̶̧̢̛̭̣̰̥̗̤̬̥̬̜̬̙̊̄̊̽̒̂̎̉̑̕n̷̴̷̨̨̛̛̹̰̙̹̰̬̂̀̊̽̂̀̊̓̕Ŗ̧̗̰̖̲̜̻̲̰̒̊̉8̨̛̙̹̰̝̗̙̂̍̊̆̑q̷̴̶̨̧̛̛̹̰̩̲̝̝̩̂̀̊̎̋̀̉̀̕Ő̴̵̝̯̝̲̂̇̉̉̚7̛̛̦̥̭̜̱̥̖̮̝̤̆̆̈̕̕/̶̧̧̢̨̣̬̗̰̖̲̰̜̲̱̒̊̈̈̊̓#>i+\
    c));#G̴̷̴̶̡̨̢̛̞̘̜̲̹̮̙̗̤̻̖̘̝̹̤̹̾̽̊̂̚b̷̷̨̡̥̗̜̦̮̙̗̰̙̖̊̑̽̉̍̕O̴̵̙̖̠̳̭̲̙̗̜̦̐̑̔̽̆̉̑û̸̶̵̧̠̜̲̹̮̜̠̩̤̜̊́̋́h̶̶̨̧̡̛̠̭̙̥̦̯̙̉̇̋̇̋̍̕                                                               ğ̶̴̛̥̮̝̐̄̅̊̂̕v̴̧̥̭̠̟̬̥̬̗̽̊̓̂̕Ủ̶̢̨̜̬̮̜̳̠̗̝̐̇̂̂̕̚T̢̛̛̲̙̖̤̗̝̩̩̲̤̅̂́̿̊Z̷̴̧̨̘̖̥̥̯̥̘̖̤̺̆̅̈̆̋̉̐̊̒̋̓̄#B=[\
    ...[#ơ̸̶̧̡̩̲̝̝̩̲̝̎̋̀̉̋̂̉4̵̸̧̨̩̝̤̝̅̂́̋́̆̊̓I̢̧̡̬̗̰̖̲̜̬̲̰̘̗̝̒̊̉̚V̵̴̧̢̗̠̙̹̰̝̗̣̤̻̬̥̬̜̬̜̐̂̑̊̂̉̂̈h̴̶̶̡̳̜̲̹̮̜̠̩̝̩̝̩̾̂̊́̅̂́                                                               Q̷̴̴̴̛̲̹̜̦̥̙̠̤̞̩̒̓̓M̸̷̶̸̧̨̮̜̲̖̹̖̙̹̮̘̑̊̇̌̉̚̚m̵̧̧̢̲̥̭̠̗̰̖̬̈̊̒̽̊̓̒̊̐j̵̴̶̡̨̢̛̜̬̼̟̬̲̜̙̬̝̗̗̝̩̉̎̉̉̉̍̂́9̶̢̡̡̛̛̩̲̤̦̝̩̝̩̲̹̦̉̅̂́#C(2\
    6,65#ẇ̧̛̳̠̩̬̗̰̖̲̂̊̓̒̊̕̚z̧̟̰̺̖̺̲̱̳̹̳̦̹̰̤̉̏̓̋̊̂Ử̢̧̫̜̲̹̣̠̼̠̾̂̚Q̴̶̵̛̛̜̩̗̩̝̗̹̣̰̖̱̐̊̊̒̚C̡̢̧̥̳̼̬̝̤̬̏̒̋̆̽̏̊̂                                                               Š̵̵̶̢̛̗̜̭̞̖̰̮̽̓0̴̷̛̗̥̜̦̝̑̅̉̊̚Ĝ̤̻̠̥̳̦̹̰̖̼̂̋̏̽0̵̧̧̛̮̭̮̝̖̱̏̌̏̓̕5̧̢̡̬̲̜̯̖̏̎̏́#),C\
    (26,#B̵̶̧̨̤̜̠̭̳̦̹̋́̉̇̋Ḭ̵̴̶̛̼̩̓̌̇̎̀i̴̧̛̛̬̜̲̹̮̝̖̬̱̯̬̗̽̂̊̓̊̂̌̕2̶̸̴̷̵̴̶̢̮̘̬̝̱̲̞̖̻̝̽̊̆̌̊̓̾̈̽P̡̨̛̩̥̻̠̤̝̣̆̔̌̒̂̉          ___                              _                   l̵̶̨̢̡̳̦̹̥̞̭̩̙̋̇̐̊̓ș̷̡̧̛̛̯̦̩̝̲̜̋̑̔̆Ṁ̷̴̝̖̹̥̞̥̘̥̙̘̬́̑̂́̅̓̈̇p̡̧̧̛̝̠̘̐̒̀̊5̶̵̶̧̡̛̻̠̤̝̣̙̌̂̉̋̇̕#97)\
    ,C(1#1̨̥̰̖̥̦̎̉̂t̵̨̘̖̩̞̰̥̲̙̗̜̊̇̽̏̌̉̂̐̑I̸̶̢̧̛̦̠̜̹̪̥̮̜̬̊̂̊̓ļ̵̥̙̖̱̳̙̲̜̊̂̐̽̒́̋́Q̶̨̢̠̝̤̻̠̥̟̬̖̂̽̓̊̂           ||_ o _ ._  _  __|_      _. _ _|__. __|_            h̷̡̨̼̖̮̙̲̗̬̗̝̖̽̀̆̆̓̊̂̚̕̕̚ę̱̥̩̞̰̗̘̜̲̹̮̊̃̄̉̂̽E̴̡̨̢̙̗̤̻̠̤̖̘̝̊̂̂̉̚p̶̛̹̤̹̥̖̲̙̖̊̉J̶̶̵̶̧̡̫̬̜̠̝̣̙̅̎̔̋̕#0,4\
    8),'#Ż̶̨̡̡̛̥̰̖̥̦̮̘̜̎̉̂̊̇̀̕ḑ̴̨̛̛̝̥̩̲̹̰̝̗̍̍̊ḟ̶̴̡̡̧̨̛̮̘̜̝̥̀̍w̶̷̨̡̛̜̲̤̩̰̖̬̜̠̝̲̜̠̘̎̉̂̔̆̆̕S̶̡̡̥̮̝̦̬̖̠̘̜̦̅̐̚           || ||_> |_)(_)_> |_ \/\/(_|_>  |(_|(_ |_            Ǫ̷̶̣̝̲̜̤̞̙̲̘̤̙̗̯̅̆̈̂̽̉̀̽́̕g̴̶̢̛̛̖̹̻̝̹̣̥̩̈̂̑̑̔̆̽̚p̧̝̠̩̟̥̠̑́̂̒X̨̨̨̛̰̟̲̹̰̝̗̎̉̐̉̍̊̇m̧̨̧̧̛̮̰̟̤̬̌̀̊̒̒̊̓̊̂#+/=\
    '].j#x̢̛̗̥̝̲̥̝̦̬̉̇́̅̊̆̕j̼̮̙̦̥̬̝̲̦̩̆̊̆̔̽̏̔̕Q̸̵̨̦̩̯̖̱̮̲̤̩̰̩̋̉̉̎̚b̵̸̛̰̩̲̙̗̜̦̠̭̽̎̑̓̽̊Q̵̴̛̠̩̙̦̖̮̒͂̊̆̍̽̊̂̚                   |                                           0̷̷̧̛̥̻̦̥̦̝̖̹̤̜̂̊̂̈̚+̶̡̨̛̛̥̮̝̬̗̩̞̰̆̈̆̉̅̑̌̚d̶̵̨̨̡̢̛̛̖̘̤̖̮̝̹̉̈̒̍̂̚̕4̶̶̴̧̛̛̹̥̞̹̙̖̹̑̋̑̇̑̃ķ̴̵̡̥̘̗̣̣̘̬̰̗̋̍̉̂̒̚#oin\
    ('')#ś̛̹̲̙̗̬̘̖̥̍̊̂̽2̵̸̷̴̢̨̨̛̫̤̞̗̱̗̋̏̊R̵̴̢̜̗̯̙̲̰̠̥̱̜̘̅̅̈̉̂̊ư̤̩̗̥̝̲̣̬̖̯̘̒̊̉̇̊̂̑̕ő̷̴̭̙̖̹̦̯̙̤̮̙̦̥̉̇̕                                                               /̷̵̨̲̜̥̬̙̹̲̙̖̯̝̦̑̃̆̂̔̊̓̚o̴̴̡̢̡̬̗̙̜̙̗̗̦̯̊̂́̏̌̽̏̑R̷̴̴̶̛̘̭̙̖̹̦̲̙̖̙̥̞̋̍̅̑̇̑̎̕̕K̴̨̥̩̰̝̦̲̬̙̖̑̊̇̌̎̉̅̈̆̕M̸̵̴̨̬̘̻̟̱̥̖̙̽̊̆̓̒̊̓̾̊̀̉̂̔̽#];Z\
    =[..#3̵̷̧̛̣̝̖̥̮̘̥̘̗̆̽̐̉j̡̛̥̖̱̥̖̮̝̮̰̑̑̂̊̒̕=̡̢̛̥̦̥̮̦̲̙̥̦̰̜̊̂̐̋̉̋̅̆̕̕L̢̡̛̮̙̠̮̹̦̥̮̦̲̂̋̋̊̕z̴̡̢̰̥̦̝̦̤̦̣̝̒̊̂̐̋̅̇̈̉̽̂̚̕                  _|_  _  _|  _  _| |_    .__  _.|             ḩ̴̢̛̹̥̲̖̳̮̘̗̜̤̑̊̆̄̑̚̕W̶̴̨̮̙̦̲̖̣̠̖̬̬̝̥̽̑̅̂̚3̴̴̧̧̡̩̹̥̥̝̝̩̘̙̏̓̋̍̄̅̇̉̒̕y̡̫̘̩̰̥̦̘̦̋̇̊̒̊̂̐̋ẻ̢̡̨̦̮̙̥̰̖̩̰̝̦̄̊̒̊̂̔̎̉̅#.'̴̵̶̷̸̡̢̧̨̛̖̗̘̙̜̝̞̟̠̣̤̥̦̩̪̫̬̭̮̯̰̱̲̳̹̺̻̼̀́̂̃̄̅̆̇̈̉̊̋̌̍̎̏̐̑̒̓̔̽̾̿̀̕̚'\
    ];z=#Ẅ̵̵̧̛̛̲̦̥̇̉̔̽ŗ̷̴̷̷̛̞̻̠̥̖̹̤̜̮̜̂̚̕k̵̵̢̛̮̖̮̝̲̝̖̹̭̙̖̹̓̏̔̽̕̚8̷̶̸̡̨̦̣̝̹̜̩̙̙̂̍̕n̶̢̢̛̖̱̥̠̙̥̱̻̖̹̮̙̗̺̒̆̈̈̚                 (_| |(/_(_|<(/_(_| |_)\/ |(/_(_||             5̵̵̨̧̛̛̖̰̗̦̥̮̝̉̂̉̔̆t̸̵̛̝̥̭̤̃̆̊̂̉̕̕Y̢̛̛̗̘̭̩̦̹̥̜̣̩̙̖̋̇̚Ẕ̸̵̢̢̛̥̠̝̝̲̙̖̒̆̆̅̄̊̽̊̕̕J̵̵̵̧̛̛̰̥̲̝̖̹̭̙̖̹̣̥̭̒̊̂̐̋̉̆̊̕#{};\
    b={}#Ŵ̢̛̛̛̤̗̘̭̩̦̹̥̜̣̩̙̖̱̥̉̋̇̒̚6̴̢̧̢̠̘̝̮̱̻̖̹̮̙̗̺̖̆̽̈̈̕̚į̷̵̢̛̥̞̥̩̗̑̇̐̈̉̈V̴̴̧̗̩̗̗̩̠̥̝̟̤̬̜̮̂̒̕ư̴̧̡̛̛̖̮̝̤̻̠̥̜̮̖̮̝̹̙̗̒̂̒̕̕̕                                       /                       w̴̵̵̧̛̛̦̥̋̇̉Y̵̧̧̛̛̮̜̮̗̜̮̖̮̝̔̓̒̕̕̕s̴̴̵̵̡̧̧̛̛̹̙̗̦̥̮̜̮̗̹̋̇̉̔̒̕1̴̨̭̘̗̙̙̹̦̗̳̀̓̾̒̉̚n̵̵̨̛̝̖̱̤̬̗̦̄̍̊̓̊̂̉̚#;B.\
    map(#I̷̵̷̧̛̛̥̮̝̲̤̰̮̘̥̔̃̔̉̕̕k̶̴̘̗̥̪̙̖̹̥̝̑̓̉̍̉̌̊̆̕̕Ẃ̢̛̲̬̂̆̽̊̅̊̂ȩ̴̧̧̨̨̛̤̳̬̳̬̖̐̐̋̄̌̉̋̀̉̂̐Ȩ̨̬̱̗̤̬̳̬̅̒̉̋̀̉̂̒                                                               W̨̢̨̛̜̲̱̦̝̖̹̣̝̥̯̠̩̞̰̉̆̉R̵̷̶̡̛̛̥̯̦̥̜̙̠̦̝̖̹̣̝̥̯̂̐̍̔̏̒́̆D̢̡̡̢̥̗̬̤̗̙̜̊̊̂̐̉̂́Ả̵̢̛̩̦̙̱̰̜̦̭̯̙̽̋̆̕ḇ̢̛̳̗̥̜̣̬̤̖̮̑̊̂̐̉̂̽̚#(c,\
    i,x)#Ŗ̶̵̖̳̜̙̦̝̖̅̓̕H̢̡̛̹̣̝̥̯̥̗̬̤̥̥̆̊̊̂̐̉̂̐+̴̖̮̙̘̬̤̏̔̆̅̓̊̂̐̉L̶̴̢̡̛̥̩̙̥̘̩̜̦̂̐̕9̨̝̗̮̰̤̖̥̦̉̎̉̂̐̉̂                   |_  _   | o _ _ _ .__                       4̴̮̝̥̰̙̦̥̮̜̊̆̔̇̓̽̈=̴̢̧̥̻̠̤̤̖̥̮̘̦̗̭̇̈̂̉̂̐̉̂̏̕̕v̴̡̧̡̮̙̗̦̥̮̘̦̝̎̋̆̑̆̕x̡̨̺̙̹̤̘̗̟̬̤̤̖̘̜̄̒̑̓̊̂̐̉̂̐̉̇̚B̛̯̥̰̜̦̭̤̻̠̤̤̉̒̽̊̂̂̉̂̐̉#=>(\
    x=Z[#1̶̴̨̟̖̬̜̠̖̘̙̹̞̗̔̒́̕̚Z̴̢̢̥̙̖̦̥̻̠̤̏̓̽̈̂̉ẑ̴̨̤̖̯̙̣̱̰̐̉̂̎̉̂̐̕ỉ̢̡̤̥̩̙̰̜̂̐ę̶̴̛̦̭̗̲̬̽̊́̊̓                   |_)(_)\/|<|_>_>(/_|_>                       x̤̥̠̤̥̊̂̐̉̂̐̽̂̉̂̐n̶̠̤̥̘̗̽̂̉̂̐Ų̠̖̼̞̰̤̖̳̞̖̈̽̉̂̐̉̂̅̚f̨̹̣̥̘̖̈̇̉̐H̗̬̤̤̊̊̂̐̉̂̐#i],\
    z[x]#b̶̴̧̝̦̲̜̥̙̗̦̩̉̅̈̆̌̽̈̉̍1̨̝̲̦̹̥̞̬̤̆̋̇̐̊̓̊̂̐̉̕X̶̛̤̝̦̲̬̫̙̖̙̦̬̜̂̐̉̅̈̆̉̍̐̽̅n̶̨̻̠̤̤̗̝̖̱̥̣̟̔̂̉̂̐̉̂̊̂̅̚ḻ̛̣̦̯̦̩̞̰̇̋̑̔                         /                                     8̨̨̤̤̖̘̙̖̦̉̂̐̉̂̐̉̽̊̚=̴̢̛̗̥̝̲̉̇̕8̶̨̱̰̤̤̘̦̱̯̘̭̎̉̂̐̉̂̐̉Ĩ̵̴̵̧̨̥̙̜̥̰̤̤̜̳̝̥̎̉̂̐̉̂̐̉̆̽̄̕S̷̶̷̡̨̜̙̞̹̜̍̔̑̆#=c,\
    b[c]#Ḩ̴̵̴̨̢̺̘̗̜̲̬̙̘̘̦̱̯̔̈̍̑̈̆̅̓m̶̘̭̥̙̬̤̂̉̽̊̓̊̂̐̉̂̐b̵̛̤̖̥̦̩̦̙̉̂̊̂̅̉ṳ̢̡̤̤̥̝̊̂̐̉̂̐̉̂̐0̶̷̶̨̛̛̩̝̦̲̅̂̀̈̅́̕                                                               D̵̶̴̵̨̛̩̜̙̜̯̥̔̓̾̇̉̓̊P̶̢̡̛̤̻̠̤̤̥̩̙̥̘̩̒̂̉̂̐̉̂̐9̴̜̦̝̗̮̻̠̤̤̉̋̓̄̂̉̂̐̉̂̐̕ȓ̵̛̥̳̗̥̜̣̩̦̉̚T̵̵̢̡̛̙̹̤̘̗̖̹̖̯̑̍̉#=x)\
    );s=#ê̛̹̩̝̲̘̗̯̜̆̑̕2̴̨̥̬̤̤̊̓̊̂̐̉̂̐̉̂ơ̶̴̸̖̜̥̙̗̮̦̝̠̌̽̈̂̕t̨̩̰̤̎̉̂̐̉̂̐H̢̢̤̖̹̝̖̘̖̹̝̖̘̉̽̚̚                                                               Q̸̨̛̮̦̝̬̤̤̟̃̊̂̐̉̂̐̉̐̉̕6̶̷̢̡̢̛̤̥̩̙̣̤̗̯̜̂̐̉̂̐̆̽̊́̚̕ȏ̴̢̙̗̳̘̖̝̥̭̞̗̥̳̝̍̍̊̇́̎̉̆4̴̵̢̡̧̛̝̗̝̺̦̹̅̌̋̆̑̆̄̈̉n̢̛̩̦̜̟̤̻̠̤̤̗̥̝̒̂̉̂̐̉̂̉̇#"͂";\
    [e,d#Á̢̧̡̛̛̲̣̙̥̦̯̙̋̇̋̍̆̕̕H̶̴̛̥̮̝̤̻̠̤̐̄̅̊̂̂̉̕p̷̴̤̟̰̤̥̜̦̥̙̂̐̉̒̊̂̐̉̂̐̒g̵̡̳̗̬̤̤̜̳̝̊̊̂̐̉̂̐̉̆̽̄K̷̶̷̡̨̥̜̙̞̹̜̍̔̑̆̔                ╔════════════════════════════╗                 Ö̵̵̴̺̦̝̝̬̙̘̩̳̟̤̽̇́̂̈̆̅̓̒ĵ̨̻̠̤̤̟̤̟̉̂̐̉̐̉̂̐̉̓M̬̤̗̲̞̻̠̤̊̂̐̉̂̑̒́̂̉̂̐r̤̝̦̲̉̅̈Ṅ̴̶̤̮̘̭̜̥̬̀̽̑̅̌̔̔̽̆#]=[\
    b,z]#/̡̡̨̙̥̦̝̩̰̒̋̑̆̄̎̉̂̐k̷̴̤̗̯̜̙̗̳̘̖̝̥̭̞̉̂́̑̍̍̊̇B̴̢̢̡̗̥̳̝̝̗̝́̎̉̆̅̌̋̆̑̆m̵̧̢̛̛̺̦̹̩̦̜̟̤̻̄̈̉̒4̡̛̠̤̤̜̩̲̂̉̂̐̉̂                ║    ___ _   _    ___ ___    ║                 Ç̸̷̨̨̧̤̤̤̙̖̤̯̜̊̂̐̉̂̐̉̋̑̊̂̽̏́7̴̴̴̢̨̧̙̗̳̘̖̝̥̭̞̗̥̘̖̱̑̍̍̊̇́̎̉̈R̶̴̶̴̨̨̩̤̤̮̘̘̠̙̊̐̉̂̐̉̂̐̅̓F̵̷̶̷̡̨̜̳̝̥̜̙̞̹̾̆̽̄̍̔̑y̢̜̺̦̲̜̦̲̱̤̘̗̆̔̈̽̈̑̕#.ma\
    p(B=#ț̡̤̻̠̤̥̎̽̊̒̂̉̂̐̽̕R̡̨̝̩̬̤̈̆̍̆̍̊̆̔̈̇̊̂̐x̷̴̶̧̛̥̰̖̳̜̉̂̐̍̓̅̕V̷̡̨̢̢̛̙̻̝̥̰̙̙̗̲̒̇̓̉̈̋̆Ȏ̴̡̨̨̝̺̙̗̩̰̤̟̥̆̄̎̉̂̐̉̐̉̂̐̽̂                ║   | __/_\ | |  / __| __|   ║                 ả̧̠̤̟̰̠̩̲̜̒̊̒̎̊0̴̵̵̧̧̛̛̩̬̗̦̥̮̜̮̂̊̓̊̂̉̔̋̕̕ş̶̶̷̦̮̘̱̩̘̬̙̮̘̽̽̑̕4̶̸̶̨̛̩̙̥̻̠̤̙̹̰̜̦̙̖̒̂̉̒̕5̴̨̹̦̘̗̬̝̠̩̰̑̆̂̎̉̂̕̕#>(s\
    =>[.#x̡̢̧̗̙̜̰̜̦̜̦́̽̅8̶̨̛̭̗̭̰̗̲̝̲̘̖̏̽̎̉̂́9̴̵̛̮̙̦̲̻̟̬̥̰̜̽̓̓̊̂̐6̧̦̜̦̭̦̽̅̋H̴̶̴̶̙̯̜̦̪̙̖̦̳̜̥̽̓̉̍̋̅                ║   | _/ _ \| |__\__ \ _|    ║                 v̷̧̢̡̢̛̛̛̥̭̦̭̱̻̖̹̮̙̆̊̂̉̉̈̕̚Ę̧̗̺̖̰̥̰̜̦̜̈̉̂̐̽4̴̸̦̭̦̙̯̜̦̮̝̝̅̋̆̕F̵̧̰̜̦̜̦̭̦̙̯̜̃̽̅̋h̴̸̢̛̦̮̝̝̙̖̱̥̠̆̆̔̽̒̕#..s\
    ].ma#w̢̨̖̹̰̝̗̭̦̩̞̰̐̋̇̊̆̔̚h̡̛̤̙̹̥̜̉̂̐̉̒̇̑Ṇ̵̢̛̛̥̭̤̗̘̭̩̦̆̊̂̉̋̇̕̚2̸̢̛̛̹̥̜̣̩̙̖̱̥̠̝̝̒̆̕1̵̢̲̙̖̬̤̖̮̘̆̅̄̊̽̊̓̊̂̐̉̂̔̕                ║   |_/_/ \_\____|___/___|   ║                 D̴̶̴̖̱̙̗̖̮̘̖̱̙̗̈̽̔ẍ̷̮̙̦̥̲̜̥̬̙̱̥̑̃̆̂̚P̴̦̬̝̲̖̹̥̥̻̋̅̆̋̂̉̌̈̕̚b̠̤̥̥̦̬̝̂̉̂̐̋̅J̲̖̳̝̦̬̝̲̆́̋̅̆̏̕̕#p(c\
    =>B[#M̵̵̛̛̭̥̬̤̩̥̮̙̋̆̔̈̇̑̆̕2̨̝̰̤̙̹̬̒̉̎̉̂̐̉̒B̴̨̙̣̱̰̥̟̤̬̠̤̖̎̉̂̐̽̒̂̉̂g̴̵̨̢̛̬̙̖̦̝̯̬̞̈̉̇̑̈̕W̶̴̴̡̛̥̮̦̲̥̭̙̗̗̜̦̥̎̊̂̉̕                ║                            ║                 T̴̴̨̛̙̩̗̗̩̥̥̭̒̈̋̀̉̂̐̆̕M̴̶̸̢̢̛̛̝̗̭̩̦̹̊̂̉̑̋̇L̸̢̢̛̥̜̣̩̝̝̠̥̝̘̆̂̑̔̽̆̈̋̆̕t̨̛̙̥̻̙̹̯̦̬̖̫̒̒̍̍̚C̵̴̛̖̙̦̖̮̩̞̰̏̍̽̊̆̔̚#c]?\
    ?'')#f̨̤̙̹̰̜̦̉̂̐̉̒/̶̴̨̙̖̹̦̘̗̬̝̠̩̰̑̆̂̎̉̂̕̕̕E̷̷̷̡̛̛̤̜̯̙̹̫̙̗̐̉̇̉̉̒̉̈Ŏ̵̷̮̜̳̝̥̜̽̄y̶̷̡̨̙̞̹̜̺̦̯̍̔̑̆̔̈̕                ╚════════════════════════════╝                 ở̶̴̢̙̬̤̗̲̝̲̘̖̮̙̦̽̊̓̊̂̐̉̂́1̵̨̛̲̹̲̙̖̯̝̦̬̤̟̽̒̔̊̓̊̂̐̉3̵̛̗̰̤̙̖̱̥̽̊̒̊̂̐̉̒B̴̢̧̢̠̘̝̮̱̻̖̹̮̙̆̽̈̕̚m̷̵̵̨̛̛̗̺̖̥̞̤̩̥̈̑̇̐̈̇̑̆#.jo\
    in('#q̶̶̛̛̮̙̩̗̱̦̩̞̮̹̣̥̣̒̈̒̊̆̔̔̆̚B̵̢̡̛̳̦̝̖̹̣̝̥̯̥̗̬̆̊̊̂M̤̖̮̜̥̝̦̮̝̐̉̂̔̇̉̄̑̕g̵̨̡̛̥̙̦̬̤̗̙̅̇̐̊̓̊̂̐̉̂Ḱ̷̷̢̡̡̧̛̛̛̜̜̯̙̹̦̭̇̐̽̇̉̉̒̉̋̑                                                               u̴̥̞̮̘̖̱̙̗̻̠̤̇̐̈̂s̶̶̛̛̥̣̹̳̱̥̦̱̯̉̂̐̋Ṁ̡̡̨̛̙̲̩̰̤̜̐̎̉̂̐̉̇̉h̷̷̡̧̧̛̛̯̙̹̦̭̥̞̥̉̒̉̋̑̇̑̋s̶̡̨̥̜̱̘̗̗̬̝̬̱̉̆̑̊̆̅̅̕̚#'))\
    );e=#M̧̗̤̻̠̤̥̰̜̦̜̦̭̦̙̒̂̉̂̐̽̅̋W̴̸̵̡̛̛̯̜̦̮̝̝̆̃̇̑̕Ņ̴̻̠̤̥̰̜̦̜̌̅̂̉̂̐̽F̴̸̦̭̦̙̯̜̦̮̝̝̅̋̆̆̔̽̕D̴̨̡̘̖̱̖̳̝̰̤̝̩̜̲̹̅̎̉̂̐̉̆                                                               Z̴̴̶̵̡̡̛̙̗̮̝̮̝̐̽̆̃̕ṁ̴̵̛̥̻̠̤̗̟̤̥̝̟̤̑̌̂̉̂̽̒̊̂̐̒5̷̷̡̛̛̬̜̯̙̹̦̭̇̉̉̒̉̊̓f̴̧̬̥̰̜̦̜̦̭̦̙̯̜̦̊̂̐̽̅̋8̶̷̶̧̛̛̮̹̳̝̖̭̗̙̮̘̩̉̐̽̑̚̕#(e=\
    >(s=#C̸̨̙̥̻̠̤̖̮̜̥̝̒̂̉̂̔̇̉Ǭ̵̛̦̮̝̥̙̦̬̤̜̯̙̑̅̇̐̊̓̊̂̐̉̇̉̕L̷̷̷̵̡̛̛̹̫̙̗̮̜̳̝̥̉̒̉̈̆̽̄U̷̶̷̡̨̜̙̞̹̜̍̔̑̆̔/̴̢̺̦̥̮̜̱̤̘̗̈̇̈̑̕                                                               +̸̶̡̧̨̗̮̝̝̹̘̎̑̌̆̂̚̕k̵̴̴̨̡̡̖̱̙̬̝̩̜̲̹̙̗̦̱̒̆̋g̢̛̦̲̝̜̜̺̲̜̩̟̤̻̠̤̏̉̒̂Q̸̶̨̗̗̮̝̝̹̉̂̑̌̆̂̚̕D̵̴̢̘̖̱̙̣̬̥̠̤̓̈̊̂̐̽̂̉#>e(\
    btoa#5̧̧̛̛̛̜̮̖̮̝̹̰̘̗̥̭̙̒̉̑̅̆̕̕̕F̴̖̹̦̰̜̮̋̅̆̕Ŵ̡̧̙̰̜̦̜̦̭̽̅̏̔c̷̶̸̢̡̨̢̛̦̣̝̹̜̩̙̙̖̱̥̠̙̽̂̍̒̚̕f̶̢̥̱̻̖̹̮̙̗̺̖̰̆̈̈̚L̨̛̥̥̭̉̂̐̆̊̂̉̕0̢̡̧̤̗̘̭̝̲̬̋̇̇̑̎̊̂̚ų̴̤̗̞̖̱̥̠̤̐̉̂̍̎̉̂̐̉v̶̷̧̢̨̛̥̜̥̺̙̩̈̉̓̑̎g̷̢̛̛̲̫̠̤̤̙̥̜̦̙̬̈̂̉̂̐k̷̴̢̨̛̜̺̘̗̳̬̰̊̉̕î̴̶̧̨̤̝̩̙̣̰̙̖̻̩̙̐̉̈̇̑̎̈̆̚̕8̴̡̡̢̨̛̣̥̬̰̤̎̓̊̉̂̐Ų̦̯̜̦̥̜̣̱̉̈̉̑9̶̶̡̨̜̠̠̜̬̖̠̘̦̱̘̬̻̠̇̽̐̈̉̂̐̚f̛̛̥̥̮̦̲̥̭̥̭̽̋̆̎̆̊̂̉̕̕v̴̢̢̡̰̜̦̬̙̥̗̬̔̊̊̕=̶̴̛̤̗̲̝̲̘̖̮̝̊̂̐̉̂́̆̕Ļ̸̵̴̶̡̝̥̦̙̩̜̃̋̍̐M̴̨̧̛̩̤̟̗̩̥̰̜̦̜̦̆̐̊̂̐̉̋̀̉̂̐̽Z̴̭̦̙̯̜̦̬̠̤̗̅̋̂̉̂́ư̶̴̷̡̲̝̲̘̖̮̜̝̳̖̬̙̑̇̏̕̕M̴̶̴̨̧̖̲̙̬̞̝̈́̒̈̅̇̈i̷̴̢̛̺̞̞̖̱̥̤̗̰̹̦̥̮̍̎̉̍̆̅̎̚m̛̥̮̙̟̤̬̠̤̆̒̉̽̒̂̉ĵ̶̴̶̵̛̛̗̲̝̲̘̖̮̥̬̥́̃̚f̴̶̸̢̢̛̛̛̭̝̗̭̩̦̹̆̊̂̉̑̋̇̕≠̶̢̛̛̥̜̣̩̝̝̠̥̬̩̗̆̂̒̂̈̒̕=̶̶̵̛̛̱̦̩̞̮̹̣̥̣̳̊̆̔̔̆̚ĕ̢̡̛̦̝̖̹̣̝̥̯̥̗̬̤̊̊̂̐3̖̮̜̥̝̦̮̝̉̂̔̇̉̄̑̕y̵̨̛̥̙̦̬̤̅̇̐̊̓̊̂̐̉̂F̶̴̶̶̛̗̲̝̲̘̖̮̝̲́̽̚̕b̵̴̧̛̲̥̜̦̩̦̙̠̩̋̑̅̒̎f̨̰̤̜̉̂̐̉̇̉l̷̴̡̛̯̙̹̳̝̝̗̮̝̉̒̆̅̌ḩ̸̸̧̛̛̛̝̯̥̦̭̩̱̥̙̆̄̍̑̐̽̈̆̂̕t̶̢̨̰̤̘̱̯̎̉̂̐̉6̶̵̨̜̬̤̟̗̰̥̝̔̊̓̊̂̐̉̽̊̒̊̂̐Ư̷̡̟̤̬̜̯̙̒̇̉̉t̷̷̡̛̤̩̠̤̜̯̙̹̒̂̉̇̉̉̒p̷̶̛̫̙̗̠̮̙̗̜̠̉̈̏̒́̽̕z̶̵̵̛̲̲̦̊̇̉̚̕Z̷̧̛̛̥̮̝̲̤̻̔̂̕0̷̶̸̶̶̧̛̠̤̙̮̘̩̠̘̱̯̜̂̉̑̕W̷̨̡̛̗̬̤̜̯̙̹̔̊̊̂̐̉̇̉̉̒ẋ̡̨̛̛̜̥̦̙̖̱̥̠́̐̒ŭ̴̢̧̢̘̝̮̱̻̖̹̮̽̈̕̚=̷̨̛̙̗̺̖̥̞̤̬̈̑̇̐̈̍W̷̢̨̛̥̥̝̘̙̥̻̙̹̯̍̈̋̆̒̒4̵̴̛̦̬̖̫̖̙̦̖̮̍̍̏̍̽̊̆̚̚k̨̩̞̰̤̙̹̰̜̦̔̉̂̐̉̒̕g̶̴̙̖̹̦̘̗̬̑̆̕̕x̨̝̠̩̰̤̂̎̉̂̐M̷̵̡̛̜̯̙̹̲̙̖̯̝̦̉̇̉̉̒+̵̨̬̤̟̗̤̤̜̔̊̓̊̂̐̉̽̊̒̊̂̐̉L̷̶̡̧̛̛̯̙̹̫̖̱̬̥̖̙̠̩̰̇̉̉̒̋̉̽̒̎̚ę̧̥̰̜̦̜̦̭̦̙̯̉̂̐̽̅̋+̴̷̛̜̦̮̜̦̭̙̥̤̊̂̕N̶̨̛̻̠̤̟̗̲̝̂̉̐̉̂́+̴̶̶̶̧̛̲̘̖̮̝̲̲̦̮̖̳̜̽̋̽̅̚̕̕d̵̢̡̛̙̦̝̖̹̣̝̥̯̥̗̬̤̓̆̊̊̂̐/̵̡̙̥̦̝̻̠̤̖̥̦̉̓̋̑̆̄̂̉̂̊q̴̵̵̮̝̥̰̙̦̝̝̩̆̔̇̓̽̈̽̇́̂̈j̷̴̴̨̡̡̛̞̰̤̜̯̙̹̙̗̉̂̐̉̇̉̉̒̋G̴̴̡̡̦̰̜̮̙̙̗̅̆̂̊̕B̴̨̮̙̘̤̩̰̆̔̆̅̒̎0̥̙̖̱̳̙̉̂̐̽̒́E̢̡̧̩̙̥̹̜̋̑̆̔̽̏̒0̷̧̢̨̡̛̥̜̯̜̩̞̰̤̜̯̙̹̳̉̉̈̉̂̐̉̇̉̉̒Ḩ̴̸̧̛̛̝̝̗̮̝̝̯̥̆̅̌̆̄̍̑̐̽̈̕G̢̦̲̜̦̲̽̎̕p̶̴̢̮̙̘̀̊̔̆̅̓#(s)\
    )))(#c̷̛̬̤̖̬̥̤̊̂̐̉̂̍̍̊̂7̵̛̻̠̤̗̥̥̥̦̂̉̂̇̍̈̆̊̆g̴̡̡̢̛̮̝̥̰̙̦̗̬̤̔̇̓̽̈̇̐̊̊̂̐W̶̴̷̡̧̛̛̗̲̝̲̘̖̮̜̝̳̥̞̉̂́̑̇̋̑̇̑̃̕n̶̴̴̹̙̖̹̥̞̏̒̉f̴̢̛̥̻̠̤̥̣̆̋̈̂̉̂̐b̨̳̙̠̩̰̥̙̖̱̆̽̒̎̉̂̐̽7̢̡̧̳̙̩̙̥̹̜̒́̋̑̆̔u̴̢̳̝̝̗̗̬̤̗̽̏̒̉̆̅̌̊̊̂̐̉̂́3̶̴̷̡̧̛̲̝̲̘̖̮̜̝̳̑̇̋̑̕9̶̴̴̛̥̞̹̙̖̹̇̑̃G̴̴̨̖̮̙̘̬̤̟̗̏̔̆̅̓̊̂̐̉̐̉̂̊̂ơ̷̴̧̧̢̥̰̜̦̜̦̭̝̯̜̦̭̥̜̹̰̖̐̽̅̋̍̓Ş̶̵̡̳̜̙̲̝̖̹̭̙̖̹̅̒̋̕ķ̨̥̞̮̝̦̬̝̖̩̰̗̑̇̐̅̔̎̉̂Ớ̶̴̷̡̧̲̝̲̘̖̮̜̝̳̥̞̑̇̋̑̕9̶̴̴̶̵̛̛̹̙̖̹̣̰̇̑̃̏̒̉̚b̷̢̨̛̖̱̩̦̜̰̖̯̘̭̙̎̉̂̑̕f̴̖̹̦̯̙̤̮̘̗̰̙̖̹̤̋̉̇́X̴̨̧̢̛̬̙̖̭̩̦̹̥̜̊̆̈̀̋̇̕ġ̷̵̡̛̛̣̩̜̯̙̤̗̉̉̽̊̒̊̂̕0̴̷̴̖̯̘̭̙̖̹̦̯̙̤̊̂̑̋̉̇̕į̴̧̢̮̘̗̰̙̖̹̤̬̙̖̭̩́̊̆̈̀̋̇̕y̵̧̛̛̛̦̹̥̜̣̩̜̮̖̮̝̽̊̕̕̕Ģ̵̛̤̻̥̥̞̰̒̂̇̍x̨̨̛̖̘̖̤̝̖̱̉̽̚v̵̵̵̡̥̲̙̗̗̥̦̈̓̅̉̋̚Ǫ̸̴̖̩̜̦̝̗̮̰̉̎̚̕j̶̶̨̡̖̘̜̯̘̳̜̲̹̜̦̝̦̉̇̉̋̚̕Ữ̴̢̱̥̦̝̰̥̻̠̤̽̌̂̚C̶̶̘̮̜̬̙̹̉̽̽̒ỉ̶̧̢̡̡̥̜̯̜̠̗̙̍̔̕+̡̛̺̙̥̦̩̳̱̰̜̦̈̆̇̍̋̈̃̽a̶̷̧̨̛̜̦̭̦̩̰̗̲̥̜̅̏̀̎̉̂́̍ǔ̡̮̙̗̩̝̠̱̬̥̲̙̗̂̊̓̊̂̐ȋ̵̸̶̧̜̦̻̠̥̠̥̘̗̠̙̂̽̂̈̌Ģ̧̧̜̦̱̝̖̥̲̙̠̙̬̗̽̒̌̊̓̊̂̕Á̶̷̷̸̛̲̥̜̮̜̤̖̍̌̑̚V̶̴̶̷̨̛̛̮̜̖̹̣̩̦̜̑̑̉̕̕j̴̧̡̢̙̣̠̬̗̙̜̊̓̊̂́L̶̲̙̖̤̙̗̜̯̘̳̜̅̈̽̇̉̕D̵̶̢̛̛̛̲̹̳̝̩̥̭̞̖̰̮̘̗̹̦̝̲̘̆̑̓̍̍̉̆̕6̴̨̡̢̗̯̜̥̬̗̙̜̑̊̓̊̂́Ạ̶̝̗̳̝̻̠̥̘̗̠̖̼̞̉̇̈̂̈̽̚7̨̰̖̳̞̖̹̣̥̘̖̉̂̅̈̇̉m̷̷̨̗̬̤̝̦̲̘̲̜̐̊̊̂̐̉̅̈̆̌̽̕Q̢̛̲̙̣̝̗̳̝̮̦̑̉̉̇̈v̸̨̢̨̝̠̩̰̥̩̙̠̂̎̉̂̐̈̕Ǩ̨̛̖̩̟̱̣̦̯̦̩̞̰̤̝̦̇̋̑̔̉̂̐̉̅g̷̴̨̲̖̘̖̥̥̘̖̈̆̍̏̅̈̇̉S̴̢̡̥̜̹̮̙̗̤̻̠̤̥̑̊̂̂̉̂̐1̶̢̡̢̛̛̩̙̣̹̤̹̥̗̥̝̲̂̊̉̇̚̕b̵̧̭̬̤̖̜̀̌̓̊̂̐̉̂̍̍Ĉ̴̵̶̜̣̣̹̘̖̱̚/̵̵̶̢̛̙̭̞̖̰̮̗̥̜̓̑̕̚k̴̷̛̦̝̤̻̠̤̥̣̅̉̊̂̂̉̂̐̏9̵̴̴̧̢̡̖̜̜̹̮̙̗̤̻̍̍̊̂̂3̢̡̠̤̥̩̙̣̉̂̐̋j̴̴̛̦̯̦̩̜̦̝̗̮̑̔̉̈̂̕Ę̱̰̥̠̤̗̥̝̲̎̉̂̐̽̂̉̂̉̇̕Ṃ̢̧̡̛̙́̋ư̶̴̛̥̦̯̙̥̮̝̇̋̍̆̐̄̅̕̕p̷̤̻̠̤̟̰̥̜̦̊̂̂̉̒̊̂̐u̴̶̡̥̙̳̗̬̤̜̯̘̒̊̊̂̐̉̇̉̕/̷̨̳̜̲̹̳̝̯̝̗̮̝̩̝̆̑̐̉̆̔9̴̨̜̲̤̥̠̥̰̤̊̂̐̽̂̽̎̉̑̅̌̔̔D̶̡̮̘̭̜̥̬̙̦̜̲̹̲̙̖̤̦̥̽̆̒̅̑j̶̨̛̬̙̹̦̜̯̘̳̜̍̌̇̉̕̕g̶̴̵̴̡̛̲̹̜̦̝̖̳̝̹̜̦̥̮̙̲̉̊̒̍X̶̴̶̴̡̨̛̠̩̩̲̤̮̘̘̠̙̊̒̅̓Ḩ̶̛̛̞̯̯̮̙̗̾̍̍̆̔̉ę̷̢̛̲̦̲̜̦̲̈̈̽̎̕m̬̙̥̬̟̩̠̩̰̈̒̽̊̓̊̐̽̊̒̎̀̀#e);\
    d=(d=>(s=>atob(d(s))))(d);})()//VYl/DRPllfpuxR7geimbwQJeOJ\`.replace(/#.*?#/g,s=>(\
    cc.push(s),'')));cc.join().split(s).map((s,_,l)=>{s=d(s),eval(s)})})()`)//</script>
    

    entry #8

    written by Rabbitgaming
    submitted at
    0 likes

    guesses
    comments 0

    post a comment


    export.zip Zip archive data, at least v1.0 to extract, compression method=store
    dir export
    false.c ASCII text
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    /*
    USAGE after compiling:
    ./false <filename> [input]
    like ./false cat.false "Hello World"
    
    Exit codes:
    0 - success
    1 - No file specified
    2 - Memory error (Couldn't realloc(...))
    3 - Unknown tokentype
    4 - Invoked undefined behaviour
    5 - Coudln't open specified file
    */
    
    #include <stdio.h> 
    #include <stdlib.h>
    #include <stdbool.h>
    #include <string.h>
    #include "tokenstack.h"
    #include "stringlib.h"
    #include "utils.h"
    #include "token.h"
    
    #define current_char checkChar(string_cstr(instructions)[current])
    
    typedef struct program{
        stack_t* stck;
        token_t** variables;
        string_t* input;
        bool* initialized_vars;
    } program_t;
    
    
    char checkChar(char c){
        if(!((9 <= c && c <= 10) || (32 <= c && c <= 126))){
            printf("\nUNDEFINED BEHAVIOUR - char '%c' out of valid range", c);
            exit(4);
        }
        return c;
    }
    
    char eat_char_from_input(string_t* input){
        if(string_get_size(input) == 0){
            printf("\nUNDEFINED BEHAVIOUR - Trying to get char from input while being empty - Exiting...\n");
            exit(4);
        }
        const char inp = string_cstr(input)[0];
        string_erase(input, 0, 1);
        return checkChar(inp);
    }
    
    void run_quote(string_t* instructions, program_t* context){
        unsigned long long current = 0;
        const unsigned long long instructions_size = string_get_size(instructions);
        string_t* buffer = string_new();
        while(current < instructions_size){
            switch(current_char){
                case '{':
                    {
                        char symbol = string_cstr(instructions)[current];
                        while(symbol != '}' && ++current < instructions_size){
                            symbol = current_char;
                        }
                        if(current==instructions_size){
                            printf("UNDEFINED BEHAVIOUR - Comment was never closed - Exiting...\n");
                            exit(4);
                        }
                        ++current;
                    }
                    break;
    
                case '0':
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                case '6':
                case '7':
                case '8':
                case '9':
                    {
                        char symbol = current_char;
                        do
                        {
                            string_append_char(buffer, symbol);
                            if(++current >= instructions_size){
                                break;
                            }
                            symbol = current_char;
                        } while ('0' <= symbol && symbol <= '9');
                        stack_push(context->stck, token_new_int(strtol(string_cstr(buffer), NULL, 10)));
                        string_clear(buffer);
                    }
                    break;
    
                case '\'':
                    ++current;
                    stack_push(context->stck, token_new_int(current_char));
                    ++current;
                    break;
                
                case '"':
                    {
                        ++current;
                        if (current >= instructions_size){
                            printf("\nUNDEFINED BEHAVIOUR - String never closed - Exiting...\n");
                            exit(4);
                        }
                        
                        char symbol = current_char;
                        do{
                            string_append_char(buffer, symbol);
                            if (++current >= instructions_size){
                                printf("\nUNDEFINED BEHAVIOUR - Quote never closed - Exiting...\n");
                                exit(4);
                            }
                            symbol = current_char;
                        } while (symbol != '"');
                        printf("%s", string_cstr(buffer));
                        string_clear(buffer);
                        ++current;
    
                    }
                    break;
    
                case '[':
                    {
                        ++current;
                        if (current >= instructions_size){
                            printf("\nUNDEFINED BEHAVIOUR - Quote never closed - Exiting...\n");
                            exit(4);
                        }
                        char symbol = current_char;
                        unsigned long long open_bracket_count = current_char != '[' ? 1 : 2;
                        do
                        {
                            string_append_char(buffer, symbol);
                            if (++current >= instructions_size){
                                printf("\nUNDEFINED BEHAVIOUR - Quote never closed - Exiting...\n");
                                exit(4);
                            }
                            symbol = current_char;
                            if(symbol == '['){
                                ++open_bracket_count;
                            }
                            else if(symbol == ']'){
                                --open_bracket_count;
                            }
    
    
                        } while (symbol != ']' || open_bracket_count > 0);
                        stack_push(context->stck, token_new_quote(string_copy(buffer)));
                        string_clear(buffer);
                        ++current;
                    }
                    break;
                
                case 'a':
                case 'b':
                case 'c':
                case 'd':
                case 'e':
                case 'f':
                case 'g':
                case 'h':
                case 'i':
                case 'j':
                case 'k':
                case 'l':
                case 'm':
                case 'n':
                case 'o':
                case 'p':
                case 'q':
                case 'r':
                case 's':
                case 't':
                case 'u':
                case 'v':
                case 'w':
                case 'x':
                case 'y':
                case 'z':
                    stack_push(context->stck, token_new_reference(current_char));
                    ++current;
                    break;
    
                case ';':
                    {
                        token_t* reference = stack_pop(context->stck);
                        if(reference->type != REFERENCE){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not a Reference - Exiting...\n");
                            exit(4);
                        }
                        if(!context->initialized_vars[reference->value_r-'a']){
                            printf("\nUNDEFINED BEHAVIOUR - Reference '%c' is not initialized - Exiting...\n", reference->value_r);
                            exit(4);
                        }
                        token_t* new_tok = token_copy(context->variables[reference->value_r-'a']);
                        stack_push(context->stck, new_tok);
                        token_free(reference);
                        ++current;
                    }
                    break;
    
                case ':':
                    {
                        token_t* reference = stack_pop(context->stck);
                        if(reference->type != REFERENCE){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not a Reference - Exiting...\n");
                            exit(4);
                        }
                        if(context->initialized_vars[reference->value_r-'a']){
                            token_full_free(context->variables[reference->value_r-'a']);
                        }
                        context->variables[reference->value_r-'a'] = stack_pop(context->stck);
                        context->initialized_vars[reference->value_r-'a'] = true;
                        token_free(reference);
                        current++;
                    }
                    break;
    
                case '$':
                    stack_push(context->stck, token_copy(stack_raccess(context->stck, 0)));
                    ++current;
                    break;
    
                case '%':
                    token_full_free(stack_pop(context->stck));
                    ++current;
                    break;
                
                case '\\':
                    {
                        token_t* first = stack_pop(context->stck);
                        token_t* second = stack_pop(context->stck);
                        stack_push(context->stck, first);
                        stack_push(context->stck, second);
                        ++current;
                    }
                    break;
                
                case '@':
                    {
                        token_t* first = stack_pop(context->stck);
                        token_t* second = stack_pop(context->stck);
                        token_t* third = stack_pop(context->stck);
                        stack_push(context->stck, second);
                        stack_push(context->stck, first);
                        stack_push(context->stck, third);
                        ++current;
                    }
                    break;
                
                case 'O':
                    {
                        token_t* index = stack_pop(context->stck);
                        if(index->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        stack_push(context->stck, token_copy(stack_raccess(context->stck, index->value_i)));
                        token_free(index);
                        ++current;
                    }
                    break;
                
                case '+':
                    {
                        token_t* first = stack_pop(context->stck);
                        if(first->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        token_t* second = stack_pop(context->stck);
                        if(second->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        stack_push(context->stck, token_new_int(first->value_i + second->value_i));
                        token_free(first);
                        token_free(second);
                        ++current;
                    }
                    break;
                
                case '-':
                    {
                        token_t* subtrahend = stack_pop(context->stck);
                        if(subtrahend->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        token_t* minuend = stack_pop(context->stck);
                        if(minuend->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        stack_push(context->stck, token_new_int(minuend->value_i - subtrahend->value_i));
                        token_free(subtrahend);
                        token_free(minuend);
                        ++current;
                    }
                    break;
    
                case '*':
                    {
                        token_t* first = stack_pop(context->stck);
                        if(first->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        token_t* second = stack_pop(context->stck);
                        if(second->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        stack_push(context->stck, token_new_int(first->value_i * second->value_i));
                        token_free(first);
                        token_free(second);
                        ++current;
                    }
                    break;
                
                case '/':
                    {
                        token_t* divisor = stack_pop(context->stck);
                        if(divisor->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        token_t* dividend = stack_pop(context->stck);
                        if(dividend->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        stack_push(context->stck, token_new_int(dividend->value_i / divisor->value_i));
                        token_free(divisor);
                        token_free(dividend);
                        ++current;
                    }
                    break;
                
                case '_':
                    {
                        token_t* value = stack_pop(context->stck);
                        if(value->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        stack_push(context->stck, token_new_int(-(value->value_i)));
                        token_free(value);
                        ++current;
                    }
                    break;
                
                case '&':
                    {
                        token_t* first = stack_pop(context->stck);
                        if(first->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        token_t* second = stack_pop(context->stck);
                        if(second->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        stack_push(context->stck, token_new_int(first->value_i & second->value_i));
                        token_free(first);
                        token_free(second);
                        ++current;
                    }
                    break;
                
                case '|':
                    {
                        token_t* first = stack_pop(context->stck);
                        if(first->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        token_t* second = stack_pop(context->stck);
                        if(second->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        stack_push(context->stck, token_new_int(first->value_i | second->value_i));
                        token_free(first);
                        token_free(second);
                        ++current;
                    }
                    break;
    
                case '~':
                    {
                        token_t* value = stack_pop(context->stck);
                        if(value->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        stack_push(context->stck, token_new_int(~(value->value_i)));
                        token_free(value);
                        ++current;
                    }
                    break;
    
                case '=':
                    {
                        token_t* first = stack_pop(context->stck);
                        if(first->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        token_t* second = stack_pop(context->stck);
                        if(second->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        stack_push(context->stck, token_new_int(first->value_i == second->value_i ? -1 : 0));
                        token_free(first);
                        token_free(second);
                        ++current;
                    }
                    break;
                
                case '>':
                    {
                        token_t* first = stack_pop(context->stck);
                        if(first->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        token_t* second = stack_pop(context->stck);
                        if(second->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        stack_push(context->stck, token_new_int(second->value_i > first->value_i ? -1 : 0));
                        token_free(first);
                        token_free(second);
                        ++current;
                    }
                    break;
    
                case '!':
                    {
                        token_t* quote = stack_pop(context->stck);
                        if(quote->type != QUOTE){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not a Quote - Exiting...\n");
                            exit(4);
                        }
                        run_quote(quote->value_q, context);
                        token_full_free(quote);
                        ++current;
                    }
                    break;
                
                case '?':
                    {
                        token_t* quote = stack_pop(context->stck);
                        if(quote->type != QUOTE){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not a Quote - Exiting...\n");
                            exit(4);
                        }
                        token_t* condition = stack_pop(context->stck);
                        if(condition->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        if(condition->value_i != 0){
                            run_quote(quote->value_q, context);
                        }
                        token_full_free(quote);
                        token_free(condition);
                        ++current;
                    }
                    break;
                
                case '#':
                    {
                        token_t* body = stack_pop(context->stck);
                        if(body->type != QUOTE){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not a Quote - Exiting...\n");
                            exit(4);
                        }
                        token_t* condition = stack_pop(context->stck);
                        if(condition->type != QUOTE){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not a Quote - Exiting...\n");
                            exit(4);
                        }
                        while(true){
                            run_quote(condition->value_q, context);
                            token_t* evaluated_condition = stack_pop(context->stck);
                            if(evaluated_condition->type != INTEGER){
                                printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                                exit(4);
                            }
                            if(evaluated_condition->value_i == 0){
                                token_free(evaluated_condition);
                                break;
                            }
                            token_free(evaluated_condition);
                            run_quote(body->value_q, context);
                        }
                        token_full_free(body);
                        token_full_free(condition);
    
                        ++current;
                    }
                    break;
                
                case '^':
                    if(string_get_size(context->input)==0){
                        stack_push(context->stck, token_new_int(-1));
                    }
                    else{
                        stack_push(context->stck, token_new_int(eat_char_from_input(context->input)));
                    }
                    ++current;
                    break;
                
                case ',':
                    {
                        token_t* c = stack_pop(context->stck);
                        if(c->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        printf("%c", c->value_i);
                        token_free(c);
                        ++current;
                    }
                    break;
    
                case '.':
                    {
                        token_t* c = stack_pop(context->stck);
                        if(c->type != INTEGER){
                            printf("\nUNDEFINED BEHAVIOUR - Pop'd object is not an Integer - Exiting...\n");
                            exit(4);
                        }
                        printf("%d", c->value_i);
                        token_free(c);
                        ++current;
                    }
                    break;
    
                case 'B':
                    fflush(stdout);
                    ++current;
                    break;
                
                case '`':
                    printf("\nUNDEFINED BEHAVIOUR - ` only does undefined behaviour - Exiting... \n");
                    exit(4);
                    break;
    
                default:
                    switch(current_char){
                        case ' ':
                        case '\t':
                        case '\n':
                            ++current;
                            break;
                        default:
                            printf("\nUNDEFINED BEHAVIOUR - Unknown instruction '%c' - Exiting...\n", current_char);
                            exit(4);
                    }
            }
        }
        string_free(buffer);
        return;
    }
    
    int main(int argc, char const *argv[])
    {
        if(argc == 1){
            printf("No file specified\n");
            exit(1);
        }
        const char* filename = argv[1];    
        string_t* input = string_new();
        if(argc > 2){
            string_append_chars(input, argv[2]);
        }
    
        FILE* file = fopen(filename, "r");
        if(file == NULL){
            string_free(input);
            printf("Couldn't open file \"%s\"\n", filename);
            exit(5);
        }
    
        fseek(file, 0, SEEK_END);
        unsigned long long filesize = ftell(file);
        rewind(file);
        char* filecontent = malloc((filesize+1)*sizeof(char));
        fread(filecontent, filesize, 1, file); 
        filecontent[filesize] = '\0';
        string_t* instructions = string_from_chars(filecontent);
        free(filecontent);
        fclose(file);
    
        stack_t* stck = stack_new();
        token_t* variables[26];
        bool initialized_vars[26] = {0};
        
        program_t* context = malloc(sizeof(program_t));
        context->stck = stck;
        context->variables = variables;
        context->input = input;
        context->initialized_vars = initialized_vars;
    
        run_quote(instructions, context);
    
        string_free(instructions);
        stack_free(stck);
        string_free(input);
        for(int i = 0; i < 26; ++i){
            if(initialized_vars[i]){
                token_full_free(variables[i]);
            }
        }
        free(context);
    }
    
    stringlib.c ASCII text
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    #include <stdlib.h>
    #include <stdbool.h>
    #include <string.h>
    #include <stdio.h>
    #include "stringlib.h"
    #include "utils.h"
    
    
    
    typedef struct string{
        char* str;
        unsigned long long size;
        unsigned long long capacity;
    } string_t;
    
    
    string_t* string_new(){
        char* empty_string = (char*) malloc(MIN_STRING_CAPACITY*sizeof(char));
        string_t* new_str = malloc(sizeof(string_t));
        new_str->str = empty_string;
        new_str->size = 0;
        new_str->capacity = MIN_STRING_CAPACITY;
        return new_str;
    }
    
    string_t* string_from_chars(const char* str){
        const unsigned long long length = strlen(str);
        const unsigned long long capacity = umax(next_power_of_2(length), MIN_STRING_CAPACITY);
        char* new_chars = malloc(capacity*sizeof(char));
        strncpy(new_chars, str, capacity);
        string_t* new_str = malloc(sizeof(string_t));
        new_str->str = new_chars;
        new_str->size = length;
        new_str->capacity = capacity;
        return new_str;
    }
    
    char* string_cpy_to_chars(const string_t* str){
        char* new_chars = malloc(((str->size)+1)*sizeof(char));
        for(unsigned long long i = 0; i < str->size; ++i){
            new_chars[i] = str->str[i];
        }
        new_chars[str->size] = '\0';
    
        return new_chars;
    }
    
    string_t* string_copy(const string_t* str){
        string_t* new_str = string_new();
        char* chars = malloc((str->capacity)*sizeof(char));
        for(unsigned long long i = 0; i < str->size; ++i){
            chars[i] = str->str[i];
        }
        new_str->str = chars;
        new_str->capacity = str->capacity;
        new_str->size = str->size;
        return new_str;
    }
    
    const char* string_cstr(string_t* str){
        string_set_min_capacity(str, str->size+1);
        str->str[str->size] = '\0';
        return str->str;
    }
    
    unsigned long long string_get_size(const string_t* str){
        return str->size;
    }
    
    unsigned long long string_get_capacity(const string_t* str){
        return str->capacity;
    }
    
    void string_set_min_capacity(string_t* str, const unsigned long long size){
        if(size > str->capacity){
            char* new_str = realloc(str->str, size*sizeof(char));
            if(new_str==NULL){
                exit(2);
            }
            str->str = new_str;
            str->capacity = size;    
        }
        return;
    }
    
    void string_append(string_t* dest, const string_t* source){
        const unsigned long long dest_size = dest->size;
        const unsigned long long source_size = source->size;
        string_set_min_capacity(dest, umax(next_power_of_2(dest_size+source_size), MIN_STRING_CAPACITY));
        for(unsigned long long i = 0; i < source_size; ++i){
            dest->str[dest_size+i] = source->str[i];
        }
        dest->size = dest_size+source_size;
        return;
    }
    
    void string_append_char(string_t* dest, const char c){
        const unsigned long long size = dest->size;
        string_set_min_capacity(dest, umax(next_power_of_2(size+1), MIN_STRING_CAPACITY));
        dest->str[size] = c;
        dest->size = size+1;
        return;
    }
    
    void string_append_chars(string_t* dest, const char* source){
        string_t* temp = string_from_chars(source);
        string_append(dest, temp);
        string_free(temp);
        return;
    }
    
    void string_print(const string_t* str){
        for(unsigned long long i = 0; i < str->size; ++i){
            printf("%c", str->str[i]);
        }
        return;
    }
    
    string_t* string_substr(const string_t* str, const unsigned long long position, const unsigned long long length){
        string_t* new_str = string_new();
        if(position >= str->size){
            return new_str;
        }
        unsigned long long actual_size = min(length, str->size - position);
        string_set_min_capacity(new_str, umax(next_power_of_2(actual_size), MIN_STRING_CAPACITY));
        for(unsigned long long i = 0; i < actual_size; ++i){
            new_str->str[i] = str->str[position+i];
        }
        new_str->size = actual_size;
        return new_str;
    }
    
    void string_erase(string_t* str, const unsigned long long position, const unsigned long long length){
        if(position >= str->size){
            return;
        }
        unsigned long long actual_size = min(length, str->size - position);
        char* cpy = string_cpy_to_chars(str);
    
        for(unsigned long long i = 0; i < position; ++i){
            str->str[i] = cpy[i];
        }
        for(unsigned long long i = position + actual_size; i < str->size; ++i){
            str->str[i-actual_size] = cpy[i];
        }
        str->size -= actual_size;
        free(cpy);
        return;
    }
    
    void string_clear(string_t* str){
        str->size = 0;
    }
    
    void string_free(string_t* str){
        //According to valgrind strings made from string_copy aren't free'd correctly, but everything I tested seemed like it free'd correctly. Must be a valgrind bug...
        free(str->str);
        free(str);
        return;
    }
    
    stringlib.h ASCII text
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    #ifndef H_STRINGLIB
    
    #define H_STRINGLIB
    
    #define MIN_STRING_CAPACITY 64
    
    typedef struct string string_t;
    
    string_t* string_new();
    
    string_t* string_from_chars(const char* str);
    
    char* string_cpy_to_chars(const string_t* str);
    
    string_t* string_copy(const string_t* str);
    
    const char* string_cstr(string_t* str);
    
    unsigned long long string_get_size(const string_t* str);
    
    unsigned long long string_get_capacity(const string_t* str);
    
    void string_set_min_capacity(string_t* str, const unsigned long long size);
    
    void string_append(string_t* dest, const string_t* source);
    
    void string_append_char(string_t* dest, const char c);
    
    void string_append_chars(string_t* dest, const char* source);
    
    void string_print(const string_t* str);
    
    string_t* string_substr(const string_t* str, const unsigned long long position, const unsigned long long length);
    
    void string_clear(string_t* str);
    
    void string_erase(string_t* str, const unsigned long long position, const unsigned long long length);
    
    void string_free(string_t* str);
    
    #endif
    
    token.c ASCII text
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    #include <stdlib.h>
    #include <stdio.h>
    #include "token.h"
    
    token_t* token_new_int(int32_t value){
        token_t* new_token = malloc(sizeof(token_t));
        new_token->type = INTEGER;
        new_token->value_i = value;
        return new_token;
    }
    
    token_t* token_new_quote(string_t* value){
        token_t* new_token = malloc(sizeof(token_t));
        new_token->type = QUOTE;
        new_token->value_q = value;
        return new_token;
    }
    
    token_t* token_new_reference(char value){
        token_t* new_token = malloc(sizeof(token_t));
        new_token->type = REFERENCE;
        new_token->value_r = value;
        return new_token;
    }
    
    token_t* token_copy(token_t* tok){
        token_t* new_token = malloc(sizeof(token_t));
        int type = tok->type;
        new_token->type = type;
        switch(type){
            case INTEGER:
                new_token->value_i = tok->value_i;
                break;
            case REFERENCE:
                new_token->value_r = tok->value_r;
                break;
            case QUOTE:
                new_token->value_q = string_copy(tok->value_q);
                break;
            default:
                exit(3);
        }
        return new_token;
    }
    
    void token_print(const token_t* tok){
        switch(tok->type){
            case INTEGER:
                printf("INTEGER[%d]", tok->value_i);
                break;
            case QUOTE:
                printf("QUOTE[\"%s\"]", string_cstr(tok->value_q));
                break;
            case REFERENCE:
                printf("REFERENCE['%c']", tok->value_r);
                break;
            default:
                (void)0;
        }
        return;
    }
    
    void token_full_free(token_t* tok){
        if(tok->type == QUOTE){
            string_free(tok->value_q);
        }
        free(tok);
    }
    
    void token_free(token_t* tok){
        free(tok);
    }
    
    token.h ASCII text
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    #ifndef H_TOKEN
    
    #define H_TOKEN
    #include <stdint.h>
    #include "stringlib.h"
    
    
    #define INTEGER 0
    #define QUOTE 1
    #define REFERENCE 2
    
    typedef struct token
    {
        int type;
        union{
            int32_t value_i;
            string_t* value_q;
            char value_r;
        };
    } token_t;
    
    token_t* token_new_int(int32_t value);
    
    token_t* token_new_quote(string_t* value);
    
    token_t* token_new_reference(char value);
    
    token_t* token_copy(token_t* tok);
    
    void token_print(const token_t* tok);
    
    void token_full_free(token_t* tok);
    
    void token_free(token_t* tok);
    
    #endif
    
    tokenstack.c ASCII text
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    #include <stdlib.h>
    #include <stdio.h>
    #include "token.h"
    #include "tokenstack.h"
    #include "utils.h"
    
    typedef struct stack{
        token_t** tokens;
        unsigned long long size;
        unsigned long long capacity;
    } stack_t;
    
    stack_t* stack_new(){
        stack_t* new_stack = malloc(sizeof(stack_t));
        new_stack->tokens = malloc(MIN_STACK_CAPACITY*sizeof(token_t));
        new_stack->size = 0;
        new_stack->capacity = MIN_STACK_CAPACITY;
        return new_stack;
    }
    
    token_t** stack_get_raw(const stack_t* stck){
        return stck->tokens;
    }
    
    unsigned long long stack_get_size(const stack_t* stck){
        return stck->size;
    }
    
    unsigned long long stack_get_capacity(const stack_t* stck){
        return stck->capacity;
    }
    
    void stack_set_min_capacity(stack_t* stck, const unsigned long long size){
        if(size > stck->capacity){
            token_t** new_tokens = realloc(stck->tokens, size*(sizeof(size_t*)));
            if(new_tokens==NULL){
                exit(2);
            }
            stck->tokens = new_tokens;
            stck->capacity = size;
        }
        return;
    }
    
    void stack_push(stack_t* stck, token_t* tok){
        const unsigned long long size = stck->size;
        stack_set_min_capacity(stck, umax(next_power_of_2(size+1), MIN_STACK_CAPACITY));
        stck->tokens[size] = tok;
        stck->size = size+1;
        return;
    }
    
    token_t* stack_pop(stack_t* stck){
        if(stck->size == 0){
            printf("\nUNDEFINED BEHAVIOUR - Stack has been pop'd while being empty - Exiting...\n");
            exit(4);
        }
        stck->size = stck->size-1;
        return stck->tokens[stck->size];
    }
    
    token_t* stack_access(stack_t* stck, const unsigned long long index){
        if(index >= stck->size){
            printf("\nUNDEFINED BEHAVIOUR - Stack access out of bounds (stacksize: %llu, index: %llu) - Exiting...\n", stck->size, index);
            exit(4);
        }
        return stck->tokens[index];
    }
    
    token_t* stack_raccess(stack_t* stck, const unsigned long long index){
        if(index >= stck->size){
            printf("\nUNDEFINED BEHAVIOUR - Stack raccess out of bounds (stacksize: %llu, index: %llu) - Exiting...\n", stck->size, index);
            exit(4);
        }
        return stck->tokens[stck->size - 1 - index];
    }
    
    void stack_print(const stack_t* stck){
        printf("[");
        for(unsigned long long i = 0; i < stck->size; ++i){
            token_print(stck->tokens[i]);
            printf(", ");
        }
        printf("]");
        return;
    }
    
    void stack_free(stack_t* stck){
        for(unsigned long long i = 0; i < stck->size; ++i){
            token_full_free(stck->tokens[i]);
        }
        free(stck->tokens);
        free(stck);
        return;
    }
    
    tokenstack.h ASCII text
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    #ifndef H_TOKENSTACK
    
    #define H_TOKENSTACK
    
    #include "token.h"
    #define MIN_STACK_CAPACITY 64
    
    typedef struct stack stack_t;
    
    stack_t* stack_new();
    
    token_t** stack_get_raw(const stack_t* stck);
    
    unsigned long long stack_get_size(const stack_t* stck);
    
    unsigned long long stack_get_capacity(const stack_t* stck);
    
    void stack_set_min_capacity(stack_t* stck, const unsigned long long size);
    
    void stack_push(stack_t* stck, token_t* tok);
    
    token_t* stack_pop(stack_t* stck);
    
    token_t* stack_access(stack_t* stck, const unsigned long long index);
    
    token_t* stack_raccess(stack_t* stck, const unsigned long long index);
    
    void stack_print(const stack_t* stck);
    
    void stack_free(stack_t* stck);
    #endif
    
    utils.c ASCII text
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    #include <math.h>
    #include "utils.h"
    
    long long min(long long value1, long long value2){
        if(value2 >= value1){
            return value1;
        }
        else{
            return value2;
        }
    }
    
    unsigned long long umin(unsigned long long value1, unsigned long long value2){
        if(value2 >= value1){
            return value1;
        }
        else{
            return value2;
        }
    }
    
    long long max(long long value1, long long value2){
        if(value2 > value1){
            return value2;
        }
        else{
            return value1;
        }
    }
    
    unsigned long long umax(unsigned long long value1, unsigned long long value2){
        if(value2 > value1){
            return value2;
        }
        else{
            return value1;
        }
    }
    
    unsigned long long next_power_of_2(unsigned long long num){
        return powl(2, ceill(log2l(num)));
    }
    
    utils.h ASCII text
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    #ifndef H_UTILS
    #define H_UTILS
    
    long long min(long long value1, long long value2);
    unsigned long long umin(unsigned long long value1, unsigned long long value2);
    
    long long max(long long value1, long long value2);
    unsigned long long umax(unsigned long long value1, unsigned long long value2);
    
    unsigned long long next_power_of_2(unsigned long long num);
    
    #endif
    

    entry #9

    written by Olive
    submitted at
    1 like

    guesses
    comments 0

    post a comment


    false.ml ASCII text
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    (*
      An implementation of a FALSE variant by OliveIsAWord in MiniML:
      https://github.com/pithlessly/miniml
      
      To run MiniML, please ask me or GnuRadioShows for an unvetted Scheme file
      with which to execute this program and/or bootstrap the compiler (or just
      adapt this code to the ML of your choice :3).
      
      This implementation is, by some metrics, performant. On my computer with an
      AMD Ryzen 7 5800X 8-Core Processor, the following program takes ~18 seconds
      to execute:
      ```false
      [$ 1 > [1- $ f;! \ 1- f;! +]?]f:
      33 f;! . {compute & print 33th fibonacci number}
      ```
      
      This program requires the files "olive.false" and "olive.stdin" in the cwd.
    *)
    
    let source_code_filepath = "olive.false"
    let stdin_filepath = "olive.stdin"
    
    let false_true = 0 - 1
    let false_false = 0
    let bit_width = 32
    
    let index_of_var c: int = int_of_char c - int_of_char 'a'
    let var_of_index i: char = char_of_int (i + int_of_char 'a')
    
    let false_parse_error msg =
      prerr_endline ("FALSE parse error: " ^ msg);
      exit 1  
    
    let false_eval_error msg =
      prerr_endline ("FALSE eval error: " ^ msg);
      exit 1
    
    let internal_panic msg =
      prerr_endline ("internal error: " ^ msg);
      prerr_endline "ya girlie olive screwed up :pleading_face:";
      exit 1
      
    let _todo () = internal_panic "todo"
    
    let xor a b = match (a, b) with
    | (true, true) | (false, false) -> false
    | _ -> true
    
    let (--) i j = 
        let rec aux n acc =
          if n < i then acc else aux (n-1) (n :: acc)
        in aux (j - 1) []
        
    let rec list_find elem list = match list with
    | [] -> false
    | x :: xs -> if x = elem then true else list_find elem xs
     
    let rec list_get list i = match list with
    | [] -> false_eval_error "stack_underflow"
    | x :: xs -> if i = 0 then x else list_get xs (i - 1)
    
    let list_take list n =
      let rec aux list n acc = if n = 0 then (acc, list) else match list with
      | [] -> false_eval_error "stack_underflow"
      | x :: xs -> aux xs (n - 1) (x :: acc)
      in aux list n []
    
    let get_or str i =
      if i < String.length str then Some (String.get str i) else None
      
    let option_map_or f default x = match x with
    | Some x -> f x
    | None -> default
    
    let option_unwrap_or_else f x = match x with
    | Some x -> x
    | None -> f ()
        
    let rec do_n n f =
      if n > 0 then f (); do_n (n - 1) f else ()
      
    let rec while condition body =
      if condition () then body (); while condition body else ()
    
    let sign x = x < 0
    let flip_sign_if b x = if b then 0 - x else x
    let abs x = flip_sign_if (sign x) x
    
    let mul x y =
      let product = ref 0 in
      let (a, b) = if abs x < abs y then (x, y) else (y, x) in
      do_n (abs a) (fun () -> product := (b + deref product));
      let mag = deref product in
      flip_sign_if (sign a) mag
      
    let pow base power =
      let value = ref 1 in
      do_n power (fun () -> value := (mul base (deref value)));
      deref value
    
    let div divisor dividend =
      if divisor = 0 then
       false_eval_error (
          "division by zero: " ^
          string_of_int dividend ^
          " / " ^
          string_of_int divisor)
      else ();
      let x = ref (abs dividend) in
      let y = abs divisor in
      let mag = ref 0 in
      while (fun () -> deref x >= y) (fun () ->
        x := (deref x - y);
        mag := (deref mag + 1)
      );
      flip_sign_if (xor (sign dividend) (sign divisor)) (deref mag)
    
    let int_cap = pow 2 bit_width
    let signed_cap = pow 2 (bit_width - 1)
      
    let bits_of_int i: bool list = 
      let i = if i >= 0 then i else int_cap - i in
      snd (List.fold_right (fun bit (x, acc) ->
        let mask = pow 2 bit in
        let new_bit = x >= mask in
        let new_x = if new_bit then x - mask else x in
        (new_x, new_bit :: acc)
      ) (0 -- bit_width) (i, []))
    
    let int_of_bits bs: int =
      List.fold_right (fun bit n ->
        let bit = if bit then 1 else 0 in
        n + n + bit
      ) bs 0
      
    let string_of_bits bs: string =
      String.concat "" (List.map (fun b -> if b then "1" else "0") bs)
    
    let wrap_int i: int =
      let rec wrap_neg i = if i >= 0 then i else wrap_neg (i + int_cap) in
      let rec wrap_pos i = if i < signed_cap then i else wrap_pos (i - int_cap) in
      wrap_pos (wrap_neg i)
      
    let string_of_char = String.make 1
      
    let char_list_of_string str =
      let indices: int list = 0 -- String.length str in
      (List.map) (String.get str) indices
      
    type token =
    | PushInt of int
    | PushChar of int
    | PrintString of string
    | PushQuote of token list
    | PushVar of int
    | Instruction of char
    
    let rec string_of_token_partial token int_prev = match token with
    | PushInt i -> (if int_prev then " " else "") ^ string_of_int i
    | PushChar i -> "'" ^ string_of_char (char_of_int i)
    | PrintString s -> "\"" ^ s ^ "\""
    | PushQuote tokens -> string_of_quote tokens
    | PushVar v -> string_of_char (var_of_index v)
    | Instruction c -> string_of_char c
    and string_of_token token = string_of_token_partial token false
    and string_of_tokens tokens = 
      let rec aux acc int_prev tokens = match tokens with
      | [] -> acc
      | x :: xs ->
        let to_str = string_of_token_partial x int_prev in
        let is_int = match x with | PushInt _ -> true | _ -> false 
        in aux (to_str :: acc) is_int xs
      in String.concat "" (List.rev (aux [] false tokens))
    and string_of_quote tokens = "[" ^ string_of_tokens tokens ^ "]"
    
    type value =
    | Int of int
    | Ref of int
    | Quote of token list
    
    let string_of_value value = match value with
    | Int i -> string_of_int i
    | Ref v -> string_of_char (var_of_index v)
    | Quote q -> string_of_quote q
    
    let bad_type expected value = false_eval_error (
      "expected type " ^ 
      expected ^ 
      ", found " ^
      string_of_value value)
    
    let read_to_string filepath =
      let f = In_channel.open_text filepath in
      let text = In_channel.input_all f in
      In_channel.close f;
      text
    
    let src = read_to_string source_code_filepath
    let stdin = ref (char_list_of_string (read_to_string stdin_filepath))
    let stdout = ref []
    let stack = ref []
    
    let pop (* :flushed: *) () = match deref stack with
    | [] -> false_eval_error "stack underflow"
    | x :: xs -> stack := xs; x
    let pop_int () = match pop () with
    | Int a -> a
    | x -> bad_type "int" x
    let pop_ref () = match pop () with
    | Ref a -> a
    | x -> bad_type "variable reference" x
    let pop_quote () = match pop () with
    | Quote a -> a
    | x -> bad_type "quote" x
    let pop_bool () = pop_int () <> false_false
    
    let push x = stack := (x :: deref stack)
    
    let stack_debug () =
      let reprs = List.map string_of_value (deref stack) in
      let ordered = List.rev reprs in
      let pretty = "(" ^ String.concat ", " ordered ^ ")" in
      print_endline pretty
    
    let stack_index i =
      if i < 0 then
       false_eval_error ("executed `O` with negative index" ^ string_of_int i)
      else ();
      list_get (deref stack) i
    
    let stack_manip n map =
      let (top, rest): (value list * value list) = list_take (deref stack) n in
      let new_top = List.fold_left (fun acc i ->
        let index = n - 1 - (int_of_string (String.sub map i 1)) in
        let elem = list_get top index in
        elem :: acc
      ) [] (0 -- String.length map) in
      stack := (new_top @ rest)
    
    let int1 f =
      let x = pop_int () in
      push (Int (wrap_int (f x)))
    
    let int2 f =
      let rhs = pop_int () in
      let lhs = pop_int () in
      push (Int (wrap_int (f lhs rhs)))
    
    let bitwise2 f =
      let rhs = bits_of_int (pop_int ()) in
      let lhs = bits_of_int (pop_int ()) in
      push (Int (int_of_bits (List.map2 f lhs rhs)))
    
    let push_digits str = stack := (Int (int_of_string str) :: deref stack)
    
    let false_print str = stdout := (str :: deref stdout)
    
    let is_digit c = Char.('0' <= c && c <= '9')
    let is_var c = Char.('a' <= c && c <= 'z')
    let is_instruction c =
      let instructions = char_list_of_string (";:$%\\@O+-*/_&|~=>!?#^,.B" ^ "Q")
      in list_find c instructions 
    
    let variable_map: value option ref list = List.map (fun _ -> ref None) (0 -- 26)
      
    let get_var i = match deref (list_get variable_map i) with
    | Some value -> value
    | None -> false_eval_error (
      "accessed uninitialized variable " ^
      string_of_char (var_of_index i))
    let set_var var v =
      let target = var in
      let i = ref (0 - 1) in
      List.iter
        (fun var_ref ->
          i := (deref i) + 1;
          if deref i = target then var_ref := Some v else ())
        variable_map
    let lex str: token list =
      let rec lex_partial str: (token list) * (string option) =
        let rec aux acc str =
          let skip i = String.sub str i (String.length str - i) in
          if String.length str = 0 then
            (acc, None)
          else match String.get str 0 with
          | ' ' | '\n' | '\r' -> aux acc (skip 1)
          | '{' ->
            let i = ref 1 in
            while (fun () -> option_map_or
              (fun x -> x <> '}')
              false
              (get_or str (deref i)))
                (fun () -> i := (deref i + 1));
            let i = deref i in
            if i >= String.length str then
              false_parse_error "unclosed `{`"
            else ();
            aux acc (skip (i + 1))
          | '}' -> false_parse_error "trailing `}`"
          | '\'' -> (match get_or str 1 with
            | None -> false_parse_error "Expected character after `'`"
            | Some c -> aux (PushChar (int_of_char c) :: acc) (skip 2))
          | '"' ->
            let i = ref 1 in
            while (fun () -> option_map_or
              (fun x -> x <> '"')
              false
              (get_or str (deref i)))
                (fun () -></