-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathast3.ml
120 lines (117 loc) · 2.58 KB
/
ast3.ml
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
type expr;;
type cmd;; (*готово*)
type pipe;;
type fu;;
type mfor;;
type forList;;
type enumFor;;
type mcase;;
type mif;;
type mwhile;;
type muntil;;
type compList;;
type redirect;; (*готово*)
type word;;
type wordAssign;;
type arifm;; (*готово*)
type cons;;
type logOp;;
type pipeOp;;
type bCommand =
LogicalExpression of expr
| Pipeline of pipe
| Command of cmd
| Function of fu
| For of mfor
| Case of mcase
| If of mif
| While of mwhile
| Until of muntil
;;
type logOp = And | Or | Great | Less | EcGreat | EcLess | Ecual;; (*логические выражения, как их парсить? например обратно 2 раза pattern match?*)
type expr =
(*надо ли еще 1 expr отдельно*)
LogicalExpression of logOp * expr * expr
| Pipeline of pipe
| Command of cmd
| Function of fu
| For of mfor
| Case of mcase
| If of mif
| While of mwhile
| Until of muntil
;;
type pipeOp = And | Or | Dpoint;; (*склейки пайпы || && ;*)
type pipe = (*не работает надо чет придумать*)
Pipline of pipeOp * pipe * pipe
| Command of cmd
| Function of fu
| For of mfor
| Case of mcase
| If of mif
| While of mwhile
| Until of muntil
;;
type cmd =
(*WHAT A FU*K *)
Name of string * string list * redirect (* name command, parametrs, redirection*)
|NameN of string * redirect (* name command, redirection*)
| Arifm of arifm
;;
type arifm =
Ecual of word * arifm (* means a = b or a = 4*)
| Plus of arifm * arifm (* means a + b *)
| Minus of arifm * arifm (* means a - b *)
| Multi of arifm * arifm (* means a * b *)
| Divide of arifm * arifm (* means a / b *)
| Cons of cons (* "x", "y", "n", etc. *)
;;
type fu =
Funct of string * string * compList
;;
type compList =
LogicalExpression of expr
| Pipeline of pipe
| Command of cmd
| Function of fu
| For of mfor
| Case of mcase
| If of mif
| While of mwhile
| Until of muntil
;;
type mfor =
For of forList * compList
;;
type forList =
Arg of word * enumFor
;;
type enumFor =
Listm of word
| Str of string
;;
type mcase =
CaseItem of word * compList
;;
type mif =
Clause of compList * compList * compList (*if then else*)
;;
type mwhile =
Clause of compList * compList (*clause, todoList*)
;;
type muntil =
Clause of compList * compList (*clause, todoList*)
;;
type redirect =
Redirect of string * string * string
;;
type word =
Cons of cons
;;
type cons =
Int of int
| Float of float
| String of string
;;
(*type wordref =
;;*)