-
Notifications
You must be signed in to change notification settings - Fork 1
The Complete Syntax
Sjoerd Vermeulen edited this page Jun 10, 2022
·
6 revisions
This is the complete syntax of Evi represented in BNF:
program : (func_decl | var_decl)*
declaration : var_decl
| statement
func_decl : "@" "!"? IDENT type "(" type* "..."? ")" (statement | ";")
var_decl : "%" "!"? IDENT ("," IDENT)* type (expression ("," expression)*)? ";"
statement : assignment
| if_stmt
| loop
| return
| block
| expression ";"
assignment : "=" IDENT ("[" expression "]")* expression ";"
if_stmt : "??" "(" expression ")" statement ("::" statement)?
loop : "!!" "(" declaration? expression ";" declaration? ")" statement
return : "~" expression? ";"
block : "{" declaration* "}"
expression : ternary
ternary : logical_or ("?" expression ":" ternary)?
logical_or : logical_xor ("||" logical_xor)*
logical_or : logical_and ("^^" logical_and)*
logical_and : bitwise_or ("&&" bitwise_or)*
bitwise_or : bitwise_xor ("|" bitwise_xor)*
bitwise_xor : bitwise_and ("^" bitwise_and)*
bitwise_and : equality ("&" equality)*
equality : comparison (("!=" | "==") comparison)*
comparison : bitwise_shift ((">" | ">=" | "<" | "<=") bitwise_shift)*
bitwise_shift : term (("<<" | ">>") term)*
term : factor (("-" | "+") factor)*
factor : cast (("/" | "*") cast)*
cast : unary ("->" type)*
unary : ("*" | "&" | "!" | "-" | "++" | "--") unary | subscript
subscript : primary ("[" expression "]")*
primary : NUMBER | CHAR | STRING | "(" expression ")"
| array | size_of | reference | call
array : "{" (expression ("," expression)*)? "}"
size_of : "?" ( "(" type ")" | type )
reference : "$" (IDENT | INTEGER)
call : IDENT "(" (expression ("," expression)*)? ")"
type : ("!")? BASIC_TYPE ("*")*
Next: 9 – Miscellaneous Information
Home | About | Installation | Language Overview | License: MIT 2022 Sjoerd Vermeulen. Terms