-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathast.syn
64 lines (52 loc) · 1.34 KB
/
ast.syn
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
57
58
59
60
61
62
63
64
language Calc
start File
type File
type Expr {
grouping = "(" ")",
}
prod File: File = e:Expr
prod Num: Expr = val:Float
-------------------------------------------------------------------
-- Tokens. These will not be covered in the tutorial, but if you're
-- curious the language fragments defining each of these tokens
-- can be found here:
-- https://github.com/miking-lang/miking/blob/develop/stdlib/parser/lexer.mc
include "lib/prime-lexer.mc"
-- Basic tokens
token String {
repr = StringRepr {},
constructor = StringTok,
fragment = StringTokenParser,
}
token Integer {
repr = UIntRepr {},
constructor = UIntTok,
fragment = UIntTokenParser,
}
token Float {
repr = FloatRepr {},
constructor = FloatTok,
fragment = UFloatTokenParser,
}
token LIdent {
repr = LIdentRepr {},
constructor = LIdentTok,
fragment = LIdentTokenParser,
ty = String,
}
token UIdent {
repr = UIdentRepr {},
constructor = UIdentTok,
fragment = UIdentTokenParser,
ty = String,
}
-- Token types only used through literals
token {fragment = OperatorTokenParser,}
token {fragment = CommaTokenParser,}
token {fragment = SemiTokenParser,}
token {fragment = BracketTokenParser,}
token {fragment = PrimeTokenParser,}
-- Whitespace and comments
token {fragment = LineCommentParser,}
token {fragment = MultilineCommentParser,}
token {fragment = WhitespaceParser,}