Node:Eval escapes, Previous:Input File Grammar, Up:Input File Grammar
The text in eval-escape
is Forth code that is evaluated when
Vmgen reads the line. You will normally use this feature to define
stacks and types.
If you do not know (and do not want to learn) Forth, you can build the
text according to the following grammar; these rules are normally all
Forth you need for using Vmgen:
text: stack-decl|type-prefix-decl|stack-prefix-decl|set-flag stack-decl: 'stack ' ident ident ident type-prefix-decl: 's" ' string '" ' ('single'|'double') ident 'type-prefix' ident stack-prefix-decl: ident 'stack-prefix' string set-flag: ('store-optimization'|'include-skipped-insts') ('on'|'off')
Note that the syntax of this code is not checked thoroughly (there are many other Forth program fragments that could be written in an eval-escape).
A stack prefix can contain letters, digits, or :
, and may start
with an #
; e.g., in Gforth the return stack has the stack prefix
R:
. This restriction is not checked during the stack prefix
definition, but it is enforced by the parsing rules for stack items
later.
If you know Forth, the stack effects of the non-standard words involved
are:
stack ( "name" "pointer" "type" -- ) ( name execution: -- stack ) type-prefix ( addr u item-size stack "prefix" -- ) single ( -- item-size ) double ( -- item-size ) stack-prefix ( stack "prefix" -- ) store-optimization ( -- addr ) include-skipped-insts ( -- addr )
An item-size takes three cells on the stack.