
342 Compilers – Principles and Practice
11.4.1 Hello World in Forth
The following FORTH program, which defines a word (a function), is the mandatory “HelloWorld”
program:
: HELLO CR ." Hello, world!" ;
HELLO <cr>
The first line starting with a ‘:’ defines a new word called HELLO, which prints a carriage-return, then
a string “Hello, world!” and then a carriage-return is printed automatically by the FORTH system.
The definition ends with the ‘;’ character.
11.4.2 A Quick Introduction to FORTH
When you invoke the Forth, you will see a startup banner printed and nothing else. Forth is now
running its command line interpreter, which is called the ...