module Z
Overview
Basic recursive-descent parser.
The grammar is as follows (basic EBNF notation)
program = (fn | asm)*
fn = ident "(" (indent ",")* ")" "{" stmt* "}"
stmt = expr ";"
| "return" expr ";"
#| declaration
| "{" stmt* "}"
| asm
| "if" "(" expr ")" stmt ("else" stmt)?
| "while" "(" expr ")" stmt
#| "for" "(" expr? ";" expr? ";" expr? ")" stmt
#declaration = type ident ";"
# | type ident "=" assign ";"
expr = assign
assign = equality ("=" assign)?
equality = logical ("==" logical | "!=" logical)*
logical = relational ("&&" relational | "||" relational)*
relational = add ("<" add | "<=" add | ">" add | ">=" add)*
add = mul ("+" mul | "-" mul)*
mul = unary ("*" unary | "/" unary)*
unary = ("+" | "-")? primary
primary = num
| ident
| ident "(" ( ident ",")* ")"
| "(" expr ")"
asm = "asm" "{" asm_instruction_list* "}"
asm_instruction_list = asm_ident
| asm_imm
Defined in:
ast/dot.crast/node.cr
ast/printer.cr
ast/visitor.cr
codegen/codegen.cr
codegen/compiler.cr
parse/parser.cr
version.cr
Constant Summary
-
VERSION =
"0.2.0"