quox/syntax.ebnf

85 lines
2.3 KiB
EBNF
Raw Normal View History

2023-04-23 11:33:50 -04:00
input = {top level}.
top level = load | decl.
decl = namespace | def.
(* top level semicolons are optional because all decls start with a
special word. like in ocaml *)
load = "load", STRING, [";"].
namespace = "namespace", "{", {decl}, "}", [";"].
def = def intro, NAME, [":", term], "=", term, [";"].
def intro = "def0" | "defω" | "def", [qty, "."].
(* "def" with no qty defaults to ω *)
qty = "0" | "1" | "ω".
dim = dim const | name.
dim const = "0" | "1".
dim arg = "@", dim.
pat var = NAME | "_".
2023-08-08 06:48:27 -04:00
term = lambda | case | pi | w | sigma | ann.
2023-04-23 11:33:50 -04:00
lambda = ("λ" | "δ"), {pat var}+, "⇒", term.
case = case intro, term, "return", case return, "of", case body.
(* default qty is 1 *)
case intro = "case0" | "case1" | "caseω" | "case", [qty, "."].
2023-04-23 11:33:50 -04:00
case return = [pat var, "⇒"], term.
case body = "{", {pattern, "⇒", term / ";"}, [";"], "}".
pattern = "zero" | "0"
| "succ", pat var, [",", [qty, "."], pat var]
(* default qty for IH is 1 *)
2023-04-23 11:33:50 -04:00
| TAG
| "[", pat var, "]"
2023-08-08 06:48:27 -04:00
| "(", pat var, ",", pat var, ")"
| pat var, "", pat var, [",", [qty, "."], pat var].
2023-04-23 11:33:50 -04:00
(* default qty is 1 *)
pi = [qty, "."], (binder | term arg), "→", term.
2023-04-23 11:33:50 -04:00
binder = "(", {NAME}+, ":", term, ")".
2023-08-08 06:48:27 -04:00
w = binder, "⊲", ann.
2023-04-23 11:33:50 -04:00
sigma = (binder | ann), "×", (sigma | ann).
ann = infix eq, ["∷", term].
2023-08-08 06:48:27 -04:00
infix eq = sup term, ["≡", term, ":", sup term]. (* dependent is below *)
sup term = app term, ["⋄", app term].
2023-04-23 11:33:50 -04:00
app term = coe | comp | split universe | dep eq | succ | normal app.
split universe = "★", NAT.
dep eq = "Eq", type line, term arg, term arg.
succ = "succ", term arg.
normal app = term arg, {term arg | dim arg}.
(* direction defaults to @0 @1 *)
coe = "coe", type line, [dim arg, dim arg], term arg.
2023-04-23 11:33:50 -04:00
type line = "[", [pat var, "⇒"], term, "]".
comp = "comp", type line, [dim arg, dim arg],
term arg, dim arg, comp body.
2023-04-23 11:33:50 -04:00
comp body = "{", comp branch, ";", comp branch, [";"], "}".
comp branch = dim const, name, "⇒", term.
2023-05-21 14:09:34 -04:00
displacement = SUPER.
term arg = UNIVERSE | "★", SUPER
| "{", {BARE TAG / ","}, [","], "}"
2023-04-23 11:33:50 -04:00
| TAG
| "[", [qty, "."], term, "]"
| ""
| "zero"
| NAT
2023-05-21 14:09:34 -04:00
| QNAME, displacement
| "(", {term / ","}+, [","], ")".