From b7022e94d2ab62d522b0a7c2886cce3afaff6872 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 14 May 2000 14:05:10 +0000 Subject: vastly improved awk based code generator now handles recursive function definitions, unions etc it is sufficient for some basic types like UNISTR2 and BUFFER5 to be defined in the *.struct file and used successfully this generator uses templates (in *.tpl files) for all code generation, allowing easy replacement of the backend functions (This used to be commit 14ded82dc92ae6eff7639351f391a33b9cc31c0d) --- source3/aparser/main.awk | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 source3/aparser/main.awk (limited to 'source3/aparser/main.awk') diff --git a/source3/aparser/main.awk b/source3/aparser/main.awk new file mode 100644 index 0000000000..c3e8c2539c --- /dev/null +++ b/source3/aparser/main.awk @@ -0,0 +1,63 @@ +# the main program + +@include dump.awk +@include parsetree.awk +@include header.awk +@include util.awk +@include template.awk +@include parsefn.awk +@include harness.awk + +/^module/ { + start_module($2); + next; +} + +/^test/ { + test=$2; + next; +} + +/^struct.*\{/ { + start_struct($2); + next; +} + +/^[ \t]*union.*\{/ { + start_union($2, $3); + next; +} + +/^[ \t]*case.*;/ { + split($0,a,"[ \t;]*"); + parse_case(a[3],a[4],a[5]); + next; +} + +/^\};/ { + end_struct(); + next; +} + +/^[ \t]*\}/ { + end_union(); + next; +} + +/^[ \t]*\{.*\}.*;/ { + split($0,a,"[ \t;{}]*"); + add_array(a[2], a[3], a[4]); + next; +} + +/.*;/ { + split($0,a,"[ \t;]*"); + add_elem(a[2], a[3]); +} + +END { + dump_structs("debug.out"); + produce_headers("prs_"module".h"); + produce_parsers("prs_"module".c"); + produce_harness("test.h"); +} -- cgit