2 # Convert forth source files to a giant C string
3 # Joe Abley <jabley@patho.gen.nz>, 12 January 1999
8 printf "/***************************************************************\n";
9 printf "** s o f t c o r e . c\n";
10 printf "** Forth Inspired Command Language -\n";
11 printf "** Words from CORE set written in FICL\n";
12 printf "** Author: John Sadler (john_sadler@alum.mit.edu)\n";
13 printf "** Created: 27 December 1997\n";
14 printf "** Last update: %s\n", strftime();
15 printf "***************************************************************/\n";
17 printf "** This file contains definitions that are compiled into the\n";
18 printf "** system dictionary by the first virtual machine to be created.\n";
19 printf "** Created automagically by ficl/softwords/softcore.awk\n";
21 printf "\n#include \"ficl.h\"\n";
22 printf "\nstatic char softWords[] =\n";
27 # some general early substitutions
29 gsub("\t", " "); # replace each tab with 4 spaces
30 gsub("\"", "\\\""); # escape quotes
31 gsub("\\\\[[:space:]]+$", ""); # toss empty comments
34 # strip out empty lines
40 # emit / ** lines as multi-line C comments
41 /^\\[[:space:]]\*\*/ && (commenting == 0) \
43 sub("^\\\\[[:space:]]", "");
44 printf "/*\n%s\n", $0;
49 /^\\[[:space:]]\*\*/ \
51 sub("^\\\\[[:space:]]", "");
56 # function to close a comment, used later
57 function end_comments()
63 # pass commented preprocessor directives
66 if (commenting) end_comments();
67 sub("^\\\\[[:space:]]", "");
72 # toss all other full-line comments
75 if (commenting) end_comments();
79 # emit all other lines as quoted string fragments
81 if (commenting) end_comments();
83 sub("\\\\[[:space:]]+.*$", ""); # lop off trailing \ comments
84 sub("[[:space:]]+$", ""); # remove trailing spaces
85 printf " \"%s \\n\"\n", $0;
91 if (commenting) end_comments();
92 printf " \"quit \";\n";
93 printf "\n\nvoid ficlCompileSoftCore(FICL_VM *pVM)\n";
95 printf " assert(ficlExec(pVM, softWords) != VM_ERREXIT);\n";