blob: b86f5635da1e598af52d9cfc751489a8ffbe9ef8 (
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
|
##### LM #####
lex
literal '-'
token file /^('-'|0)(^0)*/
end
token word /(^0)+/
token zero /0/
lex
token single /[qvh]/
token with_opt /[oi]/
end
def item
[file zero]
| ['-' single* zero]
| ['-' with_opt zero? word zero]
def args
[word zero item*]
cons ArgParser: parser<args> []
ArgV: list<str> ArgV = argv
for A: str in ArgV
send ArgParser [A '\0']
Args: args = ArgParser()
print_xml( Args )
print( '\n' )
##### ARGS #####
-qv -h -o output sdf -i eth0 file
##### EXP #####
<args><word>./working/accum3.bin</word><zero>�</zero><_repeat_item><item><_literal_0001>-</_literal_0001><_repeat_single><single>q</single><single>v</single></_repeat_single><zero>�</zero></item><item><_literal_0001>-</_literal_0001><_repeat_single><single>h</single></_repeat_single><zero>�</zero></item><item><_literal_0001>-</_literal_0001><with_opt>o</with_opt><_opt_zero><zero>�</zero></_opt_zero><word>output</word><zero>�</zero></item><item><file>sdf</file><zero>�</zero></item><item><_literal_0001>-</_literal_0001><with_opt>i</with_opt><_opt_zero><zero>�</zero></_opt_zero><word>eth0</word><zero>�</zero></item><item><file>file</file><zero>�</zero></item></_repeat_item></args>
|