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. 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)
  5. 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)
  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 () -> i := (deref i + 1));
            let i = deref i in
            if i >= String.length str then
              false_parse_error "unclosed `\"`"
            else ();
            let str_span = String.sub str 1 (i - 1) in
            aux ((PrintString str_span) :: acc) (skip (i + 1))
          | '[' ->
            let (quote_tokens, rest) = lex_partial (skip 1) in
            let rest = option_unwrap_or_else
              (fun () -> false_parse_error "unclosed `[`")
              rest
            in aux ((PushQuote quote_tokens) :: acc) rest
          | ']' -> (acc, Some (skip 1))
          | '`' -> false_parse_error "the ` instruction is not supported"
          | c ->
            if int_of_char c = 9 then
              (* hiii christine add \t support please :pleading_face: *)
              aux acc (skip 1)
            else if is_digit c then
              let i = ref 1 in 
              while (fun () -> option_map_or is_digit false (get_or str (deref i)))
                (fun () -> i := (deref i + 1));
              let i = deref i in
              let digits = String.sub str 0 i in
              let int_token = PushInt (int_of_string digits) in
              aux (int_token :: acc) (skip i)
            else if is_var c then
              let var_token = PushVar (index_of_var c) in
              aux (var_token :: acc) (skip 1)
            else if is_instruction c then
              aux (Instruction c :: acc) (skip 1)
            else false_parse_error (
              "unexpected character `" ^
              (string_of_char c) ^
              "`")
        in let (tokens, rest) = aux [] str in (List.rev tokens, rest)
      in fst (lex_partial str)
      
    let rec eval_op op = match op with
    | PushInt i | PushChar i -> push (Int (wrap_int i))
    | PrintString s -> false_print s
    | PushQuote quote -> push (Quote quote)
    | PushVar v -> push (Ref v)
    | Instruction c -> match c with
    | 'Q' -> stack_debug ()
    | ';' -> push (get_var (pop_ref ()))
    | ':' ->
      let var = pop_ref () in
      let value = pop () in
      set_var var value
    | '$' -> stack_manip 1 "00"
    | '%' -> stack_manip 1 ""
    | '\\' -> stack_manip 2 "01"
    | '@' -> stack_manip 3 "102"
    | 'O' ->
      let i = pop_int () in
      push (stack_index i)
    | '+' -> int2 (+)
    | '-' -> int2 (-)
    | '*' -> int2 mul
    | '/' -> int2 div
    | '_' -> int1 (fun x -> 0 - x)
    | '&' -> bitwise2 (&&)
    | '|' -> bitwise2 (||)
    | '~' -> int1 (fun x -> (0 - 1) - x)
    | '=' -> int2 (fun x y -> if x = y then false_true else false_false)
    | '>' -> int2 (fun x y -> if x > y then false_true else false_false)
    | '!' -> eval (pop_quote ())
    | '?' ->
      let quote = pop_quote () in
      if pop_bool () then eval quote else ()
    | '#' -> 
      let body = pop_quote () in
      let condition = pop_quote () in
      while (fun () -> eval condition; pop_bool ())
        (fun () -> eval body)
    | '^' ->
      let code_point = match deref stdin with
      | [] -> 0 - 1
      | x :: xs -> stdin := xs; int_of_char x
      in push (Int code_point)
    | ',' -> false_print (String.make 1 (char_of_int (pop_int ())))
    | '.' -> false_print (string_of_int (pop_int ()))
    | 'B' -> ()
    | c -> internal_panic ("bad instruction `" ^ string_of_char c ^ "`")
    and eval code = List.iter eval_op code
      
    let () =
      let code = lex src in
      eval code;
      print_endline (String.concat "" (List.rev (deref stdout)));
      ()
    

    entry #10

    written by taswelll
    submitted at
    0 likes

    guesses
    comments 0

    post a comment


    dir cg41
    Cargo.lock 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
     675
     676
     677
     678
     679
     680
     681
     682
     683
     684
     685
     686
     687
     688
     689
     690
     691
     692
     693
     694
     695
     696
     697
     698
     699
     700
     701
     702
     703
     704
     705
     706
     707
     708
     709
     710
     711
     712
     713
     714
     715
     716
     717
     718
     719
     720
     721
     722
     723
     724
     725
     726
     727
     728
     729
     730
     731
     732
     733
     734
     735
     736
     737
     738
     739
     740
     741
     742
     743
     744
     745
     746
     747
     748
     749
     750
     751
     752
     753
     754
     755
     756
     757
     758
     759
     760
     761
     762
     763
     764
     765
     766
     767
     768
     769
     770
     771
     772
     773
     774
     775
     776
     777
     778
     779
     780
     781
     782
     783
     784
     785
     786
     787
     788
     789
     790
     791
     792
     793
     794
     795
     796
     797
     798
     799
     800
     801
     802
     803
     804
     805
     806
     807
     808
     809
     810
     811
     812
     813
     814
     815
     816
     817
     818
     819
     820
     821
     822
     823
     824
     825
     826
     827
     828
     829
     830
     831
     832
     833
     834
     835
     836
     837
     838
     839
     840
     841
     842
     843
     844
     845
     846
     847
     848
     849
     850
     851
     852
     853
     854
     855
     856
     857
     858
     859
     860
     861
     862
     863
     864
     865
     866
     867
     868
     869
     870
     871
     872
     873
     874
     875
     876
     877
     878
     879
     880
     881
     882
     883
     884
     885
     886
     887
     888
     889
     890
     891
     892
     893
     894
     895
     896
     897
     898
     899
     900
     901
     902
     903
     904
     905
     906
     907
     908
     909
     910
     911
     912
     913
     914
     915
     916
     917
     918
     919
     920
     921
     922
     923
     924
     925
     926
     927
     928
     929
     930
     931
     932
     933
     934
     935
     936
     937
     938
     939
     940
     941
     942
     943
     944
     945
     946
     947
     948
     949
     950
     951
     952
     953
     954
     955
     956
     957
     958
     959
     960
     961
     962
     963
     964
     965
     966
     967
     968
     969
     970
     971
     972
     973
     974
     975
     976
     977
     978
     979
     980
     981
     982
     983
     984
     985
     986
     987
     988
     989
     990
     991
     992
     993
     994
     995
     996
     997
     998
     999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    1201
    1202
    1203
    1204
    1205
    1206
    1207
    1208
    1209
    1210
    1211
    1212
    1213
    1214
    1215
    1216
    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    1228
    1229
    1230
    1231
    1232
    1233
    1234
    1235
    1236
    1237
    1238
    1239
    1240
    1241
    1242
    1243
    1244
    1245
    1246
    1247
    1248
    1249
    1250
    1251
    1252
    1253
    1254
    1255
    1256
    1257
    1258
    1259
    1260
    1261
    1262
    1263
    1264
    1265
    1266
    1267
    1268
    1269
    1270
    1271
    1272
    1273
    1274
    1275
    1276
    1277
    1278
    1279
    1280
    1281
    1282
    1283
    1284
    1285
    1286
    1287
    1288
    1289
    1290
    1291
    1292
    1293
    1294
    1295
    1296
    1297
    1298
    1299
    1300
    1301
    1302
    1303
    1304
    1305
    1306
    1307
    1308
    1309
    1310
    1311
    1312
    1313
    1314
    1315
    1316
    1317
    1318
    1319
    1320
    1321
    1322
    1323
    1324
    1325
    1326
    1327
    1328
    1329
    1330
    1331
    1332
    1333
    1334
    1335
    1336
    1337
    1338
    1339
    1340
    1341
    1342
    1343
    1344
    1345
    1346
    1347
    1348
    1349
    1350
    1351
    1352
    1353
    1354
    1355
    1356
    1357
    1358
    1359
    1360
    1361
    1362
    1363
    1364
    1365
    1366
    1367
    1368
    1369
    1370
    1371
    1372
    1373
    1374
    1375
    1376
    1377
    1378
    1379
    1380
    1381
    1382
    1383
    1384
    1385
    1386
    1387
    1388
    1389
    1390
    1391
    1392
    1393
    1394
    1395
    1396
    1397
    1398
    1399
    1400
    1401
    1402
    1403
    1404
    1405
    1406
    1407
    1408
    1409
    1410
    1411
    1412
    1413
    1414
    1415
    1416
    1417
    1418
    1419
    1420
    1421
    1422
    1423
    1424
    1425
    1426
    1427
    1428
    1429
    1430
    1431
    1432
    1433
    1434
    1435
    1436
    1437
    1438
    1439
    1440
    1441
    1442
    1443
    1444
    1445
    1446
    1447
    1448
    1449
    1450
    1451
    1452
    1453
    1454
    1455
    1456
    1457
    1458
    1459
    1460
    1461
    1462
    1463
    1464
    1465
    1466
    1467
    1468
    1469
    1470
    1471
    1472
    1473
    1474
    1475
    1476
    1477
    1478
    1479
    1480
    1481
    1482
    1483
    1484
    1485
    1486
    1487
    1488
    1489
    1490
    1491
    1492
    1493
    1494
    1495
    1496
    1497
    1498
    1499
    1500
    1501
    1502
    1503
    1504
    1505
    1506
    1507
    1508
    1509
    1510
    1511
    1512
    1513
    1514
    1515
    1516
    1517
    1518
    1519
    1520
    1521
    1522
    1523
    1524
    1525
    1526
    1527
    1528
    1529
    1530
    1531
    1532
    1533
    1534
    1535
    1536
    1537
    1538
    1539
    1540
    1541
    1542
    1543
    1544
    1545
    1546
    1547
    1548
    1549
    1550
    1551
    1552
    1553
    1554
    1555
    1556
    1557
    1558
    1559
    1560
    1561
    1562
    1563
    1564
    1565
    1566
    1567
    1568
    1569
    1570
    1571
    1572
    1573
    1574
    1575
    1576
    1577
    1578
    1579
    1580
    1581
    1582
    1583
    1584
    1585
    1586
    1587
    1588
    1589
    1590
    1591
    1592
    1593
    1594
    1595
    1596
    1597
    1598
    1599
    # This file is automatically @generated by Cargo.
    # It is not intended for manual editing.
    version = 3
    
    [[package]]
    name = "addr2line"
    version = "0.19.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97"
    dependencies = [
     "gimli",
    ]
    
    [[package]]
    name = "ahash"
    version = "0.8.3"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
    dependencies = [
     "cfg-if",
     "once_cell",
     "version_check",
    ]
    
    [[package]]
    name = "aho-corasick"
    version = "1.0.4"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a"
    dependencies = [
     "memchr",
    ]
    
    [[package]]
    name = "anyhow"
    version = "1.0.75"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
    
    [[package]]
    name = "arbitrary"
    version = "1.3.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e"
    
    [[package]]
    name = "async-trait"
    version = "0.1.73"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0"
    dependencies = [
     "proc-macro2",
     "quote",
     "syn 2.0.29",
    ]
    
    [[package]]
    name = "autocfg"
    version = "1.1.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
    
    [[package]]
    name = "base64"
    version = "0.21.2"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d"
    
    [[package]]
    name = "bincode"
    version = "1.3.3"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
    dependencies = [
     "serde",
    ]
    
    [[package]]
    name = "bitflags"
    version = "1.3.2"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
    
    [[package]]
    name = "bitflags"
    version = "2.4.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
    
    [[package]]
    name = "block-buffer"
    version = "0.10.4"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
    dependencies = [
     "generic-array",
    ]
    
    [[package]]
    name = "bumpalo"
    version = "3.13.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1"
    
    [[package]]
    name = "byteorder"
    version = "1.4.3"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
    
    [[package]]
    name = "cc"
    version = "1.0.82"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01"
    dependencies = [
     "jobserver",
     "libc",
    ]
    
    [[package]]
    name = "cfg-if"
    version = "1.0.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
    
    [[package]]
    name = "cpp_demangle"
    version = "0.3.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f"
    dependencies = [
     "cfg-if",
    ]
    
    [[package]]
    name = "cpufeatures"
    version = "0.2.9"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1"
    dependencies = [
     "libc",
    ]
    
    [[package]]
    name = "cranelift-bforest"
    version = "0.98.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "1380172556902242d32f78ed08c98aac4f5952aef22d3684aed5c66a5db0a6fc"
    dependencies = [
     "cranelift-entity",
    ]
    
    [[package]]
    name = "cranelift-codegen"
    version = "0.98.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "037cca234e1ad0766fdfe43b527ec14e100414b4ccf4bb614977aa9754958f57"
    dependencies = [
     "bumpalo",
     "cranelift-bforest",
     "cranelift-codegen-meta",
     "cranelift-codegen-shared",
     "cranelift-control",
     "cranelift-entity",
     "cranelift-isle",
     "gimli",
     "hashbrown 0.13.2",
     "log",
     "regalloc2",
     "smallvec",
     "target-lexicon",
    ]
    
    [[package]]
    name = "cranelift-codegen-meta"
    version = "0.98.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "d375e6afa8b9a304999ea8cf58424414b8e55e004571265a4f0826eba8b74f18"
    dependencies = [
     "cranelift-codegen-shared",
    ]
    
    [[package]]
    name = "cranelift-codegen-shared"
    version = "0.98.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "ca590e72ccb8da963def6e36460cce4412032b1f03c31d1a601838d305abdc39"
    
    [[package]]
    name = "cranelift-control"
    version = "0.98.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "9d2d38eea4373639f4b6236a40f69820fed16c5511093cd3783bf8491a93d9cf"
    dependencies = [
     "arbitrary",
    ]
    
    [[package]]
    name = "cranelift-entity"
    version = "0.98.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "5e3173c1434af23c00e4964722cf93ca8f0e6287289bf5d52110597c3ba2ea09"
    dependencies = [
     "serde",
    ]
    
    [[package]]
    name = "cranelift-frontend"
    version = "0.98.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "aec4a3a33825062eccf6eec73e852c8773220f6e4798925e19696562948beb1f"
    dependencies = [
     "cranelift-codegen",
     "log",
     "smallvec",
     "target-lexicon",
    ]
    
    [[package]]
    name = "cranelift-isle"
    version = "0.98.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "5146b5cea4b21095a021d964b0174cf6ff5530f83e8d0a822683c7559e360b66"
    
    [[package]]
    name = "cranelift-native"
    version = "0.98.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "21cec3717ce554d3936b2101aa8eae1a2a410bd6da0f4df698a4b008fe9cf1e9"
    dependencies = [
     "cranelift-codegen",
     "libc",
     "target-lexicon",
    ]
    
    [[package]]
    name = "cranelift-wasm"
    version = "0.98.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "d7fd2f9f1bf29ce6639ae2f477a2fe20bad0bd09289df13efeb890e8e4b9f807"
    dependencies = [
     "cranelift-codegen",
     "cranelift-entity",
     "cranelift-frontend",
     "itertools",
     "log",
     "smallvec",
     "wasmparser",
     "wasmtime-types",
    ]
    
    [[package]]
    name = "crc32fast"
    version = "1.3.2"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
    dependencies = [
     "cfg-if",
    ]
    
    [[package]]
    name = "crossbeam-channel"
    version = "0.5.8"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200"
    dependencies = [
     "cfg-if",
     "crossbeam-utils",
    ]
    
    [[package]]
    name = "crossbeam-deque"
    version = "0.8.3"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
    dependencies = [
     "cfg-if",
     "crossbeam-epoch",
     "crossbeam-utils",
    ]
    
    [[package]]
    name = "crossbeam-epoch"
    version = "0.9.15"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
    dependencies = [
     "autocfg",
     "cfg-if",
     "crossbeam-utils",
     "memoffset 0.9.0",
     "scopeguard",
    ]
    
    [[package]]
    name = "crossbeam-utils"
    version = "0.8.16"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
    dependencies = [
     "cfg-if",
    ]
    
    [[package]]
    name = "crypto-common"
    version = "0.1.6"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
    dependencies = [
     "generic-array",
     "typenum",
    ]
    
    [[package]]
    name = "debugid"
    version = "0.8.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d"
    dependencies = [
     "uuid",
    ]
    
    [[package]]
    name = "digest"
    version = "0.10.7"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
    dependencies = [
     "block-buffer",
     "crypto-common",
    ]
    
    [[package]]
    name = "directories-next"
    version = "2.0.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc"
    dependencies = [
     "cfg-if",
     "dirs-sys-next",
    ]
    
    [[package]]
    name = "dirs-sys-next"
    version = "0.1.2"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
    dependencies = [
     "libc",
     "redox_users",
     "winapi",
    ]
    
    [[package]]
    name = "either"
    version = "1.9.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
    
    [[package]]
    name = "env_logger"
    version = "0.10.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0"
    dependencies = [
     "humantime",
     "is-terminal",
     "log",
     "regex",
     "termcolor",
    ]
    
    [[package]]
    name = "errno"
    version = "0.3.2"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f"
    dependencies = [
     "errno-dragonfly",
     "libc",
     "windows-sys",
    ]
    
    [[package]]
    name = "errno-dragonfly"
    version = "0.1.2"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
    dependencies = [
     "cc",
     "libc",
    ]
    
    [[package]]
    name = "fallible-iterator"
    version = "0.2.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7"
    
    [[package]]
    name = "file-per-thread-logger"
    version = "0.2.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "8a3cc21c33af89af0930c8cae4ade5e6fdc17b5d2c97b3d2e2edb67a1cf683f3"
    dependencies = [
     "env_logger",
     "log",
    ]
    
    [[package]]
    name = "form_urlencoded"
    version = "1.2.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652"
    dependencies = [
     "percent-encoding",
    ]
    
    [[package]]
    name = "fxhash"
    version = "0.2.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
    dependencies = [
     "byteorder",
    ]
    
    [[package]]
    name = "fxprof-processed-profile"
    version = "0.6.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "27d12c0aed7f1e24276a241aadc4cb8ea9f83000f34bc062b7cc2d51e3b0fabd"
    dependencies = [
     "bitflags 2.4.0",
     "debugid",
     "fxhash",
     "serde",
     "serde_json",
    ]
    
    [[package]]
    name = "generic-array"
    version = "0.14.7"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
    dependencies = [
     "typenum",
     "version_check",
    ]
    
    [[package]]
    name = "getrandom"
    version = "0.2.10"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
    dependencies = [
     "cfg-if",
     "libc",
     "wasi",
    ]
    
    [[package]]
    name = "gimli"
    version = "0.27.3"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e"
    dependencies = [
     "fallible-iterator",
     "indexmap",
     "stable_deref_trait",
    ]
    
    [[package]]
    name = "hashbrown"
    version = "0.12.3"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
    
    [[package]]
    name = "hashbrown"
    version = "0.13.2"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
    dependencies = [
     "ahash",
    ]
    
    [[package]]
    name = "heck"
    version = "0.4.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
    
    [[package]]
    name = "hermit-abi"
    version = "0.3.2"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
    
    [[package]]
    name = "humantime"
    version = "2.1.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
    
    [[package]]
    name = "id-arena"
    version = "2.2.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005"
    
    [[package]]
    name = "idna"
    version = "0.4.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c"
    dependencies = [
     "unicode-bidi",
     "unicode-normalization",
    ]
    
    [[package]]
    name = "indexmap"
    version = "1.9.3"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
    dependencies = [
     "autocfg",
     "hashbrown 0.12.3",
     "serde",
    ]
    
    [[package]]
    name = "io-lifetimes"
    version = "1.0.11"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
    dependencies = [
     "hermit-abi",
     "libc",
     "windows-sys",
    ]
    
    [[package]]
    name = "is-terminal"
    version = "0.4.9"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
    dependencies = [
     "hermit-abi",
     "rustix 0.38.8",
     "windows-sys",
    ]
    
    [[package]]
    name = "itertools"
    version = "0.10.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
    dependencies = [
     "either",
    ]
    
    [[package]]
    name = "itoa"
    version = "1.0.9"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
    
    [[package]]
    name = "ittapi"
    version = "0.3.4"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "41e0d0b7b3b53d92a7e8b80ede3400112a6b8b4c98d1f5b8b16bb787c780582c"
    dependencies = [
     "anyhow",
     "ittapi-sys",
     "log",
    ]
    
    [[package]]
    name = "ittapi-sys"
    version = "0.3.4"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "f2f8763c96e54e6d6a0dccc2990d8b5e33e3313aaeae6185921a3f4c1614a77c"
    dependencies = [
     "cc",
    ]
    
    [[package]]
    name = "jobserver"
    version = "0.1.26"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2"
    dependencies = [
     "libc",
    ]
    
    [[package]]
    name = "jstack"
    version = "0.1.0"
    dependencies = [
     "anyhow",
     "wasmtime",
    ]
    
    [[package]]
    name = "leb128"
    version = "0.2.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67"
    
    [[package]]
    name = "libc"
    version = "0.2.147"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
    
    [[package]]
    name = "linux-raw-sys"
    version = "0.3.8"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
    
    [[package]]
    name = "linux-raw-sys"
    version = "0.4.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503"
    
    [[package]]
    name = "log"
    version = "0.4.20"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
    
    [[package]]
    name = "mach"
    version = "0.3.2"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa"
    dependencies = [
     "libc",
    ]
    
    [[package]]
    name = "memchr"
    version = "2.5.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
    
    [[package]]
    name = "memfd"
    version = "0.6.3"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e"
    dependencies = [
     "rustix 0.37.23",
    ]
    
    [[package]]
    name = "memoffset"
    version = "0.8.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1"
    dependencies = [
     "autocfg",
    ]
    
    [[package]]
    name = "memoffset"
    version = "0.9.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
    dependencies = [
     "autocfg",
    ]
    
    [[package]]
    name = "num_cpus"
    version = "1.16.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
    dependencies = [
     "hermit-abi",
     "libc",
    ]
    
    [[package]]
    name = "object"
    version = "0.30.4"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385"
    dependencies = [
     "crc32fast",
     "hashbrown 0.13.2",
     "indexmap",
     "memchr",
    ]
    
    [[package]]
    name = "once_cell"
    version = "1.18.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
    
    [[package]]
    name = "paste"
    version = "1.0.14"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
    
    [[package]]
    name = "percent-encoding"
    version = "2.3.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94"
    
    [[package]]
    name = "pkg-config"
    version = "0.3.27"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
    
    [[package]]
    name = "ppv-lite86"
    version = "0.2.17"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
    
    [[package]]
    name = "proc-macro2"
    version = "1.0.66"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
    dependencies = [
     "unicode-ident",
    ]
    
    [[package]]
    name = "psm"
    version = "0.1.21"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874"
    dependencies = [
     "cc",
    ]
    
    [[package]]
    name = "pulldown-cmark"
    version = "0.8.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8"
    dependencies = [
     "bitflags 1.3.2",
     "memchr",
     "unicase",
    ]
    
    [[package]]
    name = "quote"
    version = "1.0.33"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
    dependencies = [
     "proc-macro2",
    ]
    
    [[package]]
    name = "rand"
    version = "0.8.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
    dependencies = [
     "libc",
     "rand_chacha",
     "rand_core",
    ]
    
    [[package]]
    name = "rand_chacha"
    version = "0.3.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
    dependencies = [
     "ppv-lite86",
     "rand_core",
    ]
    
    [[package]]
    name = "rand_core"
    version = "0.6.4"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
    dependencies = [
     "getrandom",
    ]
    
    [[package]]
    name = "rayon"
    version = "1.7.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b"
    dependencies = [
     "either",
     "rayon-core",
    ]
    
    [[package]]
    name = "rayon-core"
    version = "1.11.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d"
    dependencies = [
     "crossbeam-channel",
     "crossbeam-deque",
     "crossbeam-utils",
     "num_cpus",
    ]
    
    [[package]]
    name = "redox_syscall"
    version = "0.2.16"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
    dependencies = [
     "bitflags 1.3.2",
    ]
    
    [[package]]
    name = "redox_users"
    version = "0.4.3"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
    dependencies = [
     "getrandom",
     "redox_syscall",
     "thiserror",
    ]
    
    [[package]]
    name = "regalloc2"
    version = "0.9.2"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "5b4dcbd3a2ae7fb94b5813fa0e957c6ab51bf5d0a8ee1b69e0c2d0f1e6eb8485"
    dependencies = [
     "hashbrown 0.13.2",
     "log",
     "rustc-hash",
     "slice-group-by",
     "smallvec",
    ]
    
    [[package]]
    name = "regex"
    version = "1.9.3"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a"
    dependencies = [
     "aho-corasick",
     "memchr",
     "regex-automata",
     "regex-syntax",
    ]
    
    [[package]]
    name = "regex-automata"
    version = "0.3.6"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69"
    dependencies = [
     "aho-corasick",
     "memchr",
     "regex-syntax",
    ]
    
    [[package]]
    name = "regex-syntax"
    version = "0.7.4"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2"
    
    [[package]]
    name = "rustc-demangle"
    version = "0.1.23"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
    
    [[package]]
    name = "rustc-hash"
    version = "1.1.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
    
    [[package]]
    name = "rustix"
    version = "0.37.23"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06"
    dependencies = [
     "bitflags 1.3.2",
     "errno",
     "io-lifetimes",
     "libc",
     "linux-raw-sys 0.3.8",
     "windows-sys",
    ]
    
    [[package]]
    name = "rustix"
    version = "0.38.8"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f"
    dependencies = [
     "bitflags 2.4.0",
     "errno",
     "libc",
     "linux-raw-sys 0.4.5",
     "windows-sys",
    ]
    
    [[package]]
    name = "ryu"
    version = "1.0.15"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
    
    [[package]]
    name = "scopeguard"
    version = "1.2.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
    
    [[package]]
    name = "semver"
    version = "1.0.18"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918"
    
    [[package]]
    name = "serde"
    version = "1.0.183"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c"
    dependencies = [
     "serde_derive",
    ]
    
    [[package]]
    name = "serde_derive"
    version = "1.0.183"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816"
    dependencies = [
     "proc-macro2",
     "quote",
     "syn 2.0.29",
    ]
    
    [[package]]
    name = "serde_json"
    version = "1.0.105"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360"
    dependencies = [
     "itoa",
     "ryu",
     "serde",
    ]
    
    [[package]]
    name = "sha2"
    version = "0.10.7"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8"
    dependencies = [
     "cfg-if",
     "cpufeatures",
     "digest",
    ]
    
    [[package]]
    name = "slice-group-by"
    version = "0.3.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7"
    
    [[package]]
    name = "smallvec"
    version = "1.11.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9"
    
    [[package]]
    name = "sptr"
    version = "0.3.2"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a"
    
    [[package]]
    name = "stable_deref_trait"
    version = "1.2.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
    
    [[package]]
    name = "syn"
    version = "1.0.109"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
    dependencies = [
     "proc-macro2",
     "quote",
     "unicode-ident",
    ]
    
    [[package]]
    name = "syn"
    version = "2.0.29"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a"
    dependencies = [
     "proc-macro2",
     "quote",
     "unicode-ident",
    ]
    
    [[package]]
    name = "target-lexicon"
    version = "0.12.11"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a"
    
    [[package]]
    name = "termcolor"
    version = "1.2.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
    dependencies = [
     "winapi-util",
    ]
    
    [[package]]
    name = "thiserror"
    version = "1.0.47"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f"
    dependencies = [
     "thiserror-impl",
    ]
    
    [[package]]
    name = "thiserror-impl"
    version = "1.0.47"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b"
    dependencies = [
     "proc-macro2",
     "quote",
     "syn 2.0.29",
    ]
    
    [[package]]
    name = "tinyvec"
    version = "1.6.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
    dependencies = [
     "tinyvec_macros",
    ]
    
    [[package]]
    name = "tinyvec_macros"
    version = "0.1.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
    
    [[package]]
    name = "toml"
    version = "0.5.11"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
    dependencies = [
     "serde",
    ]
    
    [[package]]
    name = "typenum"
    version = "1.16.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
    
    [[package]]
    name = "unicase"
    version = "2.6.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
    dependencies = [
     "version_check",
    ]
    
    [[package]]
    name = "unicode-bidi"
    version = "0.3.13"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460"
    
    [[package]]
    name = "unicode-ident"
    version = "1.0.11"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
    
    [[package]]
    name = "unicode-normalization"
    version = "0.1.22"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
    dependencies = [
     "tinyvec",
    ]
    
    [[package]]
    name = "unicode-width"
    version = "0.1.10"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
    
    [[package]]
    name = "unicode-xid"
    version = "0.2.4"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
    
    [[package]]
    name = "url"
    version = "2.4.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb"
    dependencies = [
     "form_urlencoded",
     "idna",
     "percent-encoding",
    ]
    
    [[package]]
    name = "uuid"
    version = "1.4.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d"
    
    [[package]]
    name = "version_check"
    version = "0.9.4"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
    
    [[package]]
    name = "wasi"
    version = "0.11.0+wasi-snapshot-preview1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
    
    [[package]]
    name = "wasm-encoder"
    version = "0.31.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "41763f20eafed1399fff1afb466496d3a959f58241436cfdc17e3f5ca954de16"
    dependencies = [
     "leb128",
    ]
    
    [[package]]
    name = "wasmparser"
    version = "0.107.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "29e3ac9b780c7dda0cac7a52a5d6d2d6707cc6e3451c9db209b6c758f40d7acb"
    dependencies = [
     "indexmap",
     "semver",
    ]
    
    [[package]]
    name = "wasmtime"
    version = "11.0.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "0b1f817f2ca5070983c71f1205fbab5848c9073df7f4e1af9fdceb4cc4a1b8e5"
    dependencies = [
     "anyhow",
     "async-trait",
     "bincode",
     "bumpalo",
     "cfg-if",
     "fxprof-processed-profile",
     "indexmap",
     "libc",
     "log",
     "object",
     "once_cell",
     "paste",
     "psm",
     "rayon",
     "serde",
     "serde_json",
     "target-lexicon",
     "wasmparser",
     "wasmtime-cache",
     "wasmtime-component-macro",
     "wasmtime-cranelift",
     "wasmtime-environ",
     "wasmtime-fiber",
     "wasmtime-jit",
     "wasmtime-runtime",
     "wat",
     "windows-sys",
    ]
    
    [[package]]
    name = "wasmtime-asm-macros"
    version = "11.0.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "0f82fbfda4610e9225238c62574ecded8e9d6ad3a12f387ac45819ecad5c3f9b"
    dependencies = [
     "cfg-if",
    ]
    
    [[package]]
    name = "wasmtime-cache"
    version = "11.0.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "b4f5b87f1ed383d6c219c04467ab6ae87990d6c2815d5a990138990a7fcbab95"
    dependencies = [
     "anyhow",
     "base64",
     "bincode",
     "directories-next",
     "file-per-thread-logger",
     "log",
     "rustix 0.37.23",
     "serde",
     "sha2",
     "toml",
     "windows-sys",
     "zstd",
    ]
    
    [[package]]
    name = "wasmtime-component-macro"
    version = "11.0.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "e27b96c540c78e12b60025fcbc0ba8a55bff1b32885a5e8eae2df765a6bc97ac"
    dependencies = [
     "anyhow",
     "proc-macro2",
     "quote",
     "syn 1.0.109",
     "wasmtime-component-util",
     "wasmtime-wit-bindgen",
     "wit-parser",
    ]
    
    [[package]]
    name = "wasmtime-component-util"
    version = "11.0.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "0928fe66c22bf8887e2fb524b7647308b8ce836a333af8504e4f1d80b8ea849f"
    
    [[package]]
    name = "wasmtime-cranelift"
    version = "11.0.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "b659f6e58662d1131f250339acd03aa49377f9351474282699985b79ca4d4a7c"
    dependencies = [
     "anyhow",
     "cranelift-codegen",
     "cranelift-control",
     "cranelift-entity",
     "cranelift-frontend",
     "cranelift-native",
     "cranelift-wasm",
     "gimli",
     "log",
     "object",
     "target-lexicon",
     "thiserror",
     "wasmparser",
     "wasmtime-cranelift-shared",
     "wasmtime-environ",
    ]
    
    [[package]]
    name = "wasmtime-cranelift-shared"
    version = "11.0.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "74171de083bf2ecb716c507900f825e2b858346c714fbf48f4763ea760f998a8"
    dependencies = [
     "anyhow",
     "cranelift-codegen",
     "cranelift-control",
     "cranelift-native",
     "gimli",
     "object",
     "target-lexicon",
     "wasmtime-environ",
    ]
    
    [[package]]
    name = "wasmtime-environ"
    version = "11.0.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "b124cbac1a3e04a744c76b3f77919343ef16dc4c818a2406dd7b689b16a54639"
    dependencies = [
     "anyhow",
     "cranelift-entity",
     "gimli",
     "indexmap",
     "log",
     "object",
     "serde",
     "target-lexicon",
     "thiserror",
     "wasmparser",
     "wasmtime-types",
    ]
    
    [[package]]
    name = "wasmtime-fiber"
    version = "11.0.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "f92ffb8869395c63100ffefbd71cf9489e7e9218e63a3798dcfe93fa8945f9cf"
    dependencies = [
     "cc",
     "cfg-if",
     "rustix 0.37.23",
     "wasmtime-asm-macros",
     "windows-sys",
    ]
    
    [[package]]
    name = "wasmtime-jit"
    version = "11.0.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "90ff15f426c2378f32ffb6d9b4370e3504231492e93f6968e8b5102c3256bbc4"
    dependencies = [
     "addr2line",
     "anyhow",
     "bincode",
     "cfg-if",
     "cpp_demangle",
     "gimli",
     "ittapi",
     "log",
     "object",
     "rustc-demangle",
     "rustix 0.37.23",
     "serde",
     "target-lexicon",
     "wasmtime-environ",
     "wasmtime-jit-debug",
     "wasmtime-jit-icache-coherence",
     "wasmtime-runtime",
     "windows-sys",
    ]
    
    [[package]]
    name = "wasmtime-jit-debug"
    version = "11.0.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "c549e219102426aa1f90bd18e56a3195ed1e696c318abb3f501c1f4924b530ac"
    dependencies = [
     "object",
     "once_cell",
     "rustix 0.37.23",
    ]
    
    [[package]]
    name = "wasmtime-jit-icache-coherence"
    version = "11.0.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "1cf02fedda287a409cff80ad40a7c6c0f0771e99b0cd5e2b79d9cb7ecdc1b2f4"
    dependencies = [
     "cfg-if",
     "libc",
     "windows-sys",
    ]
    
    [[package]]
    name = "wasmtime-runtime"
    version = "11.0.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "fc38c6229a5d3b8a2528eb33eb11d3e7ebf570259c7cd2f01e8668fe783ea443"
    dependencies = [
     "anyhow",
     "cc",
     "cfg-if",
     "indexmap",
     "libc",
     "log",
     "mach",
     "memfd",
     "memoffset 0.8.0",
     "paste",
     "rand",
     "rustix 0.37.23",
     "sptr",
     "wasmtime-asm-macros",
     "wasmtime-environ",
     "wasmtime-fiber",
     "wasmtime-jit-debug",
     "windows-sys",
    ]
    
    [[package]]
    name = "wasmtime-types"
    version = "11.0.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "768f6c5e7afc3a02eff2753196741db8e5ac5faf26a1e2204d7341b30a637c6f"
    dependencies = [
     "cranelift-entity",
     "serde",
     "thiserror",
     "wasmparser",
    ]
    
    [[package]]
    name = "wasmtime-wit-bindgen"
    version = "11.0.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "84a4a005a6a2d5faa7cd953d389da8ae979cb571fe40edec7769649d8c98d874"
    dependencies = [
     "anyhow",
     "heck",
     "wit-parser",
    ]
    
    [[package]]
    name = "wast"
    version = "63.0.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "2560471f60a48b77fccefaf40796fda61c97ce1e790b59dfcec9dc3995c9f63a"
    dependencies = [
     "leb128",
     "memchr",
     "unicode-width",
     "wasm-encoder",
    ]
    
    [[package]]
    name = "wat"
    version = "1.0.70"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "3bdc306c2c4c2f2bf2ba69e083731d0d2a77437fc6a350a19db139636e7e416c"
    dependencies = [
     "wast",
    ]
    
    [[package]]
    name = "winapi"
    version = "0.3.9"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
    dependencies = [
     "winapi-i686-pc-windows-gnu",
     "winapi-x86_64-pc-windows-gnu",
    ]
    
    [[package]]
    name = "winapi-i686-pc-windows-gnu"
    version = "0.4.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
    
    [[package]]
    name = "winapi-util"
    version = "0.1.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
    dependencies = [
     "winapi",
    ]
    
    [[package]]
    name = "winapi-x86_64-pc-windows-gnu"
    version = "0.4.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
    
    [[package]]
    name = "windows-sys"
    version = "0.48.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
    dependencies = [
     "windows-targets",
    ]
    
    [[package]]
    name = "windows-targets"
    version = "0.48.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
    dependencies = [
     "windows_aarch64_gnullvm",
     "windows_aarch64_msvc",
     "windows_i686_gnu",
     "windows_i686_msvc",
     "windows_x86_64_gnu",
     "windows_x86_64_gnullvm",
     "windows_x86_64_msvc",
    ]
    
    [[package]]
    name = "windows_aarch64_gnullvm"
    version = "0.48.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
    
    [[package]]
    name = "windows_aarch64_msvc"
    version = "0.48.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
    
    [[package]]
    name = "windows_i686_gnu"
    version = "0.48.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
    
    [[package]]
    name = "windows_i686_msvc"
    version = "0.48.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
    
    [[package]]
    name = "windows_x86_64_gnu"
    version = "0.48.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
    
    [[package]]
    name = "windows_x86_64_gnullvm"
    version = "0.48.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
    
    [[package]]
    name = "windows_x86_64_msvc"
    version = "0.48.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
    
    [[package]]
    name = "wit-parser"
    version = "0.8.0"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "6daec9f093dbaea0e94043eeb92ece327bbbe70c86b1f41aca9bbfefd7f050f0"
    dependencies = [
     "anyhow",
     "id-arena",
     "indexmap",
     "log",
     "pulldown-cmark",
     "semver",
     "unicode-xid",
     "url",
    ]
    
    [[package]]
    name = "zstd"
    version = "0.11.2+zstd.1.5.2"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4"
    dependencies = [
     "zstd-safe",
    ]
    
    [[package]]
    name = "zstd-safe"
    version = "5.0.2+zstd.1.5.2"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db"
    dependencies = [
     "libc",
     "zstd-sys",
    ]
    
    [[package]]
    name = "zstd-sys"
    version = "2.0.8+zstd.1.5.5"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c"
    dependencies = [
     "cc",
     "libc",
     "pkg-config",
    ]
    
    Cargo.toml ASCII text
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    [package]
    name = "jstack"
    version = "0.1.0"
    edition = "2021"
    
    # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
    
    [dependencies]
    wasmtime = "11.0.1"
    anyhow = "1.0"
    
    [[bin]]
    name = "jstack"
    path = "jstack.rs"
    
    false.jstack ASCII text
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    [[]0||$][q]:[1~,0||$][c]:[~"|~"|][oo]:
    [{{~|}}"}.[{{{|~}}"}.{{{||}}.][{{{___]?]["c]~,"c[}}]~,[w]:
    ["9=}"10=}32={{++][isws]:["48<~57>+0=][isnum]:
    [ [1]|[  oo~#<[oo@ "93=[_0]["91=[_1+pquot ][ "39=[_1+oo@0~,]["123=[_[oo@125=0=][1+]w 2 32,]["34=[_[]|1+[oo@"34=0=][}||{,|1+]w_||q 3~,]["isnum[48-[|1+oo@"isnum][48-}||{~10*+]w_1-||0~,]["isws[_32][]?2~,]?]?]?]? ]? }1+||{q,| 1]? ][0]?  ][]w|| ][pquot]:
    [~1+"}~${][p]:[oo@}1-{][r]:
    [1[oo~#<][oo@|}}"0@[[p] [p] ["1@"97<~122>+0=[p][1@32-table~@.]?] [1@}~"|1@{,~}1~${]]~@.{{1+]w__][do]:
    [32,0pquot|__}q[[]],0"",","",,,",,27{do][run]:
    [[] [r do] 0 [r}r{[}"}do r 1@0=0={{||][~}"}do{{~]w__] [oo@p] [1-] 0 0  0 0 [r}r 1@{1@*0~,p] [r}r 1@{1@+0~,p] [r}}"1@{{~}1@,1~${] [r}r 1@{1@-0~,p] [r 1@[]~["0>]["10%}10/{48+~}~,{]w_10,~}}"1@{,1~${] [r}r 1@{1@/0~,p]]
    [0 0 0 0 0 0 0 0  0 0 [r}r{~}1@95-{||}${] [oo@~1-}1@95-}"{@{~p] [r}r 1@{1@<0~-0~,p] [r}r 1@{1@=0~-0~,p] [r}r 1@{1@>0~-0~,p] [r}r{1@0=[_][do]?]],
    [[r}r}r{{||}}p{p{p] 0 []], [r}oo{1@-@p]q 0",","",,"|,,,
    [[r}oo@{~}}1-{p{p] 0 0 [oo@1@0~-0~,~"}~${]],
    0"""",,,,"",,",,[oo@1@1+0~-0~,~"}~${]q,q[table]:
    
    flake.lock JSON text data
     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
    {
      "nodes": {
        "nixpkgs": {
          "locked": {
            "lastModified": 1692463654,
            "narHash": "sha256-F8hZmsQINI+S6UROM4jyxAMbQLtzE44pI8Nk6NtMdao=",
            "owner": "NixOS",
            "repo": "nixpkgs",
            "rev": "ca3c9ac9f4cdd4bea19f592b32bb59b74ab7d783",
            "type": "github"
          },
          "original": {
            "owner": "NixOS",
            "ref": "nixpkgs-unstable",
            "repo": "nixpkgs",
            "type": "github"
          }
        },
        "root": {
          "inputs": {
            "nixpkgs": "nixpkgs",
            "wsrc": "wsrc"
          }
        },
        "wsrc": {
          "flake": false,
          "locked": {
            "lastModified": 1671804573,
            "narHash": "sha256-y7DqowHezLa0/+92Nzrmy3P2e+pEzSqA6N/VnYTitPA=",
            "owner": "ktye",
            "repo": "w",
            "rev": "702f540f2af81cacaaca764259c55325bf70f6f9",
            "type": "github"
          },
          "original": {
            "owner": "ktye",
            "repo": "w",
            "type": "github"
          }
        }
      },
      "root": "root",
      "version": 7
    }
    
    flake.nix 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
    {
    
      inputs = {
        nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
        wsrc = {
          url = "github:ktye/w";
          flake = false;
        };
      };
    
      description = "A very basic flake";
    
      outputs = { self, nixpkgs, wsrc }: {
        devShells.x86_64-linux.default =
          let
            pkgs = import nixpkgs { system = "x86_64-linux"; };
            w = pkgs.buildGoPackage {
              pname = "w";
              version = "0.0.1";
              goPackagePath = "github:ktye/w";
              src = wsrc;
            };
            jstackwasm = pkgs.stdenv.mkDerivation {
              pname = "jstack";
              version = "0.0.1";
              src = wsrc;
              buildInputs = [ w ];
              buildPhase = ''
                w j.w > jstack.wasm
              '';
              installPhase = ''
                mkdir -p $out/bin
                cp jstack.wasm $out/bin
              '';
            };
            jstack = pkgs.rustPlatform.buildRustPackage {
              pname = "jstack";
              version = "1.0.0";
              src = ./.;
              cargoLock = {
                lockFile = ./Cargo.lock;
              };
              preBuild = ''
                cp ${jstackwasm}/bin/jstack.wasm .
              '';
              doCheck = false;
            };
          in pkgs.mkShell { nativeBuildInputs = [ jstack ]; };
      };
    }
    
    jstack.rs 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
    use std::io::{Write,stdin,stdout};
    use wasmtime::{Engine, Module, Store, Caller, Func, Instance, Extern, Result};
    use anyhow::anyhow;
    
    fn i(mem: &[u8], i: i32) -> i32 { i32::from_le_bytes(mem[i as usize*4..(i as usize+1)*4].try_into().unwrap()) }
    
    fn fmt(mem: &[u8],     mut x: i32) -> String { use String as S;
        x=i(mem, x);   let mut y = (x as u32 >> 2) as i32;
        match ((x&4)>>2,(x&2)>>1,(x&1)) {
            (0,0,0)=>{ let mut s = S::from('['); for j in 0..i(mem, y+1){ if j!=0{s.push(' ');}; s.push_str(&fmt(mem, y+2+j)); } s + "]" },
            (_,1,0)=>{ let mut s = S::new();     while y!=0             { s.insert(0,(96 + y%32) as u8 as char); y>>=5;        } s       },
            (1,0,0)=>  S::from((33+(x>>3)) as u8 as char),
            (_,_,1)=>  (x >> 1).to_string(),
            _ => unreachable!("how about you reach some bitches"),
        }
    }
    
    fn main() -> Result<()> {
        let engine = Engine::default();
        let module = Module::from_binary(&engine, include_bytes!("jstack.wasm"))?;
        let mut store = Store::new(&engine, ());
        
        let stk = Func::wrap(&mut store, |mut caller: Caller<'_,()>, _:i32| {
            let mem = caller.get_export("mem").and_then(|x| x.into_memory()).ok_or(anyhow!("no mem"))?.data(&caller);
            println!("{}:{}", fmt(mem, 1),fmt(mem, 2));
            Ok(())
        });
        let draw = Func::wrap(&mut store, |mut _caller: Caller<'_,()>, _: i32, _: i32| { println!("draw called"); });
        let instance = Instance::new(&mut store, &module, &[Extern::Func(stk), Extern::Func(draw)])?;
        let j = instance.get_typed_func::<i32, i32>(&mut store, "j")?;
        
        j.call(&mut store, 18)?;
        let mut jj = |c:&str|->Result<()> { for i in c.chars() { j.call(&mut store, i as i32)?; } Ok(()) };
        let mut input = String::new();
        jj(&std::fs::read_to_string("false.jstack")?)?;
        loop {
            print!(" "); stdout().flush()?;
            stdin().read_line(&mut input)?;
            if input.starts_with('\'') {
                jj("[")?; for c in input.trim().chars().skip(1) { jj(&(c as u32).to_string())?; jj(" ")?; } jj("]!\n")?;
            } else { jj(&input.trim())?; jj("!\n")?; }
            input.clear();
        }
    }
    
    txt.txt ASCII text
    1
    2
    3
    4
    5
    6
    write
        'input  <- program input
        '1 1+   <- code
        run
    
    [[in] [out] [a] [b] ... [z] [0] [1] [2] ...] <ptr>
    

    entry #11

    written by LyricLy
    submitted at
    1 like

    guesses
    comments 0

    post a comment


    forth.py 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
    import sys
    import math
    from lark import Lark
    from lark.visitors import Interpreter
    
    l = Lark(r"""
    int: /\d+/
    char: "'" /./
    quote: "[" code "]"
    string: /"[^"]*"/
    var: /[a-z]/
    !simple: ";" | ":" | "$" | "%" | "@" | "\\" | "O" | "+" | "-" | "*" | "/" | "_" | "&" | "|" | "~" | "=" | ">" | "!" | "?" | "#" | "^" | "," | "." | "B"
    _inst: int | char | string | quote | simple | var
    code: _inst*
    %ignore /\s+|{[^}]*}/ 
    """, parser="lalr", start="code")
    
    variables = {}
    stack = []
    
    class Factor(Interpreter):
        def int(self, tree):
            stack.append(int(tree.children[0]))
    
        def char(self, tree):
            stack.append(ord(tree.children[0]))
    
        def quote(self, tree):
            stack.append(lambda: self.visit(tree.children[0]))
    
        def string(self, tree):
            print(tree.children[0][1:-1], end="")
    
        def var(self, tree):
            stack.append(tree.children[0].value)
    
        def simple(self, tree):
            match tree.children[0].value:
                case "$":
                    stack.append(stack[-1])
                case "%":
                    stack.pop()
                case "\\":
                    stack.append(stack.pop(-2))
                case "@":
                    stack.append(stack.pop(-3))
                case "O":
                    stack.append(stack[-stack.pop()-1])
                case "+":
                    stack.append(stack.pop() + stack.pop())
                case "-":
                    stack.append(stack.pop(-2) - stack.pop())
                case "*":
                    stack.append(stack.pop() * stack.pop())
                case "/":
                    stack.append(math.trunc(stack.pop(-2) / stack.pop()))
                case "_":
                    stack[-1] *= -1
                case "&":
                    stack.append(stack.pop() & stack.pop())
                case "|":
                    stack.append(stack.pop() | stack.pop())
                case "~":
                    stack.append(~stack.pop())
                case ">":
                    stack.append(-1 if stack.pop() < stack.pop() else 0)
                case "=":
                    stack.append(-1 if stack.pop() == stack.pop() else 0)
                case "!":
                    stack.pop()()
                case "?":
                    f = stack.pop()
                    if stack.pop():
                        f()
                case "#":
                    b = stack.pop()
                    c = stack.pop()
                    while (c(), stack.pop())[1]:
                        b()
                case ":":
                    variables[stack.pop()] = stack.pop(-2)
                case ";":
                    stack.append(variables[stack.pop()])
                case "^":
                    stack.append(sys.stdin.buffer.read(1)[0] or -1)
                case ",":
                    sys.stdout.buffer.write(bytes([stack.pop() % 256]))
                case ".":
                    print(stack.pop(), end="")
                case "B":
                    sys.stdout.flush()
    
        def code(self, tree):
            for x in tree.children:
                self.visit(x)
    
    Factor().visit(l.parse(open(sys.argv[1]).read()))
    

    entry #12

    written by olive
    submitted at
    1 like

    guesses
    comments 1
    olive *known at the time as [author of #12]
    % cat fib.false
    [$ 1 > [1- $ f;! \ 1- f;! +]?]f:
    33 f;! .
    % time 6.out fib.false
    3524578
    16.92u 0.72s 19.34r 	 6.out fib.false
    

    post a comment


    cg41.c 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
    #include <u.h>
    #include <libc.h>
    #include <bio.h>
    
    /*
    	Copyright 2023
    	
    	The author does not remember how this program works, or if it even does.
    	
    	Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided information regarding the author is erased and not disclosed to any third party.
    	
    	THE SOFTWARE IS PROVIDED "AS IS". THE AUTHOR DISCLAIMS ALL WARRANTIES INCLUDING ALL IMPLIED WARRANTIES. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR DAMAGES.
    */
    
    /* "accessing uninitialized data (for example, popping an empty stack or reading an uninitialized variable) is undefined behaviour." */
    
    /* TODO: check if things error <- TODO: what was that in reference to */
    /* TODO: nesting dosen't work for everything */
    
    union var
    {
    	s32int i;
    	union var *reg;
    	char *str;
    };
    #define STACKSIZE 1024
    union var stack[STACKSIZE];
    usize top = -1;
    
    struct frame
    {
    	char *ins;
    	int incond;
    	char *body;
    	char *cond;
    };
    #define CALLSIZE 256
    struct frame callstack[CALLSIZE];
    usize calltop = -1;
    
    union var regs['z'-'a'+1];
    
    Biobuf prog;
    Biobuf in;
    Biobuf out;
    
    
    void
    usage(void)
    {
    	print("oops\n");
    	exits("usage");
    }
    
    /* leaving this here because I was proud of it, unfortunately pipes & stdin. */
    /* untested */
    /*
    char *
    readquote(void)
    {
    	char *start = Boffset(&prog);
    	int len;
    	char *s;
    	
    	for(int nest = 1; nest > 0)
    		switch(Bread(&prog))
    		{
    		case '[':
    			nest++;
    			break;
    		case ']':
    			nest--;
    			break;
    		case Beof:
    			exits("eof in quote");
    		default:
    			break;
    		}
    	
    	len = Boffset(&prog)-start;
    	s = malloc(len)
    	Bseek(&prog, start, 0);
    	Bread(&prog, s, len);
    	s[len-1] = 0;
    	return s;
    }
    */
    
    int
    getins(void)
    {
    	if(calltop == -1)
    		return Bgetc(&prog);
    	else
    		return *(callstack[calltop].ins++);
    }
    
    void
    ungetins(void)
    {
    	if(calltop == -1)
    		Bungetc(&prog);
    	else
    		callstack[calltop].ins--;
    }
    
    char *
    readquote(void)
    {
    	char *s = nil;
    	int len = 0;
    	
    	for(int nest = 1; nest > 0;)
    	{
    		s = realloc(s, ++len); /* this is awful - change it later */
    		switch(s[len-1] = getins())
    		{
    		case '[':
    			nest++;
    			break;
    		case ']':
    			nest--;
    			break;
    		case 0:
    			exits("null char in quote");
    		case Beof:
    			exits("eof in quote");
    		default:
    			break;
    		}
    	}
    	
    	s[len-1] = 0;
    	return s;
    }
    
    void
    main(int argc, char *argv[])
    {
    	Binit(&in, 0, OREAD);
    	Binit(&out, 1, OWRITE);
    	
    	if(argc <= 1 || (argv[1][0] == '-' && argv[1][1] == 0))
    		Binit(&prog, 0, OREAD);
    	else if(argc == 2)
    	{
    		int fd = open(argv[1], OREAD);
    		Binit(&prog, fd, OREAD);
    	}
    	else
    		usage();
    	
    	/* Ignore Shebang */
    	if(Bgetc(&prog) == '#')
    		for(int c = Bgetc(&prog); c != Beof && c != '\n'; c = Bgetc(&prog));
    	else
    		Bungetc(&prog);
    	
    	for(int c = getins(); c != Beof; c = getins())
    	{
    		union var x,y,z;
    		
    	//	Bprint(&out, "%c", c);
    	//	Bflush(&out);
    		
    		switch(c)
    		{
    			/* Comments */
    			case '{':
    				for(c = getins(); c != Beof && c != '}'; c = getins());
    				break;
    			
    			/* Print Message */
    			case '"':
    				for(c = getins(); c != Beof && c != '"'; c = getins())
    					Bputc(&out, c);
    				break;
    			
    			/* Reg Access */
    			case ';':
    				stack[top] = *(stack[top].reg);
    				break;
    			case ':':
    				*(stack[top].reg) = stack[top-1];
    				top -= 2;
    				break;
    			
    			/* Stack */
    			case '$':
    				stack[top+1] = stack[top];
    				top++;
    				break;
    			case '%':
    				top--;
    				break;
    			case '\\':
    				x = stack[top];
    				stack[top] = stack[top-1];
    				stack[top-1] = x;
    				break;
    			case '@':
    				x = stack[top-2];
    				y = stack[top-1];
    				z = stack[top  ];
    				stack[top-2] = y;
    				stack[top-1] = z;
    				stack[top  ] = x;
    				break;
    			case 'ø':
    			case 'O':
    				stack[top] = stack[top-1-stack[top].i];
    				break;
    			
    			/* Number Ops */
    			case '+':
    				x = stack[top--];
    				stack[top].i += x.i;
    				break;
    			case '-':
    				x = stack[top--];
    				stack[top].i -= x.i;
    				break;
    			case '*':
    				x = stack[top--];
    				stack[top].i *= x.i;
    				break;
    			case '/':
    				x = stack[top--];
    				stack[top].i /= x.i;
    				break;
    			case '_':
    				stack[top].i = -stack[top].i;
    				break;
    			
    			/* Bit Ops */
    			case '&':
    				x = stack[top--];
    				stack[top].i &= x.i;
    				break;
    			case '|':
    				x = stack[top--];
    				stack[top].i |= x.i;
    				break;
    			case '~':
    				stack[top].i = ~stack[top].i;
    				break;
    			
    			/* Queries */
    			case '=':
    				x = stack[top--];
    				stack[top].i = -(stack[top].i == x.i);
    				break;
    			case '>':
    				x = stack[top--];
    				stack[top].i = -(stack[top].i > x.i);
    				break;
    			case '<':
    				x = stack[top--];
    				stack[top].i = -(stack[top].i < x.i);
    				break;
    			
    			/* Calls */
    			case '!':
    				calltop++;
    				callstack[calltop].body = stack[top].str;
    				callstack[calltop].cond = nil;
    				callstack[calltop].ins = stack[top].str;
    				callstack[calltop].incond = 0;
    				top--;
    				break;
    			case '?':
    				if(stack[top-1].i != 0)
    				{
    					calltop++;
    					callstack[calltop].body = stack[top].str;
    					callstack[calltop].cond = nil;
    					callstack[calltop].ins = stack[top].str;
    					callstack[calltop].incond = 0;
    				}
    				top -= 2;
    				break;
    			case '#':
    				calltop++;
    				callstack[calltop].body = stack[top].str;
    				callstack[calltop].cond = stack[top-1].str;
    				callstack[calltop].ins = stack[top].str;
    				callstack[calltop].incond = 0;
    				top -= 2;
    				break;
    			
    			/* Returns */
    			case 0:
    				// FIXME: memleak of strings, can't free as may ref'd elsewhere
    				if(callstack[calltop].incond)
    				{
    					if(stack[top--].i != 0)
    					{
    						callstack[calltop].incond = 0;
    						callstack[calltop].ins = callstack[calltop].body;
    					}
    					else
    						calltop--;
    				}
    				else if(callstack[calltop].cond != nil)
    				{
    					callstack[calltop].incond = 1;
    					callstack[calltop].ins = callstack[calltop].cond;
    				}
    				else
    					calltop--;
    				break;
    			
    			/* Quote */
    			case '[':
    				stack[++top].str = readquote();
    				break;
    			case ']':
    				// pass
    				break;
    			
    			/* IO */
    			case '^':
    				c = Bgetc(&in);
    				stack[++top].i = (c == Beof ? -1 : c);
    				break;
    			case ',':
    				Bputc(&out, stack[top--].i);
    				break;
    			case '.':
    				Bprint(&out, "%d", stack[top--].i);
    				break;
    			case 'ß':
    			case 'B':
    				Bflush(&out);
    				break;
    			
    			/* Character Literal */
    			case '\'':
    				x.i = getins();
    				if(x.i != 0 && x.i != Beof)
    					stack[++top].i = x.i;
    				else
    					ungetins();
    				break;
    			
    			/* Integer Literal */
    			case '0':
    			case '1':
    			case '2':
    			case '3':
    			case '4':
    			case '5':
    			case '6':
    			case '7':
    			case '8':
    			case '9':
    				stack[++top].i = c - '0';
    				for(c = getins(); '0' <= c && c <= '9'; c = getins())
    					stack[top].i = stack[top].i*10 + c - '0';
    				ungetins();
    				break;
    			
    			default:
    				/* Register Ref */
    				if('a' <= c && c <= 'z')
    					stack[++top].reg = &(regs[c-'a']);
    				break;
    		}
    		
    	//	Bflush(&out);
    	}
    	
    	Bflush(&out);
    	exits(0);
    }
    
    mkfile ASCII text
    1
    2
    3
    4
    5
    6
    7
    8
    9
    </$objtype/mkfile
    
    TARG=cg41
    BIN=/$objtype/bin
    
    OFILES=\
    	cg41.$O\
    
    </sys/src/cmd/mkone
    

    entry #13

    written by moshikoi
    submitted at
    1 like

    guesses
    comments 0

    post a comment


    dir src
    compiler.ts 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
    import { TextEncoder } from "util";
    import { AstNode, AstType } from "./parser.js";
    
    function exhaustive(x: never): never {
        throw new Error(`Expected all cases to be handled, but got ${x} instead`);
    }
    
    function encode_string(str: string): [number, string] {
        const encoder = new TextEncoder();
        const enc = [...encoder.encode(str)];
        const enc_str = enc.map(code => {
            let hex = code.toString(16)
            if (hex.length === 1) { hex = '0' + hex; }
            return '\\' + hex;
        }).join('');
        return [enc.length + 1, enc_str + '\\00'];
    }
    
    function varName(name: string) {
        return `@var_${name}`;
    }
    
    function astEqual(a: AstNode['value'], b: AstNode['value']) {
        if (typeof a !== typeof b) { return false; }
        if (!(a instanceof Array && b instanceof Array)) { return a === b; }
        if (a.length !== b.length) { return false; }
    
        for (let i = 0; i < a.length; i++) {
            if (a[i].type !== b[i].type) {
                return false
            }
    
            return astEqual(a[i].value, b[i].value);
        }
    
        return true;
    }
    
    class TemporaryGenerator {
        #id: number = 1;
        #template: (id: number) => string
        constructor(template: string | ((id: number) => string)) {
            if (typeof template === 'string') {
                this.#template = id => template + id.toString();
            }
            else {
                this.#template = template;
            }
        }
        next() {
            return this.#template(this.#id++);
        }
    }
    
    function definePush(name: string, type: string) {
        return `
    define void ${name}(${type} %value) {
    entry:
      %stack_size = load i64, i64* @stack_size
      %stack_capacity0 = load i64, i64* @stack_capacity
      %cond = icmp eq i64 %stack_size, %stack_capacity0
      br i1 %cond, label %increase_capacity, label %set_value
      
    increase_capacity:
      %buffer0 = load ptr, ptr @stack
      %new_capacity = shl i64 %stack_capacity0, 1
      %new_buffer_size = mul i64 %new_capacity, 8
      %new_buffer = call ptr @realloc(ptr %buffer0, i64 %new_buffer_size)
      store ptr %new_buffer, ptr @stack
      store i64 %new_capacity, i64* @stack_capacity
      br label %set_value
    
    set_value:
      %buffer1 = load ptr, ptr @stack
      %top = getelementptr %union.FalseValue, %union.FalseValue* %buffer1, i64 %stack_size
      %cast = bitcast %union.FalseValue* %top to ${type}*
      store ${type} %value, ${type}* %cast
      %new_size = add i64 %stack_size, 1
      store i64 %new_size, i64* @stack_size
      ret void
    }`
    }
    
    function definePop(name: string, type: string) {
        return `
    define ${type} ${name}() {
    entry:
      %stack_size = load i64, i64* @stack_size
      %new_size = sub i64 %stack_size, 1
      store i64 %new_size, i64* @stack_size
      %buffer = load ptr, ptr @stack
      %top = getelementptr %union.FalseValue, ptr %buffer, i64 %new_size
      %cast = bitcast %union.FalseValue* %top to ${type}*
      %value = load ${type}, ptr %cast
      ret ${type} %value
    }`
    }
    
    function definePeek(name: string, type: string) {
        return `
    define ${type} ${name}(i32 %depth) {
    entry:
      %stack_size = load i64, i64* @stack_size
      %0 = sext i32 %depth to i64
      %1 = sub i64 %stack_size, %0
      %peek_size = sub i64 %1, 1
      %buffer = load ptr, ptr @stack
      %top = getelementptr %union.FalseValue, ptr %buffer, i64 %peek_size
      %cast = bitcast %union.FalseValue* %top to ${type}*
      %value = load ${type}, ptr %cast
      ret ${type} %value
    }`
    }
    
    const head = `
    @.fmt = private unnamed_addr constant [3 x i8] c"%s\\00"
    @.num = private unnamed_addr constant [3 x i8] c"%d\\00"
    
    declare ptr @malloc(i64)
    declare ptr @realloc(ptr, i64)
    declare void @free(ptr)
    declare i32 @putchar(i32)
    declare i32 @getchar()
    declare i32 @printf(i8*, ...)
    
    %union.FalseValue = type { [8 x i8] }
    
    @stack = global %union.FalseValue* null
    @stack_size = global i64 0
    @stack_capacity = global i64 0
    
    define void @stack_init() {
    entry:
      store i64 16, i64* @stack_capacity
      %stack_capacity = load i64, i64* @stack_capacity
      %buffer_size = mul i64 %stack_capacity, 8
      %buffer = call ptr @malloc(i64 %buffer_size)
      store i64 0, i64* @stack_size
      store ptr %buffer, %union.FalseValue** @stack
      ret void
    }
    
    ${definePush('@stack_push_any', '%union.FalseValue')}
    ${definePush('@stack_push_int', 'i32')}
    ${definePush('@stack_push_ref', '%union.FalseValue*')}
    ${definePush('@stack_push_quote', 'void()*')}
    
    ${definePop('@stack_pop_any', '%union.FalseValue')}
    ${definePop('@stack_pop_int', 'i32')}
    ${definePop('@stack_pop_ref', '%union.FalseValue*')}
    ${definePop('@stack_pop_quote', 'void()*')}
    
    ${definePeek('@stack_peek_any', '%union.FalseValue')}
    ${definePeek('@stack_peek_int', 'i32')}
    ${definePeek('@stack_peek_ref', '%union.FalseValue*')}
    ${definePeek('@stack_peek_quote', 'void()*')}
    
    define void @stack_free() {
    entry:
      %buffer = load ptr, ptr @stack
      call void @free(ptr %buffer)
      ret void
    }
    
    ${[...'abcdefghijklmnopqrstuvwxyz']
            .map(a => `${varName(a)} = private global %union.FalseValue { [8 x i8] zeroinitializer }`)
            .join('\n')}
    `
    
    class Compiler {
    
        #functions: [nodes: AstNode[], name: string, compiled: string][] = []
        #strings: Map<string, string> = new Map();
    
        #compile(nodes: AstNode[]): string {
            const temporaryGenerator = new TemporaryGenerator('%t');
            const labelGenerator = new TemporaryGenerator('label_');
    
            const instructions: string[] = [];
    
            function basicOp(op: string): void {
                const second = temporaryGenerator.next();
                const first = temporaryGenerator.next();
                const result = temporaryGenerator.next();
                instructions.push(
                    `${second} = call i32 @stack_pop_int()`,
                    `${first} = call i32 @stack_pop_int()`,
                    `${result} = ${op} i32 ${first}, ${second}`,
                    `call void @stack_push_int(i32 ${result})`);
            }
    
            function cmp(op: string): void {
                const second = temporaryGenerator.next();
                const first = temporaryGenerator.next();
                const result = temporaryGenerator.next();
                const cast = temporaryGenerator.next();
                instructions.push(
                    `${second} = call i32 @stack_pop_int()`,
                    `${first} = call i32 @stack_pop_int()`,
                    `${result} = icmp ${op} i32 ${first}, ${second}`,
                    `${cast} = sext i1 ${result} to i32`,
                    `call void @stack_push_int(i32 ${cast})`);
            }
    
            for (const node of nodes) {
                switch (node.type) {
                    case AstType.Variable:
                        instructions.push(`call void @stack_push_ref(%union.FalseValue* ${varName(node.value)})`);
                        break;
                    case AstType.String: {
                        const strName = this.#getConstString(node.value);
                        instructions.push(`call i32 @printf(i8* @.fmt, i8* ${strName})`);
                        break;
                    }
    
                    case AstType.Integer:
                        instructions.push(`call void @stack_push_int(i32 ${node.value})`);
                        break;
                    case AstType.Quote: {
                        const name = this.#getFunction(node.value);
                        instructions.push(`call void @stack_push_quote(void()* ${name})`);
                        break;
                    }
    
                    case AstType.GetVar: {
                        const varRef = temporaryGenerator.next();
                        const value = temporaryGenerator.next();
                        instructions.push(
                            `${varRef} = call %union.FalseValue* @stack_pop_ref()`,
                            `${value} = load %union.FalseValue, %union.FalseValue* ${varRef}`,
                            `call void @stack_push_any(%union.FalseValue ${value})`);
                        break;
                    }
    
                    case AstType.SetVar: {
                        const varRef = temporaryGenerator.next();
                        const value = temporaryGenerator.next();
                        instructions.push(
                            `${varRef} = call %union.FalseValue* @stack_pop_ref()`,
                            `${value} = call %union.FalseValue @stack_pop_any()`,
                            `store %union.FalseValue ${value}, %union.FalseValue* ${varRef}`);
                        break;
                    }
    
                    case AstType.Dup: {
                        const value = temporaryGenerator.next();
                        instructions.push(
                            `${value} = call %union.FalseValue @stack_peek_any(i32 0)`,
                            `call void @stack_push_any(%union.FalseValue ${value})`);
                        break;
                    }
    
                    case AstType.Discard:
                        instructions.push(`call %union.FalseValue @stack_pop_any()`);
                        break;
                    case AstType.Swap: {
                        const first = temporaryGenerator.next();
                        const second = temporaryGenerator.next();
                        instructions.push(
                            `${first} = call %union.FalseValue @stack_pop_any()`,
                            `${second} = call %union.FalseValue @stack_pop_any()`,
                            `call void @stack_push_any(%union.FalseValue ${first})`,
                            `call void @stack_push_any(%union.FalseValue ${second})`);
                        break;
                    }
    
                    case AstType.Rotate: {
                        const first = temporaryGenerator.next();
                        const second = temporaryGenerator.next();
                        const third = temporaryGenerator.next();
                        instructions.push(
                            `${first} = call %union.FalseValue @stack_pop_any()`,
                            `${second} = call %union.FalseValue @stack_pop_any()`,
                            `${third} = call %union.FalseValue @stack_pop_any()`,
                            `call void @stack_push_any(%union.FalseValue ${second})`,
                            `call void @stack_push_any(%union.FalseValue ${first})`,
                            `call void @stack_push_any(%union.FalseValue ${third})`);
                        break;
                    }
    
                    case AstType.Take: {
                        const depth = temporaryGenerator.next();
                        const value = temporaryGenerator.next();
                        instructions.push(
                            `${depth} = call i32 @stack_pop_int()`,
                            `${value} = call %union.FalseValue @stack_peek_any(i32 ${depth})`,
                            `call void @stack_push_any(%union.FalseValue ${value})`);
                        break;
                    }
    
                    case AstType.Plus: basicOp('add'); break;
                    case AstType.Minus: basicOp('sub'); break;
                    case AstType.Mul: basicOp('mul'); break;
                    case AstType.Div: basicOp('sdiv'); break;
                    case AstType.Negate: {
                        const value = temporaryGenerator.next();
                        const temp = temporaryGenerator.next();
                        instructions.push(
                            `${value} = call i32 @stack_pop_int()`,
                            `${temp} = sub i32 0, ${value}`,
                            `call void @stack_push_int(i32 ${temp})`);
                        break;
                    }
    
                    case AstType.BitAnd: basicOp('and'); break;
                    case AstType.BitOr: basicOp('or'); break;
                    case AstType.BitInvert: {
                        const value = temporaryGenerator.next();
                        const temp = temporaryGenerator.next();
                        instructions.push(
                            `${value} = call i32 @stack_pop_int()`,
                            `${temp} = xor i32 -1, ${value}`,
                            `call void @stack_push_int(i32 ${temp})`);
                        break;
                    }
    
                    case AstType.Equal: cmp('eq'); break;
                    case AstType.GreaterThan: cmp('sgt'); break;
                    case AstType.Execute: {
                        const value = temporaryGenerator.next();
                        instructions.push(
                            `${value} = call void()* @stack_pop_quote()`,
                            `call void ${value}()`);
                        break;
                    }
    
                    case AstType.ExecuteIf: {
                        const iftrue = labelGenerator.next();
                        const iffalse = labelGenerator.next();
                        const quote = temporaryGenerator.next();
                        const value = temporaryGenerator.next();
                        const cond = temporaryGenerator.next();
    
                        instructions.push(
                            `${quote} = call void()* @stack_pop_quote()`,
                            `${value} = call i32 @stack_pop_int()`,
                            `${cond} = icmp ne i32 ${value}, 0`,
                            `br i1 ${cond}, label %${iftrue}, label %${iffalse}`,
                            `${iftrue}:`,
                            `call void ${quote}()`,
                            `br label %${iffalse}`,
                            `${iffalse}:`);
                        break;
                    }
    
                    case AstType.While: {
                        const loop = labelGenerator.next();
                        const iftrue = labelGenerator.next();
                        const iffalse = labelGenerator.next();
                        const body = temporaryGenerator.next();
                        const cond_quote = temporaryGenerator.next();
                        const value = temporaryGenerator.next();
                        const cond = temporaryGenerator.next();
    
                        instructions.push(
                            `${body} = call void()* @stack_pop_quote()`,
                            `${cond_quote} = call void()* @stack_pop_quote()`,
                            `br label %${loop}`,
                            `${loop}:`,
                            `call void ${cond_quote}()`,
                            `${value} = call i32 @stack_pop_int()`,
                            `${cond} = icmp ne i32 ${value}, 0`,
                            `br i1 ${cond}, label %${iftrue}, label %${iffalse}`,
                            `${iftrue}:`,
                            `call void ${body}()`,
                            `br label %${loop}`,
                            `${iffalse}:`);
                        break;
                    }
    
                    case AstType.Getc: {
                        const temp = temporaryGenerator.next();
                        instructions.push(
                            `${temp} = call i32 @getchar()`,
                            `call void @stack_push_int(i32 ${temp})`);
                        break;
                    }
    
                    case AstType.Putc: {
                        const temp = temporaryGenerator.next();
                        instructions.push(
                            `${temp} = call i32 @stack_pop_int()`,
                            `call i32 @putchar(i32 ${temp})`);
                        break;
                    }
    
                    case AstType.PrintInt: {
                        const temp = temporaryGenerator.next();
                        instructions.push(
                            `${temp} = call i32 @stack_pop_int()`,
                            `call i32 @printf(i8* @.num, i32 ${temp})`);
                        break;
                    }
    
                    default:
                        exhaustive(node);
                }
            }
            return instructions.join('\n');
        }
    
        compile(ast: AstNode[]) {
            const topLevel = this.#compile(ast);
    
            const strings = [...this.#strings.entries()]
                .map(([str, name]) => {
                    const [len, enc] = encode_string(str);
                    return `${name} = private unnamed_addr constant [${len} x i8] c"${enc}"`
                });
    
            return head + [
                ...strings,
                ...this.#functions.map(x => x[2]),
                'define i32 @main() {',
                'call void @stack_init()',
                topLevel,
                'call void @stack_free()',
                'ret i32 0',
                '}',
            ].join('\n');
        }
    
        #lambdaNameGenerator = new TemporaryGenerator('@lambda_');
        #stringNameGenerator = new TemporaryGenerator('@str_');
    
        #getFunction(nodes: AstNode[]) {
            const name = this.#functions.find(([value]) => astEqual(nodes, value))?.[1];
            if (name) {
                return name;
            }
            else {
                const name = this.#lambdaNameGenerator.next();
                const compiled = `define void ${name}() {\nentry:\n${this.#compile(nodes)}\nret void\n}`;
                this.#functions.push([nodes, name, compiled]);
                return name;
            }
        }
    
        #getConstString(str: string) {
            const name = this.#strings.get(str);
            if (name) {
                return name;
            }
            else {
                const name = this.#stringNameGenerator.next();
                this.#strings.set(str, name);
                return name;
            }
        }
    }
    
    export function compile(source: AstNode[]): string {
        return new Compiler().compile(source);
    }
    
    false.ts 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
    #!/usr/bin/env node
    
    // FALSE -> LLVM IR Compiler
    // Requirements:
    //  - Node.js
    //  - Typescript Compiler
    //  - LLC or equivalent (something to compile LLVM IR)
    
    import { readFile, writeFile } from "fs/promises";
    import { compile } from "./compiler.js";
    import { parse } from "./parser.js";
    
    async function main() {
    	const filename = process.argv[2];
    	if (!filename) {
    		console.error('Filename required');
    		process.exit(1);
    	}
    
    	const source = await readFile(filename, 'utf-8');
    	const outFile = process.argv[3] ?? filename.replace(/\..+$/, '.ll');
    
    	const ast = parse(source);
    	console.info('Parsed AST');
    	const IR = compile(ast);
    	await writeFile(outFile, IR);
    	console.info('Compiled to ' + outFile)
    }
    
    await main();
    
    parser.ts 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
    import { Token, TokenType, Tokenizer } from "./tokenizer.js"
    
    export enum AstType {
    	Variable,
    	String,
    	Integer, // Including chars such as 'A
    	Quote,
    	GetVar,
    	SetVar,
    	Dup,
    	Discard,
    	Swap,
    	Rotate,
    	Take,
    	Plus,
    	Minus,
    	Mul,
    	Div,
    	Negate,
    	BitAnd,
    	BitOr,
    	BitInvert,
    	Equal,
    	GreaterThan,
    	Execute,
    	ExecuteIf,
    	While,
    	Getc,
    	Putc,
    	PrintInt,
    }
    
    type ValueAst =
    	| { type: AstType.Variable, value: string }
    	| { type: AstType.String, value: string }
    	| { type: AstType.Integer, value: number }
    	| { type: AstType.Quote, value: AstNode[] }
    
    type NonValueAst = { type: Exclude<AstType, ValueAst['type']>, value: undefined }
    
    export type AstNode = ValueAst | NonValueAst
    
    class Parser {
    	#tokenizer: Iterator<Token>
    	#currentToken: Token | null = null
    
    	constructor(tokenizer: Iterator<Token>) {
    		this.#tokenizer = tokenizer;
    		this.#next();
    	}
    
    	parseStatements(): AstNode[] {
    		const statements: AstNode[] = [];
    
    		const _this = this;
    		function instr<const T extends ValueAst>(type: T['type'], value: T['value']): void;
    		function instr<const T extends NonValueAst>(type: T['type']): void;
    		function instr(type: any, value?: any): void {
    			statements.push({ type, value });
    			_this.#next();
    		}
    
    		loop:
    		while (this.#currentToken) {
    			switch (this.#currentToken.type) {
    				case TokenType.Variable: instr(AstType.Variable, this.#currentToken.value); break;
    				case TokenType.String: instr(AstType.String, this.#currentToken.value); break
    				case TokenType.Integer: instr(AstType.Integer, this.#currentToken.value); break;
    				case TokenType.OpenBracket: this.#next(); instr(AstType.Quote, this.parseStatements()); break;
    				case TokenType.CloseBracket: break loop;
    				case TokenType.GetVar: instr(AstType.GetVar); break;
    				case TokenType.SetVar: instr(AstType.SetVar); break;
    				case TokenType.Dup: instr(AstType.Dup); break;
    				case TokenType.Discard: instr(AstType.Discard); break;
    				case TokenType.Swap: instr(AstType.Swap); break;
    				case TokenType.Rotate: instr(AstType.Rotate); break;
    				case TokenType.Take: instr(AstType.Take); break;
    				case TokenType.Plus: instr(AstType.Plus); break;
    				case TokenType.Minus: instr(AstType.Minus); break;
    				case TokenType.Mul: instr(AstType.Mul); break;
    				case TokenType.Div: instr(AstType.Div); break;
    				case TokenType.Negate: instr(AstType.Negate); break;
    				case TokenType.BitAnd: instr(AstType.BitAnd); break;
    				case TokenType.BitOr: instr(AstType.BitOr); break;
    				case TokenType.BitInvert: instr(AstType.BitInvert); break;
    				case TokenType.Equal: instr(AstType.Equal); break;
    				case TokenType.GreaterThan: instr(AstType.GreaterThan); break;
    				case TokenType.Execute: instr(AstType.Execute); break;
    				case TokenType.ExecuteIf: instr(AstType.ExecuteIf); break;
    				case TokenType.While: instr(AstType.While); break;
    				case TokenType.Getc: instr(AstType.Getc); break;
    				case TokenType.Putc: instr(AstType.Putc); break;
    				case TokenType.PrintInt: instr(AstType.PrintInt); break;
    				case TokenType.Flush: this.#next(); break; // no-op
    				case TokenType.Asm:
    					this.#next();
    					// @ts-ignore https://github.com/Microsoft/TypeScript/issues/9998
    					if (this.#currentToken.type === TokenType.Integer) {
    						this.#next();
    						throw new Error(`Assembly is not supported`);
    					}
    					else {
    						throw new Error(`Syntax error: Expected a short`);
    					}
    			}
    		}
    
    		return statements;
    	}
    
    	#next() {
    		const { value, done } = this.#tokenizer.next();
    		this.#currentToken = done ? null : value;
    	}
    }
    
    export function parse(source: string) {
    	const tokenizer = new Tokenizer(source);
    	const parser = new Parser(tokenizer);
    	return parser.parseStatements();
    }
    
    tokenizer.ts 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
    export enum TokenType {
    	Variable,
    	String,
    	Integer, // Including chars such as 'A
    	OpenBracket,
    	CloseBracket,
    	GetVar,
    	SetVar,
    	Dup,
    	Discard,
    	Swap,
    	Rotate,
    	Take,
    	Plus,
    	Minus,
    	Mul,
    	Div,
    	Negate,
    	BitAnd,
    	BitOr,
    	BitInvert,
    	Equal,
    	GreaterThan,
    	Execute,
    	ExecuteIf,
    	While,
    	Getc,
    	Putc,
    	PrintInt,
    	Flush,
    	Asm,
    }
    
    type ValueToken =
    	| { type: TokenType.Variable, value: string }
    	| { type: TokenType.String, value: string }
    	| { type: TokenType.Integer, value: number }
    
    type NonValueToken = { type: Exclude<TokenType, ValueToken['type']> }
    
    export type Token = ValueToken | NonValueToken
    
    export class Tokenizer implements Iterable<Token>, Iterator<Token, null>{
    	static readonly symbols: ReadonlyMap<string, NonValueToken> =
    		new Map<string, NonValueToken>(([
    			['[', TokenType.OpenBracket],
    			[']', TokenType.CloseBracket],
    			[';', TokenType.GetVar],
    			[':', TokenType.SetVar],
    			['$', TokenType.Dup],
    			['%', TokenType.Discard],
    			['\\', TokenType.Swap],
    			['@', TokenType.Rotate],
    			['O', TokenType.Take],
    			['+', TokenType.Plus],
    			['-', TokenType.Minus],
    			['*', TokenType.Mul],
    			['/', TokenType.Div],
    			['_', TokenType.Negate],
    			['&', TokenType.BitAnd],
    			['|', TokenType.BitOr],
    			['~', TokenType.BitInvert],
    			['=', TokenType.Equal],
    			['>', TokenType.GreaterThan],
    			['!', TokenType.Execute],
    			['?', TokenType.ExecuteIf],
    			['#', TokenType.While],
    			['^', TokenType.Getc],
    			[',', TokenType.Putc],
    			['.', TokenType.PrintInt],
    			['B', TokenType.Flush],
    			['`', TokenType.Asm],
    		] as const).map(([sym, type]) => [sym, { type }]))
    
    	#source: string;
    	#pos: number;
    
    	get #currentChar(): string { return this.#source[this.#pos]; }
    
    	constructor(source: string) {
    		this.#source = source;
    		this.#pos = 0;
    	}
    
    	[Symbol.iterator](): Tokenizer { return this; }
    
    	next(): IteratorResult<Token, null> {
    		while (this.#pos < this.#source.length) {
    			if (/\s/.test(this.#currentChar)) { ++this.#pos; continue; }
    			if (this.#currentChar === '{') { this.#skipComment(); continue; }
    
    			if (this.#currentChar === '\'') { return { value: this.#nextChar() }; }
    			if (this.#currentChar === '"') { return { value: this.#nextString() }; }
    			if ('0' <= this.#currentChar && this.#currentChar <= '9') { return { value: this.#nextNumber() }; }
    			if ('a' <= this.#currentChar && this.#currentChar <= 'z') { return { value: this.#nextVariable() }; }
    
    			const sym = Tokenizer.symbols.get(this.#currentChar);
    			if (sym) {
    				++this.#pos;
    				return { value: sym };
    			}
    
    			throw new Error(`Invalid character: ${this.#currentChar}`);
    		}
    		return { value: null, done: true };
    	}
    
    	#nextVariable(): Token {
    		const variable = this.#currentChar;
    		++this.#pos;
    		return {
    			type: TokenType.Variable,
    			value: variable
    		};
    	}
    
    	#skipComment(): void {
    		while (this.#pos < this.#source.length && this.#currentChar !== '}') {
    			++this.#pos;
    		}
    		this.#eat('}', "Unclosed comment");
    	}
    
    	#nextNumber(): Token {
    		const start = this.#pos;
    		while ('0' <= this.#currentChar && this.#currentChar <= '9') {
    			++this.#pos;
    		}
    		return {
    			type: TokenType.Integer,
    			value: parseInt(this.#source.substring(start, this.#pos))
    		};
    	}
    
    	#nextChar(): Token {
    		this.#eat('\'');
    		if (this.#currentChar) {
    			const value = this.#currentChar.charCodeAt(0);
    			++this.#pos;
    			return { type: TokenType.Integer, value };
    		}
    		else {
    			throw new Error(`Expected a character`);
    		}
    	}
    
    	#nextString(): Token {
    		this.#eat('"');
    		const start = this.#pos;
    		while (this.#pos < this.#source.length && this.#currentChar !== '"') {
    			++this.#pos;
    		}
    		const result = this.#source.substring(start, this.#pos);
    		this.#eat('"');
    
    		return {
    			type: TokenType.String,
    			value: result
    		};
    	}
    
    	#eat(char: string, errorMessage?: string): void {
    		if (this.#currentChar === char) {
    			++this.#pos;
    		}
    		else {
    			throw new Error(errorMessage ?? `Expected ${char}, got ${this.#currentChar} instead`);
    		}
    	}
    }
    

    entry #14

    written by razetime
    submitted at
    1 like

    guesses
    comments 0

    post a comment


    sotrue.vim 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
    " Made In Emacs
    " Tested In VIM - Vi IMproved 8.1
    " Open File
    " Enter Insert Mode, Type In Your Program
    " Enter Normal Mode, Type :so sotrue.vim<RET> 
    
    " Nested Comments Are Supported
    
    let program = join(getline(1, '$'), "\n")
    
    " remove comments and find strings
    let s:index = 0
    let s:tokens = []
    while s:index < program->len()
       let item = program[s:index]
       if item == '{' " comment '{'
          let start = s:index
          let depth = 1
          let s:index = s:index + 1
          while depth != 0 " close comment '}'
             let depth = depth + (program[s:index] == '{') - (program[s:index] == '}')
             let s:index = s:index + 1
          endwhile
          let s:index = s:index - 1
       elseif item == '"' " string '"'
          let start = s:index + 1
          let s:index = s:index + 1
          while program[s:index] != '"'
             let s:index = s:index + 1
          endwhile
          let s:tokens = s:tokens->add(["print",program[start:s:index-1]])
       elseif item =~# '\d'
          let num = 0
          while program[s:index] =~# '\d'
             let num = num * 10 + str2nr(program[s:index])
             let s:index = s:index + 1
          endwhile
          let s:index = s:index - 1
          let s:tokens = s:tokens->add(["num",num])
       elseif item == "'"
          let s:tokens = s:tokens->add(["num",char2nr(program[s:index + 1])])
          let s:index = s:index + 1
       elseif item == '[' || item == ']'
          let s:tokens = s:tokens->add(["sq",program[s:index:s:index]])
       elseif item =~# '[a-z]'
          let s:tokens = s:tokens->add(["var",program[s:index:s:index]])
       elseif item =~# '\s'
       else
          let s:tokens = s:tokens->add(["cmd",program[s:index:s:index]])
       endif 
       let s:index = s:index + 1
    endwhile
    
    
    " parse quotations
    let s:stk = []
    let s:topquot = []
    for [type,data] in s:tokens
       if type == "sq" && data == "["
          let s:stk = add(s:stk, s:topquot)
          let s:topquot = []
       elseif type == "sq" && data == "]"
          let tmp = remove(s:stk, -1)
          let s:topquot = add(tmp,["quot",s:topquot])
          " pop from stk, add topquot to it, add it to top quot
       else
          let s:topquot = add(s:topquot, [type,data])
       endif
    endfor
    
    " run the program
    let s:plen = len(s:topquot)
    let s:pptrs = [] " program pointers
    let s:cstk = [] " call stack
    let s:vars = {} " variables in the FALSE program
    let s:cptr = 0 " current execution point
    let s:cprg = s:topquot " current quotation to execute, starting at full program
    
    " for while mainly
    let s:mode = "exec"
    let s:sndq = []  " stores quote for while loop
    
    
    let s:mstk = []
    while s:cptr < s:plen
       if s:cptr >= len(s:cprg) " handle quots
          if s:mode == "whilecond"
             if remove(s:mstk, -1) != 0
                let temp = s:cprg
                let s:cprg = s:sndq
                let s:sndq = temp
                let s:cptr = -1
                let s:mode = "whilebody"
             else " lower level of nesting.
                let [mo,cp,pr,sn] = remove(s:cstk, -1)
                let s:mode = mo
                let s:cptr = cp 
                let s:cprg = pr
                let s:sndq = sn
             endif
          elseif s:mode == "whilebody"
             let temp = s:cprg
             let s:cprg = s:sndq
             let s:sndq = temp
             let s:cptr = -1
             let s:mode = "whilecond" 
          elseif s:mode == "exec"
             let [mo,cp,pr,sn] = remove(s:cstk, -1)
             let s:mode = mo
             let s:cptr = cp 
             let s:cprg = pr
             let s:sndq = sn
          endif
       else
          let [type, data] = s:cprg[s:cptr]
          if type == 'cmd'
             if data == ';'
                let a = remove(s:mstk, -1)
                call add(s:mstk, vars[a])
             elseif data == ':'
                let a = remove(s:mstk, -1)
                let b = remove(s:mstk, -1)
                let s:vars[a] = b
             elseif data == '$'
                call add(s:mstk, deepcopy(s:mstk[-1]))
             elseif data == '%'
                call remove(s:mstk, -1)
             elseif data == '\'
                let s:mstk[-2:-1] = reverse(s:mstk[-2:-1])
             elseif data == '@'
                call add(s:mstk,remove(s:mstk,-3))
             elseif data == 'O'
                let a = remove(s:mstk, -1)
                call add(s:mstk,deepcopy(s:mstk[a]))
             elseif data == '+' 
                let a = remove(s:mstk, -1)
                let b = remove(s:mstk, -1)
                call add(s:mstk,a+b)
             elseif data == '-' 
                let a = remove(s:mstk, -1)
                let b = remove(s:mstk, -1)
                call add(s:mstk,a-b)
             elseif data == '*' 
                let a = remove(s:mstk, -1)
                let b = remove(s:mstk, -1)
                call add(s:mstk,a*b)
             elseif data == '/' 
                let a = remove(s:mstk, -1)
                let b = remove(s:mstk, -1)
                call add(s:mstk,a/b)
             elseif data == '_'
                call add(s:mstk,-remove(s:mstk,-1))
             elseif data == '&'
                let a = remove(s:mstk, -1)
                let b = remove(s:mstk, -1)
                call add(s:mstk,str2nr(system($"echo $(({a}&{b}))")))
             elseif data == '|'
                let a = remove(s:mstk, -1)
                let b = remove(s:mstk, -1)
                call add(s:mstk,str2nr(system($"echo $(({a}|{b}))")))
             elseif data == '~'
                let a = remove(s:mstk, -1)
                call add(s:mstk,str2nr(system($"echo $((~{a}))")))
             elseif data == '='
                let a = remove(s:mstk, -1)
                let b = remove(s:mstk, -1)
                call add(s:mstk, a == b ? -1 : 0)
             elseif data == '>'
                let a = remove(s:mstk, -1)
                let b = remove(s:mstk, -1)
                call add(s:mstk, b > a ? -1 : 0)
             elseif data == '!'
                call add(s:cstk, [s:mode, s:cptr, copy(s:cprg), copy(s:sndq)])
                let s:mode = "exec"
                let s:cptr = -1
                let s:cond = []
                let s:cprg = remove(s:mstk, -1)
             elseif data == '?'
                let a = remove(s:mstk, -1)
                let b = remove(s:mstk, -1)
                if a != 0
                   call add(s:cstk, [s:mode, s:cptr, copy(s:cprg), copy(s:sndq)])
                   let s:mode = "exec"
                   let s:cptr = -1
                   let s:cond = []
                   let s:cprg = a
                endif
             elseif data == '#'
                let a = remove(s:mstk, -1)
                let b = remove(s:mstk, -1)
                call add(s:cstk, [s:mode, s:cptr, copy(s:cprg), copy(s:sndq)])
                let s:mode = "whilecond"
                let s:cptr = -1
                let s:sndq = a
                let s:cprg = b
             elseif data == '^'
                call add(s:mstk, getchar())
             elseif data == ','
                echo nr2char(remove(s:mstk, -1))
             elseif data == '.'
                echo remove(s:mstk, -1)
             else
                throw 'Invalid Instruction' + data
             endif
          elseif type == 'var'
             call add(s:mstk, data)
          elseif type == 'quot'
             call add(s:mstk, data)
          elseif type == 'num'
             call add(s:mstk, data)
          elseif type == 'print'
             echon data
          else
          endif
       endif
       let s:cptr = s:cptr + 1 
    endwhile