Skip to content

Commit e3af3e4

Browse files
committed
Lisa constraint/grammar näidislahendus
1 parent 59e3e44 commit e3af3e4

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

src/constraint/grammar/constraint_grammar.ml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ struct
114114
(** Nullable võrrandite paremad pooled.
115115
Järgi täpselt grammatikat ja ära ise lihtsusta! *)
116116
let f (nt: V.t) (get: V.t -> D.t): D.t =
117-
failwith "TODO"
117+
match nt with
118+
| A -> (get B && get A && false) || true
119+
| B -> (false && get B && false) || (get A && get A)
118120
end
119121

120122
module FirstSys =
@@ -128,7 +130,9 @@ struct
128130
Võid eeldada Nullable lahendit.
129131
Järgi täpselt grammatikat ja ära ise lihtsusta! *)
130132
let f (nt: V.t) (get: V.t -> D.t): D.t =
131-
failwith "TODO"
133+
match nt with
134+
| A -> D.join (D.join (get B) (D.join (get A) (D.singleton 'a'))) D.empty
135+
| B -> D.join (D.singleton 'b') (D.join (get A) (get A))
132136
end
133137

134138
module FollowSys =
@@ -146,7 +150,18 @@ struct
146150
Järgi täpselt grammatikat ja ära ise lihtsusta!
147151
Vihje: D.of_list. *)
148152
let f (nt: V.t) (get: V.t -> D.t): D.t =
149-
failwith "TODO"
153+
match nt with
154+
| A -> join_list [
155+
D.singleton '$';
156+
D.singleton 'a';
157+
D.of_list ['a'; 'b'];
158+
get B;
159+
get B;
160+
]
161+
| B -> join_list [
162+
D.of_list ['a'; 'b'];
163+
D.singleton 'c';
164+
]
150165
end
151166
end
152167

0 commit comments

Comments
 (0)