├── LICENSE ├── README.md ├── aoc22 ├── README.md ├── aoc1.c ├── aoc2.c ├── aoc3.c ├── aoc4.c ├── aoc5.c ├── aoc6.c ├── aoc7.c ├── common.c └── inputs │ ├── 1.c │ ├── 1.txt │ ├── 2.c │ ├── 2.txt │ ├── 3.c │ ├── 3.txt │ ├── 4.c │ ├── 4.txt │ ├── 5.c │ ├── 5.txt │ ├── 6.c │ ├── 6.txt │ ├── 7.c │ ├── 7.txt │ └── convert.sh └── boline ├── boline.c └── cm.c /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Olaf Bernstein 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |
code.c | output |
15 | 16 | ```c 17 | #include "boline/boline.c" 18 | B_IF(1)(true)(false) 19 | B_UNLESS(1)(true) 20 | B_WHEN(1)(true) 21 | 22 | #define TRUE 1 23 | B_IFe(FALSE)(false)(true) 24 | B_UNLESSe(FALSE)(false) 25 | B_WHENe(FALSE)(flase) 26 | ``` 27 | 28 | | 29 | 30 | ```c 31 | 32 | true 33 | 34 | true 35 | 36 | false 37 | false 38 | 39 | ``` 40 | 41 | |
code.c | output |
49 | 50 | ```c 51 | #include "boline/boline.c" 52 | #define MYWORD word 53 | #define EQ_word_word ,1 54 | B_CHECK0(B_CATe(EQ_word_,MYWORD)) 55 | 56 | #define BRANCH__word1 ,BRANCH_1 57 | #define BRANCH__word2 ,BRANCH_2 58 | B_CHECK(B_CATe(BRANCH__,MYWORD),BRANCH_DEFAULT) 59 | ``` 60 | 61 | | 62 | 63 | ```c 64 | 65 | 66 | 67 | 1 68 | 69 | 70 | 71 | BRANCH_DEFAULT 72 | ``` 73 | 74 | |
code.c | output |
81 | 82 | ```c 83 | #include "boline/boline.c" 84 | B1_ANDe(1, B1_OR(1, 0)) 85 | B1_ANDe(1, B1_OR(0, 0)) 86 | B1_XORe(B1_NOTe(B1_ANDe(1, 0)), B1_OR(1, 1)) 87 | ``` 88 | 89 | | 90 | 91 | ```c 92 | 93 | 1 94 | 0 95 | 0 96 | ``` 97 | 98 | |
code.c | output |
105 | 106 | ```c 107 | #include "boline/boline.c" 108 | B8_HEX(B8(1,f)) 109 | B16_HEX(B16(1,2,3)) 110 | B32_HEX(B32(1,2,3,4,5,6)) 111 | B64_HEX(B64(1,2,3,4,5,6,7,8,9,a,b,c,d,e,f)) 112 | 113 | B8_HEX(B8_FROM_Bn(B32(1,2,3,4,5,6))) 114 | B32_HEX(B32_FROM_Bn(B8(1,2))) 115 | 116 | B16_HEX(B16_2(1,2)) 117 | B16_HEX(B16_0) 118 | 119 | B16(1,2) // internal representation 120 | ``` 121 | 122 | | 123 | 124 | ```c 125 | 126 | 0x1f 127 | 0x0123 128 | 0x00123456 129 | 0x0123456789abcdef 130 | 131 | 0x56 132 | 0x00000012 133 | 134 | 0x0012 135 | 0x0000 136 | 137 | (2,1,0,0) 138 | ``` 139 | 140 | |
code.c | output |
147 | 148 | ```c 149 | #include "boline/boline.c" 150 | B32_HEX(B32_ADD(B32(1,2,3), B32(1,a))) 151 | B32_HEX(B32_MUL(B32(1,2,3), B32(1,a))) 152 | B32_HEX(B32_UDIV(B32(1,2,3), B32(1,a))) 153 | B32_HEX(B32_UREM(B32(1,2,3), B32(1,a))) 154 | 155 | B32_HEX(B32_INC(B32(1,2,0))) 156 | B32_HEX(B32_DEC(B32(1,2,0))) 157 | B32_HEX(B32_NOT(B32(1,f,0))) 158 | B32_HEX(B32_NEG(B32(1))) 159 | B32_HEX(B32_ABS(B32_DEC(B32_0))) 160 | 161 | B8_HEX(B8_AND(B8(3,7),B8(9,4))) 162 | B8_HEX(B8_OR(B8(3,7),B8(9,4))) 163 | B8_HEX(B8_XOR(B8(3,7),B8(9,4))) 164 | ``` 165 | 166 | | 167 | 168 | ```c 169 | 170 | 0x0000013d 171 | 0x00001d8e 172 | 0x0000000b 173 | 0x00000005 174 | 175 | 0x00000121 176 | 0x0000011f 177 | 0xfffffe0f 178 | 0xffffffff 179 | 0x00000001 180 | 181 | 0x14 182 | 0xb7 183 | 0xa3 184 | ``` 185 | 186 | |
code.c | output |
193 | 194 | ```c 195 | #include "boline/boline.c" 196 | B32_LT(B32(a,3), B32(1,2)) 197 | B32_GT(B32(a,3), B32(1,2)) 198 | B32_EQ(B32(a,3),B32(a,3)) 199 | B32_NE(B32(a,3),B32(a,3)) 200 | B32_IS_0(B32(a,3)) 201 | B32_IS_NEG(B32_DEC(B32_0)) 202 | ``` 203 | 204 | | 205 | 206 | ```c 207 | 208 | 0 209 | 1 210 | 1 211 | 0 212 | 0 213 | ``` 214 | 215 | |
code.c | output |
224 | 225 | ```c 226 | #include "/home/camel/git/boline/boline/boline.c" 227 | 228 | M8_AT(B8(4,2),M8_PUT(B8(1,2),X,M8_PUT(B8(4,2),Y,))) 229 | M8_PUT(B8(1,e),X,) 230 | M8_PUT(B8(2,0),Z,M8_PUT(B8(1,f),Y,M8_PUT(B8(1,e),X,))) 231 | ``` 232 | 233 | | 234 | 235 | ```c 236 | 237 | 238 | Y 239 | (,(,,,,,,,,,,,,,,X,),,,,,,,,,,,,,,) 240 | (,(,,,,,,,,,,,,,,X,Y),(Z,,,,,,,,,,,,,,,),,,,,,,,,,,,,) 241 | ``` 242 | 243 | |
code.c | output |
252 | 253 | ```c 254 | #include "boline/boline.c" 255 | #include "boline/cm.c" 256 | 257 | #define SUM_PROPE(...) ,SUM_NEXT 258 | #define CM_0sum(P,total,x,...) B_CHECK(SUM_PROPE x,SUM_END)(,total,x,P##__VA_ARGS__) 259 | #define SUM_END(P,total,...) ) B16_HEX(total) 260 | #define SUM_NEXT(P,total,x,...) (,0sum,B16_ADD(total,x),P##__VA_ARGS__) 261 | 262 | #define SUM(...) CM(,0sum,B16_0,__VA_ARGS__,0end) 263 | 264 | SUM(B16(1),B16(a),B16(1,2),B16(a,f),B16(1,1,1,1)) 265 | ``` 266 | 267 | | 268 | 269 | ```c 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 0x11dd 281 | ``` 282 | 283 | |
inputs/N.txt | inputs/N.c |
15 | 16 | ```c 17 | Hello World 18 | ``` 19 | 20 | | 21 | 22 | ```c 23 | #define INPUT 48,65,6c,6c,6f,20,57,6f,72,6c,64,0a 24 | ``` 25 | 26 | |