6XHALMLUA5B5BBYFSWIFHSJ2BXCL6RSAW5TCKRGJEI2LURH2TQ4AC
while((AWK " -f tmpl-depends.awk -v TARGET=\"" fn "\" " fn | getline) > 0)
# When we are trying to find dependencies, image.awk may well not
# exist, and in any case it will never @include anything; so avoid
# a fatal error by ignoring it.
if(fn != "image.awk")
while((AWK " -f tmpl-depends.awk -v TARGET=\"" TARGET "\" " fn | getline) > 0)
# (setq mapcar \
# (lambda (f a) \
# (label \
# ((map (lambda (a r) \
# (cond ((eq a nil) (nreverse r)) \
# (true (map (cdr a) \
# (cons (f (car a)) \
# r))))))) \
# (map a nil))))
function _assoc(sym, alis) {
logg_dbg("_assoc", "looking for " sym)
# _car(alis) is the first pair; _caar(alis) is the name
for(; !_is_null(alis) && _falsy(_eq(_caar(alis), sym));
alis=_cdr(alis)) {
logg_dbg("_assoc", "is it " _repr(_car(alis)) "?")
}
if(_is_null(alis)) # we did not find sym.
return _nil()
else {
logg_dbg("_assoc", "found: " _car(alis) " containing " _repr(_car(alis)))
return _car(alis)
}
}
function _expand(form, car, mpair, app, acc) {
if(_truthy(_atom(form))) {
# "atoms cannot be macro applications," LFN p.168
return form
} else {
car = _car(form)
if(car == _symbol("quote")) {
# don't expand macros inside quote calls
return form
} else {
mpair = _assoc(car, _MACROS)
if(_is_null(mpair)) {
# expand everything in form. don't worry, form is a
# list (see first case).
for(acc=_nil(); !_is_null(form); form=_cdr(form)) {
# TODO
# acc=_cons(acc)
}
return _nreverse(acc)
} else {
# a macro call!
return _expand(_eval(_cons(_cadr(mpair))))
}}}}
}
function _assoc(sym, alis) {
logg_dbg("_assoc", "looking for " sym)
# _car(alis) is the first pair; _caar(alis) is the name
for(; !_is_null(alis) && _falsy(_eq(_caar(alis), sym));
alis=_cdr(alis)) {
logg_dbg("_assoc", "is it " _repr(_car(alis)) "?")
}
if(_is_null(alis)) # we did not find sym.
return _nil()
else {
logg_dbg("_assoc", "found: " _car(alis) " containing " _repr(_car(alis)))
return _car(alis)
}
}
function _addmacro(name, fun, existing, a) {
existing = _assoc(name, _MACROS)
if(_is_null(existing)) {
_MACROS = _cons(_cons(name, _cons(fun, _nil())), _MACROS)
} else {
# replace existing definition
_set_cdr(existing, _cons(fun, _nil()))
}
return name
Run ~make~. It will build all the source into one file, ~glotawk~. You
can run that one, ~./glotawk~, and it'll show you a REPL prompt.
- When under a BSD: Run ~make depend~, then ~make~.
- When using GNU make: Just run ~make~.
It will build all the source into one file, ~glotawk~, and run the
tests. Then you can run that file, ~./glotawk~, and it'll show you a
REPL prompt.
.MAKE: .depend
# SPDX-License-Identifier: BSD-2-Clause
include Makefile
GNUmakefile: .depend
-include .depend