# generate preparsed forth code in the form of a atom generator (C # program implementing a pfo) # bookkeeping & util 0 variable! linen : init 0 linen ! ; : symbol? type ` symbol = ; : list? type ` list = ; # red tape and sequencing : increment linen @ 1 + linen ! ; : .label linen @ "a%04d" % . ; : .next "next = &&" . increment .label "; return e_ok;" . ; : .sequence .label ": " . ; : .first .sequence "PUSH_PRIMITIVE(pf_plugin_setup); " . .next cr ; : .include >string "#include " . cr ; : .begin (plugin string macros) ' .include for-each "PF_PLUGIN(dummy){" . cr "static void *next = &&a0000;" . cr "goto *next;" . cr ; : .end .sequence "return e_eof;" . cr "}" . cr ; # atoms : .atom symbol? if >string then write ; defer .list : .args "(" . .atom "); " . ; : .thing list? if pass .list then "push_" . dup type >string . .args ; : .line .sequence .thing .next cr ; # recursive lists : .open "{" . cr "pf_stack_t *_s = s;" . cr "pf_stack_t *s = pf_list_new();" . cr ; : .close "pf_stack_push(_s, a_list, (pf_word_t)s);" . cr "} " . cr ; : .thingcr .thing cr ; :: .open reverse ' .thingcr for-each .close ; is .list # entry point : .file "// GENERATED FILE -- DO NOT EDIT" . cr init .begin .first ' .line for-each .end ;