C Language Style Helpers





VFX Forth supports a few "helper" definitions to aid the parsing of "C" header files.

These are especially helpful in the parsing of Windows resource scripts which are based on the Microsoft RC Language for C, and for cutting and pasting from C header files.

: #define       \ <spaces"NAME"> <eol"value-def"> -- ; Exec: -- value
A simple version of C's #define preprocessor command. Any text between the definition name and the end of the line is EVALUATEd when <NAME> is invoked.

: //            \ --
An implementation of the C++ single line comment.

: /*            \ --
A simple implementation of the C "/* ... */" comment.

: enum          \ --
Process an enum of the form:

  enum <name> { a, b, c=10, d };

<name> is ignored. The elements appear as Forth constants. The definition may extend over many lines. C comments may occur after the ',' separator, e.g.

 JIM = 25, // comment about this line

: enum{         \ --
Process an enum of the form:

  enum{ a, b, c=10, d };