Humus Grammar

This grammar describes the syntax of Humus in terms of tokens, ignoring whitespace and comments.

repl  = stmt+
block = '[' stmt* ']'
stmt  = 'LET' eqtn
      | ('AFTER' expr)? 'SEND' expr 'TO' expr
      | 'CREATE' ident 'WITH' expr
      | 'BECOME' expr
      | 'THROW' expr
      | expr
expr  = 'LET' eqtn 'IN' expr
      | 'IF' eqtn expr ('ELIF' eqtn expr)* ('ELSE' expr)?
      | 'CASE' expr 'OF' (ptrn ':' expr)+ 'END'
      | term ',' expr
      | term
term  = const
      | call
      | ident
      | 'NEW' term
      | '(' expr? ')'
call  = ident '(' expr? ')'
      | '(' expr ')' '(' expr? ')'
eqtn  = ptrn '=' ptrn
      | ident '(' ptrn? ')' '=' expr
ptrn  = pterm ',' ptrn
      | pterm
pterm = '_'
      | const
      | ident
      | '$' term
      | '(' ptrn? ')'
const = block
      | 'SELF'
      | '\' ptrn '.' expr
      | number
      | '?'
      | 'NIL'
      | 'TRUE'
      | 'FALSE'
      | '#' token