The jal language is free-format (except for comments) and not case-sensitive (except for character literals and possibly include file names). All characters with an ASCII value below the space (tab, carriage return, newline, form feed etc.) are treated as spaces, except that the end of a line terminates a comment.
Jal does not uses statement separators. The only real seperators are the comma's between the (formal or actual) arguments to a procedure or function.
The jal syntax is based on tokes. Tokens must be separated by separators, hence spaces (or other separators) are needed between identifiers, operators etc.
-- if statement in preferred format
if a > b then
a = b + 1
else
a = b - 1
end if
-- but this has exactly the same effect
if a > b then a = b + 1 else a = b - 1 end if
-- comma's between actual arguments
f( a, b, c, d )
A comment is started by the dubble minus token ( -- ) and continues until the end of the line.
-- the next line contains a comment after the assignment
ticks = ticks + 1 -- one more tick
-- the next line contains an error: there is no *-- operator
b = 2 *-- this is not a valid comment
An include causes the content of the included file to be read.
A subsequent include for the same file name will be ignored. This makes it possible for a library file to include all required lower libraries.
Included files are sought first in the current directory, and next in each location indicated by the compilers search path. This feature can be used to override a standard library with a more specific one. Hence the library search path specified to the compiler should mention the more project-specific directories first.
Includes can be nested to any level.
include jjlib -- include the jal standard library
include i2c -- include the i2c library
A jal program is a sequence of statements. Declarations are also considered statements, so declarations can appear almost anywhere in a program.
procedure p is
var byte a -- declaration at start of block
a = 5
var byte b -- declaration between two executable statements
b = a
end procedure
Jal is a block-structured language, so each declaration is visible from its declaration to the end of the block in which the declaration appears (in practice this means to the first end at the current nesting level).
A declaration can hide a declaration of the same name from an enclosing block. A declaration can not hide a name which was already declarared at same nesting level.
var byte b
while b > 0 loop
var bit b -- overrides the byte b
b = false -- the bit b, not the byte
var byte b -- this is an error
end loop