Note: This document is a little out of date... look at examples to see the language in use.
Author....... Kevin P. Albrecht Version...... 1.00 Date......... 4 Feb 2004
Identifiers (variables, labels, etc.) must begin with one of the follwing characters: abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ_ The rest of the identifier can be any of the characters below: 0123456789 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ_
Routine calling:
(the parentheses can be omitted when the routine is alone on a line)
NAME
NAME ARG1, ARG2, ...
NAME (ARG1, ARG2, ...)
There must be a "main" routine
Routines can be recursive
rout NAME { :TYPE } { ( ARGUMENT:TYPE { , ... } ) }
CODE
{ return { EXP } }
to immediately terminate the program, use the following routine from "lib.jul" exit
scope is defined by indentation, as in python
indent example
------ -------
0 printn "Hello, World!"
5 {hi} printn "Hello!"
5 c <- x
variable names can be redefined in a deeper scope, which
will hide the original definition of that variable.
#ID { STATEMENT } line label called ID
goto ID goto the line labeled with ID
Warning (goto considered harmful!):
Using "goto" to transfer control to a different routine can
cause major problems. Gotos should only be used to move within
the routine
loop BOOLEAN_EXP
BLOCK
cond _boolean_exp_
_block_
$filename.jul inserts the Juliet file immediately filename extension can be omitted
(items in {} are optional):
print { EXP }
printn { EXP }
cinput
a special string identifier that grabs a string out of the
console; will continue prompting for input until a non-blank
line is input
Variables are automatically initialized as follows:
int: 0
rat: 0.0
str: ""
Variables cannot be used in the same statement they are defined in.
If flow-of-control causes the "def" of a variable to be
passed over after it's original definition, the variable will
be re-initialized
Variables are defined as follows (items in {} are optional):
def ID:TYPE { <- EXP } { , ID:TYPE { <- EXP } } { , ... }
where TYPE = int, rat, or str
Constants are defined as follows:
const ID:TYPE <- EXP { , ID:TYPE <- EXP }
int EXP rat EXP str EXP
{{ single line
{ multiple line }
String: "Hello", "23.4" Integer: 23, -1000 Rational: 23.0 'nl' is a special string variable that contains the newline value Rationals can store up to 6 digits in the mantissa (to the right of the decimal point).
a <- b
where a = variable
b = expression
a = b a <> b (a=num & b=num) | (a=str & b=str) yields: rat a < b a > b a <= b a >= b a or b a and b a=num & b=num yields: rat
a + b
a - b
a * b
a / b
a=num & b=num
yields: if (a|b = rat) then rat
else int
a mod b
a=int & b=int
yields: int
a ^ b
a=num & b=int
yeilds: if a=rat, then rat
if a=int, then int
a & b a=str & b=str yields: str