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

/src/lib/regular_expression/internal/regular_expression_items/regular_expression_item_globals.e

http://github.com/tybor/Liberty
Specman e | 266 lines | 202 code | 31 blank | 33 comment | 0 complexity | 69e48bb635864318ade9e4c431319429 MD5 | raw file
  1-- This file is part of a Liberty Eiffel library.
  2-- See the full copyright at the end.
  3--
  4deferred class REGULAR_EXPRESSION_ITEM_GLOBALS
  5   --
  6   -- common invariant nodes and POSIX classes naming
  7   --
  8
  9inherit
 10   BACKTRACKING_NODE_GLOBALS
 11
 12feature {ANY} -- assertions
 13   the_any_character_item: REGULAR_EXPRESSION_ITEM_ANY
 14      once
 15         create Result
 16      end
 17
 18   the_not_end_of_line_item: REGULAR_EXPRESSION_ITEM_NOT_END_OF_LINE
 19      once
 20         create Result
 21      end
 22
 23   the_begin_of_line_item: REGULAR_EXPRESSION_ITEM_BEGIN_OF_LINE
 24      once
 25         create Result
 26      end
 27
 28   the_end_of_line_item: REGULAR_EXPRESSION_ITEM_END_OF_LINE
 29      once
 30         create Result
 31      end
 32
 33   the_begin_of_text_item: REGULAR_EXPRESSION_ITEM_BEGIN_OF_TEXT
 34      once
 35         create Result
 36      end
 37
 38   the_real_end_of_text_item: REGULAR_EXPRESSION_ITEM_END_OF_TEXT
 39      once
 40         create Result.make(True)
 41      end
 42
 43   the_end_of_text_item: REGULAR_EXPRESSION_ITEM_END_OF_TEXT
 44      once
 45         create Result.make(False)
 46      end
 47
 48   the_begin_of_word_item: REGULAR_EXPRESSION_ITEM_BEGIN_OF_WORD
 49      once
 50         create Result
 51      end
 52
 53   the_end_of_word_item: REGULAR_EXPRESSION_ITEM_END_OF_WORD
 54      once
 55         create Result
 56      end
 57
 58feature {ANY} -- character classes
 59   the_is_posix_alnum_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_ALNUM
 60      once
 61         create Result
 62      end
 63
 64   the_is_posix_alpha_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_ALPHA
 65      once
 66         create Result
 67      end
 68
 69   the_is_posix_ascii_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_ASCII
 70      once
 71         create Result
 72      end
 73
 74   the_is_posix_blank_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_BLANK
 75      once
 76         create Result
 77      end
 78
 79   the_is_posix_cntrl_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_CNTRL
 80      once
 81         create Result
 82      end
 83
 84   the_is_posix_digit_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_DIGIT
 85      once
 86         create Result
 87      end
 88
 89   the_is_posix_graph_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_GRAPH
 90      once
 91         create Result
 92      end
 93
 94   the_is_posix_lower_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_LOWER
 95      once
 96         create Result
 97      end
 98
 99   the_is_posix_print_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_PRINT
