/// src/skywrite.h // // Copyright (C) 2026 by Martin Michalec // // SPDX-License-Identifier: MIT // /// Commentary: // /// Code: #include #include #include #include #include "utils.h" #include "da.h" #include "rs274ngc_lexer.h" #include "rs274ngc_cst.h" #include "path.h" #include "critical_points.h" #include "compensations.h" #include "generator.h" void print_arena (const struct arena *a) { for (struct arena_chunk *ch = a->head; ch; ch = ch->next) printf ("%p %lu\n", ch, (void *) ch - ch->begin); } void print_path (struct path path) { DA_FOR_EACH (pe, path) { printf ("%04b | %10.4lf | %10.4lf | %10.4lf | %10.4lf | %10.4lf | %.*s\n", pe->flags, pe->x, pe->y, pe->f, pe->i, pe->j, SV_FMTA (pe->line)); } } int main (int argc, char *argv[]) { progname = argv[0]; const char *filename; int fd = 0; if (argc == 1) { filename = "-"; } else if (argc == 2) { filename = argv[1]; fd = open (filename, O_RDONLY); } else { DIE ("too many arguments provided"); } struct arena a = {0}; struct arena t = {0}; struct sv rs274ngc = read_until_eof (&a, fd); if (fd) close (fd); rs274ngc_lexer_compile_regexes (); struct rs274ngc_lexer lexer = rs274ngc_lexer_from_sv (rs274ngc, filename); struct rs274ngc_cst_parser parser = { .lexer = &lexer, .output = &a, .temporary = &t, }; struct path path = build_path (parser); struct critical_points cps = find_critical_points (&path); struct compensations comps = synthesize_compensations (&cps); struct replacements reps = generate_replacements (&a, &comps); write_code_with_replacements (0, rs274ngc, &reps); return EXIT_SUCCESS; } /// src/skywrite.h ends here