========================================= Juliet Programming Language Specification Author....... Kevin P. Albrecht Version...... 0.05 Date......... 5 Dec 2002 ========================================= ----------- IDENTIFIERS ----------- 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_ ----- SCOPE ----- scope is defined by indentation, as in python indent example ------ ------- 0 printn "Hello, World!" 5 {hi} printn "Hello!" 5 c <- x ----- STACK ----- push EXP pop VARIABLE --------------- FLOW OF CONTROL --------------- #(identifier) line label goto (identifier) goto the line labeled with (identifier) loop BOOLEAN_EXP BLOCK cond _boolean_exp_ _block_ -------------- FILE INCLUSION -------------- $filename.jul inserts the Juliet file immediately ----------- CONSOLE I/O ----------- print EXP printn EXP cinput a special identifier that grabs a string out of the console -------------------- VARIABLE DEFINITIONS -------------------- Variables are automatically initialized as follows: int: 0 rat: 0.0 str: "" Variables cannot be used in the same statement they are defined in. Variables are defined as follows (items in {} are optional): def ID:TYPE { <- EXP } { , ID:TYPE { <- EXP } } { , ... } where TYPE = int, rat, or str ------------ TYPE CASTING ------------ int EXP rat EXP str EXP -------- COMMENTS -------- {{ single line { multiple line } -------- LITERALS -------- String: "Hello", "23.4" Integer: 23, -1000 Rational: 23.0 'nl' is a special variable that contains the newline value ------------------- ASSIGNMENT OPERATOR ------------------- a <- b where a = variable b = expression --------------- LOGIC OPERATORS --------------- 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 -------------------- ARITHMETIC OPERATORS -------------------- a + b a - b a * b a / b a=num & b=num yields: if (a|b = rat) then rat else int a ^ b a=num & b=int yeilds: if a=rat, then rat if a=int, then int --------------- STRING OPERATOR --------------- a & b a=str & b=str yields: str