blob: c8a9e22604e29fffe06a247c4fe07edc1aa9c887 (
plain)
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
|
#!./txr
@(next args)
@
@
@
@(defex option_error error)
@
@
@
@(define match_option (text opt_sym))
@ (cases)
@ (skip)
@ text
@ (bind opt_sym "y")
@ (or)
@ (bind opt_sym "n")
@ (end)
@(end)
@
@
@
@(define match_option_arg (text opt_sym arg_sym))
@ (cases)
@ (skip)
@ text
@ arg_sym
@ (bind opt_sym "y")
@ (or)
@ (skip)
@ text
@ (throw option_error `@text requires arg`)
@ (or)
@ (bind opt_sym "n")
@ (end)
@(end)
@
@
@
@(try)
@ (maybe)
@ (match_option_arg "-a" opt_a opt_arg_a)
@ (or)
@ (match_option "-b" opt_b)
@ (or)
@ (match_option "-c" opt_c)
@ (end)
@ (maybe)
@ (bind opt_a "y")
@ (output)
option a was supplied, with argument @opt_arg_a
@ (end)
@ (or)
@ (bind opt_b "y")
@ (output)
option b was supplied
@ (end)
@ (or)
@ (bind opt_c "y")
@ (output)
option c was supplied
@ (end)
@ (end)
@(catch option_error (arg))
@(output)
error: @arg
@(end)
@(end)
|