-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathAst.hs
61 lines (48 loc) · 1.16 KB
/
Ast.hs
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
module Ast where
type Prog = [Sent]
data IsRec = Rec | NonRec deriving (Show, Eq)
data Sent
= Def IsRec Idt [Idt] Expr
| Sent Expr
deriving (Show, Eq)
data Expr
= Let IsRec Idt [Idt] Expr Expr
| Fun Idt Expr
| If Expr Expr Expr
| LChar Char
| LString String
| LList [Expr]
| LIdt Idt
| Pipe Expr Expr
| Apply Expr Expr
| Number Integer
| Call Expr
| Next Expr
| Nil
deriving (Show, Eq)
data Idt = Idt String deriving (Show, Eq)
alphas :: [Char]
alphas = ['0'..'9'] ++ ['a'..'z'] ++ ['A'..'Z'] ++ "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
regchars :: [Char]
regchars = " 、。也為如若寧無呼取所也以定「」"
{--
<program> = <sentence>+
<sentence> ::=
<space>* '定' <space>* '再'? <idt>+ '為' <expr> 。<space>* |
<expr> 。<space>*
<expr> ::= <pipe>
<pipe> ::= <apply> (、 <apply>)+
<apply> ::= <atom> (<expr>)+
<atom> :: =
'以' '再'? <idt>+ '為' <pipe> '如' <pipe> |
'若' <pipe> '寧' <pipe> '無' <pipe> |
'字' <pipe> |
('並' <expr>)+ '空' |
「 <string> 」|
<number> |
'呼' <atom> |
'次' <expr> |
<idt> |
'所' <expr> '也'
<idt> ::= <alpha> <char> (- <char>)* | <idt> 之 <idt>
--}