summaryrefslogtreecommitdiff
path: root/test/rhsref2.lm
blob: 4c831d7e2e8f04feb2b2658f281186c672ae728f (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
##### LM #####

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