freebsd-dev/sys/boot/ficl/softwords/softcore.pl
Mike Smith 780ebb4b00 Add the Ficl (Forth Inspired Command Language) interpreter. If all goes well,
this will allow us to manage bloat in the loader by using a bytecoded HLL
rather than lots of C code.  It also offers an opportunity for vendors
or others with special applications to significantly customise the boot
process without having to commit to a divergent code branch.

This early commit is to allow others to experiment with the most effective
mechanisms for integrating FICL with the loader as it currently stands.

Ficl is distributed with the following license conditions:

"Ficl is freeware.  Use it in any way that you like, with the understanding
 that the code is not supported."

All source files contain authorship attributions.

Obtained from:	John Sadler (john_sadler@alum.mit.edu)
1998-11-03 06:11:35 +00:00

90 lines
1.8 KiB
Perl
Executable File

#!/usr/bin/perl
# Convert forth source files to a giant C string
$now = localtime;
print <<EOF
/*******************************************************************
** s o f t c o r e . c
** Forth Inspired Command Language -
** Words from CORE set written in FICL
** Author: John Sadler (john_sadler\@alum.mit.edu)
** Created: 27 December 1997
** Last update: $now
*******************************************************************/
/*
** This file contains definitions that are compiled into the
** system dictionary by the first virtual machine to be created.
** Created automagically by ficl/softwords/softcore.pl
*/
#include "ficl.h"
static char softWords[] =
EOF
;
$commenting = 0;
while (<>) {
s"\n$""; # remove EOL
s"\t" "g; # replace each tab with 4 spaces
s/\"/\\\"/g; # escape quotes
next if /^\s*\\\s*$/;# toss empty comments
next if /^\s*$/; # toss empty lines
if (/^\\\s\*\*/) { # emit / ** lines as C comments
s"^\\ "";
if ($commenting == 0) {
print "/*\n";
}
$commenting = 1;
print "$_\n";
next;
}
if ($commenting == 1) {
print "*/\n";
}
$commenting = 0;
if (/^\\\s#/) { # pass commented preprocessor directives
s"^\\ "";
print "$_\n";
next;
}
next if /^\s*\\ /; # toss all other comments
s"\\\s+.*$"" ; # lop off trailing \ comments
s"\s+$" "; # remove trailing space
#
# emit all other lines as quoted string fragments
#
$out = " \"" . $_ . " \\n\"";
print "$out\n";
}
if ($commenting == 1) {
print "*/\n";
}
print <<EOF
"quit ";
void ficlCompileSoftCore(FICL_VM *pVM)
{
int ret = ficlExec(pVM, softWords);
if (ret == VM_ERREXIT)
assert(FALSE);
return;
}
EOF
;