100      once
101         create Result
102      end
103
104   the_is_posix_punct_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_PUNCT
105      once
106         create Result
107      end
108
109   the_is_posix_space_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_SPACE
110      once
111         create Result
112      end
113
114   the_is_posix_upper_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_UPPER
115      once
116         create Result
117      end
118
119   the_is_posix_word_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_WORD
120      once
121         create Result
122      end
123
124   the_is_posix_xdigit_item: REGULAR_EXPRESSION_ITEM_IS_POSIX_XDIGIT
125      once
126         create Result
127      end
128
129feature {ANY} -- character class naming
130   has_named_posix_item (name: STRING): BOOLEAN
131         -- True if 'name' is for a valid POSIX character class
132      require
133         name_not_void: name /= Void
134      do
135         Result := internal_named_posix_item(name) /= Void
136      end
137
138   named_posix_item (name: STRING): REGULAR_EXPRESSION_ITEM
139         -- the item for the valid POSIX character class 'name'
140      require
141         name_not_void: name /= Void
142         good_name: has_named_posix_item(name)
143      do
144         Result := internal_named_posix_item(name)
145      ensure
146         good_result: Result /= Void
147      end
148
149   has_named_perl_item (name: STRING): BOOLEAN
150         -- True if 'name' is for a valid Perl character class
151      require
152         name_not_void: name /= Void
153      do
154         Result := internal_named_perl_item(name) /= Void
155      end
156
157   named_perl_item (name: STRING): REGULAR_EXPRESSION_ITEM
158         -- the item for the valid Perl character class 'name'
159      require
160         name_not_void: name /= Void
161         good_name: has_named_perl_item(name)
162      do
163         Result := internal_named_perl_item(name)
164      ensure
165         good_result: Result /= Void
166      end
167
168feature {}
169   internal_named_posix_item (name: STRING): REGULAR_EXPRESSION_ITEM
170         -- the item for a presumed POSIX character class 'name'
171      require
172         name_not_void: name /= Void
173      do
174         inspect
175            name
176         when "alnum" then
177            Result := the_is_posix_alnum_item
178         when "alpha" then
179            Result := the_is_posix_alpha_item
180         when "ascii" then
181            Result := the_is_posix_ascii_item
182         when "blank" then
183            Result := the_is_posix_blank_item
184         when "cntrl" then
185            Result := the_is_posix_cntrl_item
186         when "digit" then
187            Result := the_is_posix_digit_item
188         when "graph" then
189            Result := the_is_posix_graph_item
190         when "lower" then
191            Result := the_is_posix_lower_item
192         when "print" then
193            Result := the_is_posix_print_item
194         when "punct" then
195            Result := the_is_posix_punct_item
196         when "space" then
197            Result := the_is_posix_space_item
198         when "upper" then
199            Result := the_is_posix_upper_item
200         when "word" then
201            Result := the_is_posix_word_item
202         when "xdigit" then
203            Result := the_is_posix_xdigit_item
204         else
205         end
206      end
207
208   internal_named_perl_item (name: STRING): REGULAR_EXPRESSION_ITEM
209         -- the item for a presumed Perl character class 'name'
210      require
211         name_not_void: name /= Void
212      do
213         inspect
214            name
215         when "IsAlnum" then
216            Result := the_is_posix_alnum_item
217         when "IsAlpha" then
218            Result := the_is_posix_alpha_item
219         when "IsASCII" then
220            Result := the_is_posix_ascii_item
221            --when "blank" then Result := the_is_posix_blank_item
222         when "IsCntrl" then
223            Result := the_is_posix_cntrl_item
224         when "IsDigit" then
225            Result := the_is_posix_digit_item
226         when "IsGraph" then
227            Result := the_is_posix_graph_item
228         when "IsLower" then
229            Result := the_is_posix_lower_item
230         when "IsPrint" then
231            Result := the_is_posix_print_item
232         when "IsPunct" then
233            Result := the_is_posix_punct_item
234         when "IsSpace", "IsSpacePerl" then
235            Result := the_is_posix_space_item
236         when "IsUpper" then
237            Result := the_is_posix_upper_item
238         when "IsWord" then
239            Result := the_is_posix_word_item
240         when "IsXDigit" then
241            Result := the_is_posix_xdigit_item
242         else
243         end
244      end
245
246end -- class REGULAR_EXPRESSION_ITEM_GLOBALS
247--
248-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
249--
250-- Permission is hereby granted, free of charge, to any person obtaining a copy
251-- of this software and associated documentation files (the "Software"), to deal
252-- in the Software without restriction, including without limitation the rights
253-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
254-- copies of the Software, and to permit persons to whom the Software is
255-- furnished to do so, subject to the following conditions:
256--
257-- The above copyright notice and this permission notice shall be included in
258-- all copies or substantial portions of the Software.
259--
260-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
261-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
262-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
263-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
264-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
265-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
266-- THE SOFTWARE.