parser.nv
· 8.1 KiB · Text
Surowy
Playground
|================================|
|==| Constants. |==|
|================================|
|-----------------------|
| r0 <- 0, r0 | r0 <- 0 ,
| r0 <- 0 | ,
|-----------------------|
|-----------------------|
| r1 <- 0, r1 | r1 <- 0 ,
| r1 <- 0 | ,
|-----------------------|
|-------------------------------|
| r1 <- 1 | r1 ,
| r1 <- 2 | r1 <- 1, r1 <- 1 ,
| r1 <- 4 | r1 <- 2, r1 <- 2 ,
| r1 <- 8 | r1 <- 4, r1 <- 4 ,
| r1 <- 9 | r1 <- 8, r1 <- 1 ,
| r1 <- 10 | r1 <- 9, r1 <- 1 ,
| r1 <- 16 | r1 <- 8, r1 <- 8 ,
| r1 <- 32 | r1 <- 16, r1 <- 16 ,
| r1 <- 40 | r1 <- 32, r1 <- 8 ,
| r1 <- 44 | r1 <- 40, r1 <- 4 ,
|-------------------------------|
|===============================|
|==| Movement. |==|
|===============================|
|-----------------------------|
| r2 <- r0, r0 | r2, r2 <- r0 ,
| r2 <- r0 | ,
|-----------------------------|
|--------------------------------|
| r1 = r2, r2 | r1, r2*, r1 = r2 ,
| r1 = r2 | r2 <- r2* ,
|--------------------------------|
|--------------------------------|
| r0 <- r0*, r0* | r0, r0 <- r0* ,
| r0 <- r0* | ,
|--------------------------------|
|--------------------------------|
| r2 <- r2*, r2* | r2, r2 <- r2* ,
| r2 <- r2* | ,
|--------------------------------|
|============================|
|==| Input. |==|
|============================|
|----------------------------------------------|
| go to the next character | @io-read ,
, , r0 <- 0 ,
, , r0 <- @io-read-in ,
|----------------------------------------------|
|--------------------------------------------------------|
| r0 <- @io-read-in, @io-read-in | r0, r0 <- @io-read-in ,
| r0 <- @io-read-in | ,
|--------------------------------------------------------|
|--------------------|
| @io-read-end | EOF ,
|--------------------|
|===============================|
|==| Equality. |==|
|===============================|
|-----------------------------------------|
| r0 == r1?, r0, r1 | r0*, r0 == r1? ,
|-----------------------------------------|
| r0 == r1?, r1 | r0 <- r0* ,
, , r1 <- 0 ,
, , r0 != r1 ,
|-----------------------------------------|
| r0 == r1?, r0 | r0 ,
, , r0 <- r0* ,
, , r0 != r1 ,
|-----------------------------------------|
| r0 == r1? | r0 <- r0* ,
, , r0 == r1 ,
|-----------------------------------------|
|--------------------------------|
| r0 <- r0*, r0* | r0, r0 <- r0* ,
| r0 <- r0* | ,
|--------------------------------|
|--------------------------------|
| r2 <- r2*, r2* | r2, r2 <- r2* ,
| r2 <- r2* | ,
|--------------------------------|
|==========================================|
|==| Whitespace handling. |==|
|==========================================|
|------------------------------|
| space?, r0 != r1 | ~space ,
| space?, r0 == r1 | space ,
|------------------------------|
| space? | r1 <- 32 ,
, , r0 == r1? ,
, , space? ,
|------------------------------|
|----------------------------|
| tab?, r0 != r1 | ~tab ,
| tab?, r0 == r1 | tab ,
|----------------------------|
| tab? | r1 <- 9 ,
, , r0 == r1? ,
, , tab? ,
|----------------------------|
|--------------------------------|
| newline?, r0 != r1 | ~newline ,
| newline?, r0 == r1 | newline ,
|--------------------------------|
| newline? | r1 <- 10 ,
, , r0 == r1? ,
, , newline? ,
|--------------------------------|
|---------------------------------------------------|
| whitespace?, space | whitespace ,
| whitespace?, tab | whitespace ,
| whitespace?, newline | whitespace ,
| whitespace?, ~space, ~tab, ~newline | ~whitespace ,
|---------------------------------------------------|
| whitespace? | space? ,
, , tab? ,
, , newline? ,
, , whitespace? ,
|---------------------------------------------------|
|-----------------------------------|
| whitespace, ~space | whitespace ,
| whitespace, ~tab | whitespace ,
| whitespace, ~newline | whitespace ,
|-----------------------------------|
|------------------------------------------|
| delimiter?, r0 == r1 | delimiter ,
| delimiter?, r0 != r1 | ~delimiter ,
|------------------------------------------|
| delimiter? | r1 = r2 ,
, , r0 == r1? ,
, , delimiter? ,
|------------------------------------------|
|------------------------------|
| comma?, r0 != r1 | ~comma ,
| comma?, r0 == r1 | comma ,
|------------------------------|
| comma? | r1 <- 44 ,
, , r0 == r1? ,
, , comma? ,
|------------------------------|
|------------------------------------------------------------------------------------------------|
| go to the next non-whitespace character, whitespace | go to the next non-whitespace character ,
| go to the next non-whitespace character, ~whitespace | ,
|------------------------------------------------------------------------------------------------|
| go to the next non-whitespace character | go to the next character ,
, , whitespace? ,
, , go to the next non-whitespace character ,
|------------------------------------------------------------------------------------------------|
|===================================|
|==| Main program. |==|
|===================================|
|-------------------------------------------------|
|| start, left ,
|-------------------------------------------------|
| start | go to the next non-whitespace character ,
, , store delimiter ,
, , parse ,
|-------------------------------------------------|
|-----------------------------------------------------------|
| store delimiter | r2 <- r0 ,
, , go to the next non-whitespace character ,
|-----------------------------------------------------------|
|-------------------------------------------------------------|
| parse, EOF | append token to side, stop ,
|-------------------------------------------------------------|
| parse, delimiter | append token to side ,
, , switch sides ,
, , go to the next non-whitespace character ,
, , parse ,
|-------------------------------------------------------------|
| parse, ~delimiter | comma? ,
, , parse ,
|-------------------------------------------------------------|
| parse, comma | append token to side ,
, , go to the next non-whitespace character ,
, , parse ,
|-------------------------------------------------------------|
| parse, ~comma | append character to token ,
, , go to the next non-whitespace character ,
, , parse ,
|-------------------------------------------------------------|
| parse | delimiter?, ,
, parse ,
|-------------------------------------------------------------|
| 1 | |================================| |
| 2 | |==| Constants. |==| |
| 3 | |================================| |
| 4 | |
| 5 | |-----------------------| |
| 6 | | r0 <- 0, r0 | r0 <- 0 , |
| 7 | | r0 <- 0 | , |
| 8 | |-----------------------| |
| 9 | |
| 10 | |-----------------------| |
| 11 | | r1 <- 0, r1 | r1 <- 0 , |
| 12 | | r1 <- 0 | , |
| 13 | |-----------------------| |
| 14 | |
| 15 | |-------------------------------| |
| 16 | | r1 <- 1 | r1 , |
| 17 | | r1 <- 2 | r1 <- 1, r1 <- 1 , |
| 18 | | r1 <- 4 | r1 <- 2, r1 <- 2 , |
| 19 | | r1 <- 8 | r1 <- 4, r1 <- 4 , |
| 20 | | r1 <- 9 | r1 <- 8, r1 <- 1 , |
| 21 | | r1 <- 10 | r1 <- 9, r1 <- 1 , |
| 22 | | r1 <- 16 | r1 <- 8, r1 <- 8 , |
| 23 | | r1 <- 32 | r1 <- 16, r1 <- 16 , |
| 24 | | r1 <- 40 | r1 <- 32, r1 <- 8 , |
| 25 | | r1 <- 44 | r1 <- 40, r1 <- 4 , |
| 26 | |-------------------------------| |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |===============================| |
| 32 | |==| Movement. |==| |
| 33 | |===============================| |
| 34 | |
| 35 | |-----------------------------| |
| 36 | | r2 <- r0, r0 | r2, r2 <- r0 , |
| 37 | | r2 <- r0 | , |
| 38 | |-----------------------------| |
| 39 | |
| 40 | |--------------------------------| |
| 41 | | r1 = r2, r2 | r1, r2*, r1 = r2 , |
| 42 | | r1 = r2 | r2 <- r2* , |
| 43 | |--------------------------------| |
| 44 | |
| 45 | |--------------------------------| |
| 46 | | r0 <- r0*, r0* | r0, r0 <- r0* , |
| 47 | | r0 <- r0* | , |
| 48 | |--------------------------------| |
| 49 | |
| 50 | |--------------------------------| |
| 51 | | r2 <- r2*, r2* | r2, r2 <- r2* , |
| 52 | | r2 <- r2* | , |
| 53 | |--------------------------------| |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |============================| |
| 59 | |==| Input. |==| |
| 60 | |============================| |
| 61 | |
| 62 | |----------------------------------------------| |
| 63 | | go to the next character | @io-read , |
| 64 | , , r0 <- 0 , |
| 65 | , , r0 <- @io-read-in , |
| 66 | |----------------------------------------------| |
| 67 | |
| 68 | |--------------------------------------------------------| |
| 69 | | r0 <- @io-read-in, @io-read-in | r0, r0 <- @io-read-in , |
| 70 | | r0 <- @io-read-in | , |
| 71 | |--------------------------------------------------------| |
| 72 | |
| 73 | |--------------------| |
| 74 | | @io-read-end | EOF , |
| 75 | |--------------------| |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |===============================| |
| 81 | |==| Equality. |==| |
| 82 | |===============================| |
| 83 | |
| 84 | |-----------------------------------------| |
| 85 | | r0 == r1?, r0, r1 | r0*, r0 == r1? , |
| 86 | |-----------------------------------------| |
| 87 | | r0 == r1?, r1 | r0 <- r0* , |
| 88 | , , r1 <- 0 , |
| 89 | , , r0 != r1 , |
| 90 | |-----------------------------------------| |
| 91 | | r0 == r1?, r0 | r0 , |
| 92 | , , r0 <- r0* , |
| 93 | , , r0 != r1 , |
| 94 | |-----------------------------------------| |
| 95 | | r0 == r1? | r0 <- r0* , |
| 96 | , , r0 == r1 , |
| 97 | |-----------------------------------------| |
| 98 | |
| 99 | |--------------------------------| |
| 100 | | r0 <- r0*, r0* | r0, r0 <- r0* , |
| 101 | | r0 <- r0* | , |
| 102 | |--------------------------------| |
| 103 | |
| 104 | |--------------------------------| |
| 105 | | r2 <- r2*, r2* | r2, r2 <- r2* , |
| 106 | | r2 <- r2* | , |
| 107 | |--------------------------------| |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |==========================================| |
| 113 | |==| Whitespace handling. |==| |
| 114 | |==========================================| |
| 115 | |
| 116 | |------------------------------| |
| 117 | | space?, r0 != r1 | ~space , |
| 118 | | space?, r0 == r1 | space , |
| 119 | |------------------------------| |
| 120 | | space? | r1 <- 32 , |
| 121 | , , r0 == r1? , |
| 122 | , , space? , |
| 123 | |------------------------------| |
| 124 | |
| 125 | |----------------------------| |
| 126 | | tab?, r0 != r1 | ~tab , |
| 127 | | tab?, r0 == r1 | tab , |
| 128 | |----------------------------| |
| 129 | | tab? | r1 <- 9 , |
| 130 | , , r0 == r1? , |
| 131 | , , tab? , |
| 132 | |----------------------------| |
| 133 | |
| 134 | |--------------------------------| |
| 135 | | newline?, r0 != r1 | ~newline , |
| 136 | | newline?, r0 == r1 | newline , |
| 137 | |--------------------------------| |
| 138 | | newline? | r1 <- 10 , |
| 139 | , , r0 == r1? , |
| 140 | , , newline? , |
| 141 | |--------------------------------| |
| 142 | |
| 143 | |---------------------------------------------------| |
| 144 | | whitespace?, space | whitespace , |
| 145 | | whitespace?, tab | whitespace , |
| 146 | | whitespace?, newline | whitespace , |
| 147 | | whitespace?, ~space, ~tab, ~newline | ~whitespace , |
| 148 | |---------------------------------------------------| |
| 149 | | whitespace? | space? , |
| 150 | , , tab? , |
| 151 | , , newline? , |
| 152 | , , whitespace? , |
| 153 | |---------------------------------------------------| |
| 154 | |
| 155 | |-----------------------------------| |
| 156 | | whitespace, ~space | whitespace , |
| 157 | | whitespace, ~tab | whitespace , |
| 158 | | whitespace, ~newline | whitespace , |
| 159 | |-----------------------------------| |
| 160 | |
| 161 | |------------------------------------------| |
| 162 | | delimiter?, r0 == r1 | delimiter , |
| 163 | | delimiter?, r0 != r1 | ~delimiter , |
| 164 | |------------------------------------------| |
| 165 | | delimiter? | r1 = r2 , |
| 166 | , , r0 == r1? , |
| 167 | , , delimiter? , |
| 168 | |------------------------------------------| |
| 169 | |
| 170 | |------------------------------| |
| 171 | | comma?, r0 != r1 | ~comma , |
| 172 | | comma?, r0 == r1 | comma , |
| 173 | |------------------------------| |
| 174 | | comma? | r1 <- 44 , |
| 175 | , , r0 == r1? , |
| 176 | , , comma? , |
| 177 | |------------------------------| |
| 178 | |
| 179 | |------------------------------------------------------------------------------------------------| |
| 180 | | go to the next non-whitespace character, whitespace | go to the next non-whitespace character , |
| 181 | | go to the next non-whitespace character, ~whitespace | , |
| 182 | |------------------------------------------------------------------------------------------------| |
| 183 | | go to the next non-whitespace character | go to the next character , |
| 184 | , , whitespace? , |
| 185 | , , go to the next non-whitespace character , |
| 186 | |------------------------------------------------------------------------------------------------| |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |===================================| |
| 192 | |==| Main program. |==| |
| 193 | |===================================| |
| 194 | |
| 195 | |-------------------------------------------------| |
| 196 | || start, left , |
| 197 | |-------------------------------------------------| |
| 198 | | start | go to the next non-whitespace character , |
| 199 | , , store delimiter , |
| 200 | , , parse , |
| 201 | |-------------------------------------------------| |
| 202 | |
| 203 | |-----------------------------------------------------------| |
| 204 | | store delimiter | r2 <- r0 , |
| 205 | , , go to the next non-whitespace character , |
| 206 | |-----------------------------------------------------------| |
| 207 | |
| 208 | |-------------------------------------------------------------| |
| 209 | | parse, EOF | append token to side, stop , |
| 210 | |-------------------------------------------------------------| |
| 211 | | parse, delimiter | append token to side , |
| 212 | , , switch sides , |
| 213 | , , go to the next non-whitespace character , |
| 214 | , , parse , |
| 215 | |-------------------------------------------------------------| |
| 216 | | parse, ~delimiter | comma? , |
| 217 | , , parse , |
| 218 | |-------------------------------------------------------------| |
| 219 | | parse, comma | append token to side , |
| 220 | , , go to the next non-whitespace character , |
| 221 | , , parse , |
| 222 | |-------------------------------------------------------------| |
| 223 | | parse, ~comma | append character to token , |
| 224 | , , go to the next non-whitespace character , |
| 225 | , , parse , |
| 226 | |-------------------------------------------------------------| |
| 227 | | parse | delimiter?, , |
| 228 | , parse , |
| 229 | |-------------------------------------------------------------| |