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

/src/lib/regular_expression/low_level/backtracking_regular_expression_pattern.e

http://github.com/tybor/Liberty
Specman e | 61 lines | 25 code | 6 blank | 30 comment | 0 complexity | b6e56c0f10049b515977a179aa24680f MD5 | raw file
 1-- This file is part of a Liberty Eiffel library.
 2-- See the full copyright at the end.
 3--
 4expanded class BACKTRACKING_REGULAR_EXPRESSION_PATTERN
 5   --
 6   -- Class for backtracking (compiled) regular expressions pattern.
 7   --
 8
 9feature {ANY}
10   group_count: INTEGER
11         -- The count of groups of the regular expression.
12
13   is_valid: BOOLEAN
14         -- Is the current pattern valid?
15      do
16         Result := root /= Void
17      end
18
19feature {BACKTRACKING_REGULAR_EXPRESSION}
20   root: BACKTRACKING_NODE
21         -- The root item.
22
23   substrings_names: BIJECTIVE_DICTIONARY[INTEGER, FIXED_STRING]
24
25feature {BACKTRACKING_REGULAR_EXPRESSION_BUILDER}
26   make (top: like root; grpcnt: INTEGER; subnames: like substrings_names)
27         -- Initializing
28      require
29         top_not_void: top /= Void
30         valid_group_count: grpcnt >= 0
31         valid_subnames: subnames.for_all(agent (c, i: INTEGER; s: FIXED_STRING): BOOLEAN do Result := i.in_range(0, c) and then s /= Void end (grpcnt, ?, ?))
32      do
33         root := top
34         group_count := grpcnt
35         substrings_names := subnames
36      ensure
37         definition: root = top and group_count = grpcnt
38         valid: is_valid
39      end
40
41end -- class BACKTRACKING_REGULAR_EXPRESSION_PATTERN
42--
43-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
44--
45-- Permission is hereby granted, free of charge, to any person obtaining a copy
46-- of this software and associated documentation files (the "Software"), to deal
47-- in the Software without restriction, including without limitation the rights
48-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
49-- copies of the Software, and to permit persons to whom the Software is
50-- furnished to do so, subject to the following conditions:
51--
52-- The above copyright notice and this permission notice shall be included in
53-- all copies or substantial portions of the Software.
54--
55-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
56-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
57-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
58-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
59-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
60-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
61-- THE SOFTWARE.