|
|
744572 |
|
|
|
744572 |
#include "parser.c"
|
|
|
744572 |
|
|
|
744572 |
|
|
|
744572 |
void run(U32 count, const char *code) {
|
|
|
744572 |
prepareKeys();
|
|
|
744572 |
Lex *l = lexParse(code);
|
|
|
744572 |
//lexChainPrint(l, stderr); fprintf(stderr, "\n");
|
|
|
744572 |
Op *op = opParse(l);
|
|
|
744572 |
//opPrint(op, stderr, 0);
|
|
|
9e60e5 |
for(U32 t = 0; !count || t < count; ++t) {
|
|
|
744572 |
fputc(asint(opCall(op, t)) & 0xff, stdout);
|
|
|
9e60e5 |
//printf("t%d %d\n", t, asint(opCall(op, t)) & 0xff);
|
|
|
9e60e5 |
}
|
|
|
744572 |
opDestroy(op);
|
|
|
744572 |
free(l);
|
|
|
744572 |
}
|
|
|
744572 |
|
|
|
744572 |
|
|
|
744572 |
void run2(U32 count, const char *codeL, const char *codeR) {
|
|
|
744572 |
prepareKeys();
|
|
|
744572 |
Lex *ll = lexParse(codeL);
|
|
|
744572 |
Lex *lr = lexParse(codeR);
|
|
|
744572 |
Op *opl = opParse(ll);
|
|
|
744572 |
Op *opr = opParse(lr);
|
|
|
744572 |
for(U32 t = 0; !count || t < count; ++t) {
|
|
|
744572 |
fputc(asint(opCall(opl, t)) & 0xff, stdout);
|
|
|
744572 |
fputc(asint(opCall(opr, t)) & 0xff, stdout);
|
|
|
744572 |
}
|
|
|
744572 |
opDestroy(opl);
|
|
|
744572 |
opDestroy(opr);
|
|
|
744572 |
free(ll);
|
|
|
744572 |
free(lr);
|
|
|
744572 |
}
|
|
|
744572 |
|
|
|
744572 |
|
|
|
744572 |
|
|
|
744572 |
int main(int argc, char **argv) {
|
|
|
744572 |
if (argc < 3 || argc > 4) {
|
|
|
744572 |
fprintf(stderr, "Usage:\n bytebeat <count> [<other-channel-code>]\n");</other-channel-code> </count>
|
|
|
744572 |
exit(1);
|
|
|
744572 |
}
|
|
|
744572 |
|
|
|
744572 |
U32 count = (U32)atoll(argv[1]);
|
|
|
744572 |
if (argc >= 4) run2(count, argv[2], argv[3]);
|
|
|
744572 |
else run(count, argv[2]);
|
|
|
744572 |
return 0;
|
|
|
744572 |
}
|
|
|
744572 |
|