forge Documentation

syntax

Syntax

The syntax of FORGE language is similar to many BASIC dialects, with the following main rules:

Line Types

A program line must be one of 4 types:

  1. Comment line - Starting with a dot . or an apostrophe '
  2. Statement - A statement followed by its parameters
  3. Variable assignment - A name followed by = and the expression for the new value. For string variables, there is also a concatenation operator, =+.
  4. Empty line

Case Insensitivity

All statements and variable names can be lower or uppercase, the language is case insensitive.

PRINT "Hello"
print "Hello"
Print "Hello"

All of these are equivalent.

Statement Abbreviations

Statements can be abbreviated to reduce typing; each statement has a different abbreviation.

For example:

  • PRINT can be abbreviated as ?
  • RAND can be abbreviated as R.
  • IF can be abbreviated as I.

See the Statements reference for specific abbreviations.

Multiple Statements Per Line

Multiple statements can be put on the same line by placing a colon : between statements.

A = 10 : B = 20 : PRINT A, B

Comments

After any statement a comment can be included by starting it with an apostrophe '.

PRINT "Hello"  ' This is a comment
A = 10 ' Another comment

Full-line comments can start with either ' or .:

' This is a full-line comment
. This is also a full-line comment

No Line Numbers

No line numbers are allowed. FORGE uses a modern line-based structure without numeric line references.

Optional Spaces

Spaces after statements and between operators are optional and ignored.

PRINT A+B
PRINT A + B
PRINT A+B

All of these are equivalent.

Notation Conventions

In the following chapters, whenever a value can take any numeric expression, it is written as _value_, and whenever you can use a string it is written as *text*.

Examples

Valid Syntax

' Comment line
PRINT "Hello"
A = 10
B$ = "World"
PRINT A, B$

Multiple Statements

A = 10 : B = 20 : PRINT A + B

With Comments

A = 10  ' Initialize counter
PRINT A ' Display value

Next Steps