E.A.L. - Syntax

EAL (Easy Algorithmic Language) is a simple demo-language for a compiler written in JavaScript for Netscape 3.0 or compatible (JavaScript1.0 with array-object). EAL uses a "lean" ALGOL-like syntax. The syntax in EBNF (Extended Backus-Naur Form) is specified below: <program> ::= <block>'.'. <block> ::= [CONST <identifier>'='<number> {',' <identifier>'='<number>}';'] [VAR <identifier>{',' <identifier>}';'] {FUNCTION <identifier>';' <block>';'} <statement>. <statement> ::= [<identifier>':='<expression> | CALL <identifier> | ASK <identifier> | TELL <expression> | BEGIN <statement> {';' <statement>} END | IF <condition> THEN <statement> {';' <statement>} [ELSE <statement> {';' <statement>}] ENDIF| WHILE <condition> DO <statement> | <comment>]. <condition> ::= <expression> ('='|'#'|'<'|'<='|'>'|'>=') <expression> | ODD <expression>. <expression> ::= ['+'|'-'] <term> {('+'|'-') <term>}. <term> ::= <factor> {('*'|'/') <factor>}. <factor> ::= <identifier> | <number> | '('<expression>')'. <number> ::= <digit>{<digit}. <digit> ::= 0|1|2|3|4|5|6|7|8|9. <identifier> ::= <letter>{<letter>|<digit>}. <letter> ::= a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z| A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z. <comment> ::= '{'{<us-ascii>}'}'.  
Have a look at a short example.

us-ascii ... any us-ascii character but '}'.
ASK ... simple input.
TELL ... simple output.
identifiers and keywords are case sensitive.
data is integer only.

How to use:
Type or paste your program into the "Program"-window.
Press "Compile"; any notification will be shown in the "Console"-window.
If the compiliation results without errors, press "Run" to run the program.
(Program input and output will be handled via JavaScript-prompts and -alerts.)
Any runtime or compilation status will be cleared by resetting the corresponding window.

The compilation produces a speed-code stored in listform. The speed-code will be interpreted at runtime.
See the code reference for details.

The compilation progress is logged in the "Console"-window.
Any comments will be included. Use them to mark sections of your program.
Syntax-errors will be marked in the console-output as "[ernr] reason in line nn near 'word'.".
Any runtime input or output will be logged in the console.
If "Trace" is checked while runtime, the interpreter's status will be alerted for every step.
"Log" writes the trace-output to the console.

A short program-listing:

{ greatest common divisor #2 } CONST escapeChar=0; VAR x; FUNCTION calcx; VAR y; BEGIN ASK y; WHILE x # y DO BEGIN IF x > y THEN x := x-y ELSE y := y-x ENDIF; END; END; BEGIN { main } ASK x; WHILE x # escapeChar DO BEGIN CALL calcx; TELL x; ASK x END END. (You can copy & paste this source into the program window. Check "Log" for runtime details.)

N.Landsteiner   02.1999