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

http://github.com/tybor/Liberty · Specman e · 65 lines · 31 code · 7 blank · 27 comment · 2 complexity · 109354f15d4163497cee5d72c5db2803 MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. class REGULAR_EXPRESSION_ITEM_LOOK_END
  5. --
  6. --
  7. inherit
  8. REGULAR_EXPRESSION_ITEM
  9. REGULAR_EXPRESSION_ITEM_GLOBALS
  10. create {ANY}
  11. make
  12. feature {ANY}
  13. is_ahead: BOOLEAN
  14. -- should look ahead? (or else behind?)
  15. should_continue: BOOLEAN
  16. -- should continue? (or else backtrack?)
  17. make (ahead, continue: BOOLEAN)
  18. do
  19. is_ahead := ahead
  20. should_continue := continue
  21. ensure
  22. definition: is_ahead = ahead and should_continue = continue
  23. end
  24. explore (matcher: BACKTRACKING_REGULAR_EXPRESSION)
  25. do
  26. if is_ahead then
  27. matcher.end_look_ahead
  28. else
  29. matcher.end_look_behind
  30. end
  31. matcher.cut
  32. if should_continue then
  33. matcher.continue
  34. else
  35. matcher.backtrack
  36. end
  37. end
  38. end -- class REGULAR_EXPRESSION_ITEM_LOOK_END
  39. --
  40. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  41. --
  42. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  43. -- of this software and associated documentation files (the "Software"), to deal
  44. -- in the Software without restriction, including without limitation the rights
  45. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  46. -- copies of the Software, and to permit persons to whom the Software is
  47. -- furnished to do so, subject to the following conditions:
  48. --
  49. -- The above copyright notice and this permission notice shall be included in
  50. -- all copies or substantial portions of the Software.
  51. --
  52. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  53. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  54. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  55. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  56. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  57. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  58. -- THE SOFTWARE.