Tcl Library Source Code

Check-in [be24b48161]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2018 Conference, Houston/TX, US, Oct 15-19
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Aug 20.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Adding tests for pt::peg::op realizable and reachable
Timelines: family | ancestors | descendants | both | pt-peg_op-tests-ssoberni
Files: files | file ages | folders
SHA3-256:be24b481617f7dcd7a02cef2ffe8ef7fcbffed944643f5201bb518619da3ba67
User & Date: ssoberni 2018-07-25 12:26:51
Context
2018-08-08
14:28
* pt_peg_op.tcl: Started work on a proper dechain transformation (dechain2); the current dechain logic is entirely broken; added tests check-in: f71a1db4a8 user: ssoberni tags: pt-peg_op-tests-ssoberni
2018-07-25
12:26
Adding tests for pt::peg::op realizable and reachable check-in: be24b48161 user: ssoberni tags: pt-peg_op-tests-ssoberni
2018-07-16
10:54
Adding tests for pt::peg::op called check-in: 6c7e7ee0de user: ssoberni tags: pt-peg_op-tests-ssoberni
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modules/pt/tests/pt_peg_op.tests.

2
3
4
5
6
7
8


9
10
11
12
13
14
15
16
17
18
19
20
21
...
166
167
168
169
170
171
172














































































173
174
175
176
177
178
179
...
212
213
214
215
216
217
218

219




































220
221
222
223
224
225
226
227
# Testsuite for pt::peg::op.

# [ok] drop unreachable
# [ok] drop unrealizable
# [ok] flatten
# [ok] minimize
# [ok] called



# TODO
# [..] dechain
# [..] modeopt
# [..] reachable
# [..] realizable

# -------------------------------------------------------------------------
# Basic syntax

foreach op {
    called
    dechain
................................................................................
	A {is {n A} mode value}
    }
    {n S} {
	S {is {/ {n A} {n A} {n A}} mode value}
	A {is {n A} mode value}
    }
} $setimpl















































































# -------------------------------------------------------------------------
# op: drop unrealizable

TestTransformation "drop unrealizable" {
    # (1) stays as-is
    epsilon {}
................................................................................
	X {is {n X} mode value}
    }
    {n S} {
	S {is {/ {t y}} mode value}
    }
} $setimpl


# -------------------------------------------------------------------------




































# op: drop unrealizable

TestTransformation "drop unreachable" {
    # (1) stays as-is
    epsilon {}
    epsilon {}
    # S <-- a; A <-- a ==> S <-- a (A not reachable, dropped)
    {n S} {







>
>




<
<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|







2
3
4
5
6
7
8
9
10
11
12
13
14


15
16
17
18
19
20
21
...
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
...
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# Testsuite for pt::peg::op.

# [ok] drop unreachable
# [ok] drop unrealizable
# [ok] flatten
# [ok] minimize
# [ok] called
# [ok] realizable
# [ok] reachable

# TODO
# [..] dechain
# [..] modeopt



# -------------------------------------------------------------------------
# Basic syntax

foreach op {
    called
    dechain
................................................................................
	A {is {n A} mode value}
    }
    {n S} {
	S {is {/ {n A} {n A} {n A}} mode value}
	A {is {n A} mode value}
    }
} $setimpl


# -------------------------------------------------------------------------
# op: realizable

set n 0
foreach {inStart inRulesSet expectedSym} [sl {
    # --- just start expression
    epsilon {}
    {{}}
    # -- all realizable, incl. start expression
    {n S} {
	S {is {n X} mode value}
	X {is {t x} mode leaf}
    }
    {{} S X}
    # -- not even start expression
    {n S} {
	S {is {n X} mode value}
	X {is {n X} mode value}
    }
    {}
    # -- not even start expression
    {n S} {
	S {is {n X} mode value}
	X {is {n X} mode value}
    }
    {}
    # -- X is unrealizable
    {n S} {
	S {is {? {n X}} mode value}
	X {is {n X} mode value}
    }
    {{} S}
    # -- X is unrealizable
    {n S} {
	S {is {/ {n X} {t y}} mode value}
	X {is {n X} mode value}
    }
    {{} S}
    # --  X <- 'A' 'B' X / 'C' X 'A'; X is unrealizable
    {n S} {
	S {is {/ {n X} {t y}} mode value}
	X {is {/ {x {t A} {t B} {n X}} {x {t C} {n X} {t A}}} mode value}
    }
    {{} S}
    # --  X <- 'A' 'B' X / 'C' X 'A' / 'x'; X *is* realizable
    {n S} {
	S {is {/ {n X} {t y}} mode value}
	X {is {/ {x {t A} {t B} {n X}} {x {t C} {n X} {t A}} {t x}} mode value}
    }
    {{} S X}
    # -- E is unrealizable
    {n S} {
	S {is {/ {x {n B} {t b}} {x {n C} {t c}} {x {n E} {t e}}} mode value}
	B {is {/ {x {n B} {t b}} {t b}} mode value}
	C {is {/ {x {n C} {t c}} {t c}} mode value}
	E {is {x {n E} {t e}} mode value}
    }
    {{} B C S}
    # -- S remains realizable (*)
    {n S} {
	S {is {* {n X}} mode value}
	X {is {n X} mode value}
    }
    {{} S}
}] {
    test pt-peg-op-set:${setimpl}-realizable.$n {op realizable} -setup {
	pt::peg::container ::In deserialize [g $inStart  $inRulesSet]
    } -body {
	lsort [pt::peg::op realizable ::In]
    } -cleanup {
	::In destroy
    } -result $expectedSym
    incr n
}
unset n


# -------------------------------------------------------------------------
# op: drop unrealizable

TestTransformation "drop unrealizable" {
    # (1) stays as-is
    epsilon {}
................................................................................
	X {is {n X} mode value}
    }
    {n S} {
	S {is {/ {t y}} mode value}
    }
} $setimpl


# -------------------------------------------------------------------------
# op: reachable

set n 0
foreach {inStart inRulesSet expectedSym} [sl {
    # --- none
    epsilon {}
    {}
    # -- D is not reachable
    {n S} {
	S {is {/ {x {n B} {t b}} {x {n C} {t c}} {x {n E} {t e}}} mode value}
	B {is {/ {x {n B} {t b}} {t b}} mode value}
	C {is {/ {x {n C} {t c}} {t c}} mode value}
	D {is {/ {x {n B} {t d}} {x {n C} {t d}} {t d}} mode value}
	E {is {x {n E} {t e}} mode value}
    }
    {B C E S}
    # -- all reachable
    {n S} {
     	S {is {/ {x {n A} {n B}} {t a}} mode value}
     	A {is {x {t a} {n A}} mode value}
	B {is {t a} mode leaf}
    }
    {A B S}
}] {
    test pt-peg-op-set:${setimpl}-reachable.$n {op reachable} -setup {
	pt::peg::container ::In deserialize [g $inStart  $inRulesSet]
    } -body {
	lsort [pt::peg::op reachable ::In]
    } -cleanup {
	::In destroy
    } -result $expectedSym
    incr n
}
unset n

# -------------------------------------------------------------------------
# op: drop unreachable

TestTransformation "drop unreachable" {
    # (1) stays as-is
    epsilon {}
    epsilon {}
    # S <-- a; A <-- a ==> S <-- a (A not reachable, dropped)
    {n S} {