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