Grammar Reference
This is the practical grammar reference for ENG v0.1.0.
Program
program ::= statement* EOF
Variables
Let IDENT be expression.
Make IDENT be expression.
Set IDENT to expression.
Example:
engling
Let x be 5.
Set x to x plus 1.
Output
Print expression.
Show expression.
Display expression.
Show and Display are lexer aliases for Print.
Expressions
Conceptually:
expression
-> or
-> and
-> comparison
-> addition
-> multiplication
-> primary
Primary values include numbers, strings, booleans, identifiers, function calls, and list access.
Conditions
If expression, then
statements
Otherwise
statements
End.
Otherwise is optional.
Repeat
Repeat expression times
statements
End.
While
While expression
statements
End.
Functions
Return form:
Define a function called NAME that takes PARAMETERS and returns EXPRESSION.
Body form:
Define a function called NAME that takes PARAMETERS
statements
End.
nothing represents an empty parameter list.
Calls
Run NAME.
Run NAME with ARGUMENTS.
Call is accepted as a lexer alias for Run.
Lists
Make a list called NAME.
Add EXPRESSION to NAME.
Get the ORDINAL item of NAME.
Set the ORDINAL item of NAME to EXPRESSION.
Print the length of NAME.
Modules
Import NAME.
From NAME use IDENTIFIER.
From NAME use IDENTIFIER and IDENTIFIER.
Comments
Comments run to the end of the line.