gplz.easy
The syntax reads as follows:
SOURCE = STATEMENT {STATEMENT}.
STATEMENT = CODE ['.'|'\n'].
CODE = FUNCTION ':' DESCRIPTION.
FUNCTION = FUNCNAME '(' [ARG {',' ARG}] ')'.
FUNCNAME = NAME | BUILTIN.
BUILTIN = 'if','while','until','do'...
NAME = CHAR { CHAR | DIGIT }.
CHAR = 'a' .. 'z'.
DIGIT = '0' .. '9'.
DESCRIPTION = CODEM {'.' CODEM}
CODEM = ASSIGNMENT | FUNCCALL | PRINT | EXPRESSION.
FUNCCALL = NAME '(' [EXPRESSION {',' EXPRESSION}] ')'.
PRINT = '<<' EXPRESSION
ASSIGNMENT = VARIABLE ('='|'+='|'-='|'*='|'/='|'%='|'|='|'&=') EXPRESSION.
EXPRESSION = OP0 {('<'|'=='|'>'|'<='|'>='|'!=') OP0}.
OP0 = OP1 {('+'|'-')OP1}.
OP1 = OP2 {('*'|'/'|'%')OP2}.
OP2 = OP3 {('|')OP3}.
OP3 = OP4 {('&')OP4}.
OP4 = ['!'] ('(' EXPRESSION ')' | FUNCCALL | VARIABLE | LITERAL).
LITERAL = DECINT.
DECINT = DIGIT {DIGIT}.
VARIABLE = NAME.
Some points to notice:
- .easy files are usually line oriented. every line should contain exactly one function definition of the form "name of function" : "code of function".
- the builtin functions 'while', 'do' etc. have no arguments; rather the first element of the sequence is treated as argument.
Easy.
Example
Hello, .easy World
# HELLO, WORLD in .easy
do:<<"Hello, World"
The following programm will print the first 20 fibonacci numbers
# FIBONACCI in .easy
f(x):i=x.j=x.c=x-x
do:f(1)
while:c<20.<<j.h=j+i.j=i.i=h.c+=1
The first line declares a function f(x) that assigns x to both the variables i and j, and 0 to c. The second line calls the function f(1). The while loop iterates c >= 20, and repeats the sequence "print j, h=j+i, j=i, i=h, c++". Easy.