Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
# Scopes
Module <- _ Statement+ _EndOfFile
Code <- _CBOP Statement* _CBCL / Statement
# Expressions
Expression <- Logical
Logical <- BitLogical ((AND / OR) BitLogical)*
BitLogical <- Comparison ((BAND / BXOR / BOR) Comparison)*
Comparison <- BitShifting ((EQ / NEQ / LTE / GTE / LT / GT) BitShifting)*
BitShifting <- Term ((RSHIFT / LSHIFT) Term)*
Term <- Factor ((PLUS / MINUS) Factor)*
Factor <- Power ((STAR / SLASH) Power)*
Power <- Unary ((POWER / MOD) Unary)*
Unary <- (PLUS / MINUS / NOT)? Attribute
Attribute <- Attr (_DOT Attr)*
Attr <- Call / Access / Primary
Call <- Primary CallParams
Access <- Primary _SBOP Slice _SBCL
Slice <- Primary _COLON Primary / Primary
Primary <- _PROP Expression _PRCL
/ Value
/ Lambda
/ Identifier
# Function Declaration
Function <- _FN Identifier Params Code
Lambda <- _FN Params Code
Param <- Identifier (_ASSIGN Expression)?
Params <- _PROP (ParamsMult / ParamsOne / ParamsNone) _PRCL
ParamsMult <- Param (_COMA Param)+
ParamsOne <- Param
ParamsNone <-
# Function Call
CallParams <- _PROP (ListMult / ListOne / ListNone) _PRCL
# Statements
Statement <- BREAK / CONTINUE / ReturnStm / ThrowStm / WhileStm / ForStm / IfStm / TryStm / Function / Assignment / LexAssignment / ExprStm
ExprStm <- Expression
Assignment <- Identifier _ASSIGN Expression
LexAssignment <- _LET Identifier _ASSIGN Expression
# Control Flow Statements
ForStm <- _FOR Store _IN Expression Code
WhileStm <- _WHILE Expression Code
IfStm <- _IF Expression Code ElseStm?
ElseStm <- _ELSE Code
ReturnStm <- _RETURN Expression
ThrowStm <- _THROW Expression
TryStm <- _TRY Code CatchStm+
CatchStm <- (_CATCH Load _AS Store Code)
# Values
Load <- Identifier
Store <- Identifier
# Values
Value <- Number / BOOL / NULL / String / List
Number <- BIN / HEX / FLOAT / DEC
String <- _DQUOTE (!_DQUOTE .)* _DQUOTE _
List <- _SBOP (ListMult / ListOne / ListNone) _SBCL
ListMult <- Expression (_COMA Expression)+
ListOne <- Expression
ListNone <-
# Lexcical Hierarchy
# Values
Identifier <- [a-zA-Z_][a-zA-Z0-9_]* _
DEC <- [0-9]+ _
FLOAT <- [0-9]* '.' [0-9]+ _
BIN <- '0b' [0-1]+ _
HEX <- '0x' [0-9a-fA-F]+ _
BOOL <- ('true' / 'false') _
NULL <- 'null' _
# Keywords
BREAK <- 'break' _
CONTINUE <- 'continue' _
_IN <- 'in' _
_ELSE <- 'else' _
_FOR <- 'for' _
_FN <- 'fn' _
_WHILE <- 'while' _
_IF <- 'if' _
_RETURN <- 'return' _
_THROW <- 'throw' _
_LET <- 'let' _
_TRY <- 'try' _
_CATCH <- 'catch' _
_AS <- 'as' _
# Lexical Delimiters
_DQUOTE <- '"'
_COMA <- ',' _
_COLON <- ':' _
_PROP <- '(' _
_PRCL <- ')' _
_CBOP <- '{' _
_CBCL <- '}' _
_SBOP <- '[' _
_SBCL <- ']' _
_ASSIGN <- '=' _
## Arithmetic Operators
PLUS <- '+' _
MINUS <- '-' _
STAR <- '*' _
SLASH <- '/' _
MOD <- '%' _
POWER <- '**' _
## Comparison Operators
EQ <- '==' _
NEQ <- '!=' _
LT <- '<' _
GT <- '>' _
LTE <- '<=' _
GTE <- '>=' _
## Bit Shifting
RSHIFT <- '>>' _
LSHIFT <- '<<' _
## Binary Bit Operators
BAND <- '&' _
BOR <- '|' _
BXOR <- '^' _
## Logic Operators
AND <- 'and' _
OR <- 'or' _
NOT <- 'not' _
## Member Access Operators
_DOT <- '.' _
# Whitespace Handling
_ <- (Space / Comment)*
Comment <- '#' (!_EOL .)* _EOL
Space <- ' ' / '\t' / _EndOfLine
_EndOfLine <- ';' / _EOL
_EOL <- '\r\n' / '\n' / '\r'
_EndOfFile <- !.