PageRenderTime 19ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/cli/aux_cli_07_custom_option.e

http://github.com/tybor/Liberty
Specman e | 50 lines | 43 code | 7 blank | 0 comment | 1 complexity | d2876ffdc558c86a5d3c964b300e93d8 MD5 | raw file
 1class AUX_CLI_07_CUSTOM_OPTION
 2
 3create {TEST_CLI_07}
 4   make
 5
 6feature {TEST_CLI_07}
 7   items: MAP[FIXED_STRING, FIXED_STRING]
 8      do
 9         Result := items_
10      end
11
12feature {}
13   make (val: STRING)
14      local
15         done: BOOLEAN
16         key, value: FIXED_STRING
17      do
18         create items_.make
19         from
20            done := not pattern.match(val)
21         until
22            done
23         loop
24            check
25               pattern.named_group_matched(once "key")
26            end
27            key := pattern.named_group_value(val, once "key").intern
28            if pattern.named_group_matched(once "value") then
29               value := pattern.named_group_value(val, once "value").intern
30            else
31               value := Void
32            end
33            items_.add(value, key)
34            done := not pattern.match_next(val)
35         end
36      end
37
38   pattern: REGULAR_EXPRESSION
39      local
40         re: REGULAR_EXPRESSION_BUILDER
41      once
42         Result := re.convert_python_pattern("\s*(?P<key>[^=;]+?)(?:\s*?=\s*(?P<value>[^;]*?))?\s*(?:;|$)")
43      end
44
45   items_: HASHED_DICTIONARY[FIXED_STRING, FIXED_STRING]
46
47invariant
48   items_ /= Void
49
50end