From 866d58d5f691fe670f31448f29d6c30781e83001 Mon Sep 17 00:00:00 2001 From: anon Date: Fri, 6 Dec 2024 21:00:20 +0100 Subject: [PATCH] 2.0 prototype --- Makefile | 17 +++ documentation/notes.md | 52 +++++++ object/.gitkeep | 0 source/generated.h | 138 +++++++++++++++++ source/main.c | 136 +++++++++++++++++ source/main_generator.c | 294 +++++++++++++++++++++++++++++++++++++ source/scanner_scanner.l | 263 +++++++++++++++++++++++++++++++++ test/brainfuck.l | 62 ++++++++ test/c_source_code_str.inc | 50 +++++++ test/hw.bf | 43 ++++++ test/pure_hw.bf | 17 +++ 11 files changed, 1072 insertions(+) create mode 100644 Makefile create mode 100644 documentation/notes.md create mode 100644 object/.gitkeep create mode 100644 source/generated.h create mode 100644 source/main.c create mode 100644 source/main_generator.c create mode 100644 source/scanner_scanner.l create mode 100644 test/brainfuck.l create mode 100644 test/c_source_code_str.inc create mode 100644 test/hw.bf create mode 100644 test/pure_hw.bf diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0230394 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +.PHONY: test + +#main: +# bake main_generator.c +# # im such a fucking genius +# ./main_generator.out 2>&1 | perl -pe "s/(\[.{1,4}\] = 128)/\x1b[90m\1\x1b[0m/g" +# +# +#test: +# ./main_generator.out > generated.h 2> /dev/null +# bake main.c +# ./main.out + +main: + flex --debug -o scanner_scanner.c source/scanner_scanner.l + g++ -D SCANNER_MAIN -o scanner_scanner.out scanner_scanner.c + ./scanner_scanner.out source/scanner_scanner.l diff --git a/documentation/notes.md b/documentation/notes.md new file mode 100644 index 0000000..78e97c4 --- /dev/null +++ b/documentation/notes.md @@ -0,0 +1,52 @@ +# Rationale +now, as it turns out BF + Flex is unholy. +bf ']' requires moving backwards one way or another. + +flex can in fact not do that in any documented way, + theoretically it should be possible to fuck with + the internal pointers using macros and constantly + emptying the buffers, but that does not sound fun. + +What does sound fun however, is writting a mini-flex + which has only the most surface level features, + BUT is fully hackable, embeded friedly with + minimal memory requirements and a somewhat proper subset of flex. + +Another usage could be to scan unconventional info, + for example command line arguments (without UB). + +# CLI +[ ] --debug (dump tables) +[X] --trace +[ ] --table=[static|switch] + +# Syntax + +```lex + // definition section +%% + // rule section +%% + // code section +``` + +## Definitions +``` +%option