-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrammar.ebnf
56 lines (40 loc) · 1.67 KB
/
grammar.ebnf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Program = PackageDef {Element}.
PackageDef = "package" PackageName.
PackageName = Lowercase {Lowercase}.
Element = (Comment | Newline | Requirement | Thing | Function | FunctionCall | Var | Const).
Comment = CommentStart { Words } Newline.
CommentStart = "//".
Requirement = "require" StdlibRequire | RelativeRequire.
StdlibRequire = "<" {Alpha | Symbol} ">".
RelativeRequire = "\"" {Alpha | Symbol} "\"".
Thing = "thing" Identifier OpenBrace Newline {Super | Internal | Element} Newline CloseBrace.
Super = "super" ExternalIdentifier Newline.
Function = "f" Identifier Args Rocket Args OpenBrace Newline {Element} Newline CloseBrace.
FunctionCall = ExternalIdentifier Args.
Internal = "internal" Identifier Assignment Newline.
Var = "var" Identifier Assignment Newline.
Const = "const" Identifier Assignment Newline.
// First Identifier is a Var name can be omitted or set to "_" to ignore
Arg = [Identifier | "_"] SomeWhitespace Identifier.
Args = OpenBracket {Arg} CloseBracket.
Identifier = {Alpha}.
ExternalIdentifier = Lowercase {Lowercase} "." Uppercase {Alpha}.
Assignment = Arg "=" (Quotes Words Quotes) | Number | Alpha | FunctionCall.
// Just all kinds of arbitrary values and stuff
Lowercase = "a...z".
Uppercase = "A...Z".
Symbol = "[" | "]" | "{" | "}" | "(" | ")" | "<" | ">" | "\\" | "=" | "|" | "." | "." | "/" | "-" | "_".
Numeral = "0...9".
OpenBrace = "{".
CloseBrace = "}".
OpenBracket = "(".
CloseBracket = ")".
Rocket = "->".
Alpha = Lowercase | Uppercase.
Number = Numeral {"." | Numeral}.
ANS = Lowercase | Uppercase | Symbol | Whitespace.
Words = ANS {ANS}.
Quotes = "\"" | "'".
Whitespace = " " | "\t".
SomeWhitespace = Whitespace {Whitespace}.
Newline = "\n" | "\r\n".