summaryrefslogtreecommitdiff
path: root/test/rhsref2.lm
blob: cf5b32388048254d14c7d67b461b168646b858de (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

lex
	literal `- `= `; `* `->
	literal `option

	token id /[A-Za-z_][A-Za-z_0-9]*/

	ignore /[ \t\r\n]+/
end

def arg_option
	I: int
	[`option `- Short: id `-> Func: id `;]
|	[`option `- `- Long: id `-> Func: id `;]

def arg_defs
	[arg_option+]

def input [ arg_defs ]

def program
	[Input: input]

parse Input: input[stdin]
cons P: program [ Input ]

I: int = 1

for AO: arg_option in P {
	if AO.Long {
		AO.I = I
		I = I + 1
	}
}

I = 1

for AO: arg_option in P {
	if AO.Short
		print( ^AO.Short ' ' ^AO.Func  '\n' )

	I = I + 1
}

##### IN #####
option -h      -> help;
option -H      -> help;
option --help  -> help;
##### EXP #####
h help
H help