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