/src/lib/parse/eiffel/eiffel_position.e

http://github.com/tybor/Liberty · Specman e · 74 lines · 43 code · 7 blank · 24 comment · 1 complexity · f7286a788e7aa5e183293a3d66056e5f MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. expanded class EIFFEL_POSITION
  5. insert
  6. ANY
  7. redefine
  8. default_create, is_equal
  9. end
  10. creation {EIFFEL_GRAMMAR}
  11. default_create
  12. feature {EIFFEL_GRAMMAR}
  13. next (buffer: MINI_PARSER_BUFFER): like Current is
  14. do
  15. buffer.next
  16. index := buffer.current_index
  17. if not buffer.end_reached then
  18. inspect
  19. buffer.current_character
  20. when '%N' then
  21. line := line + 1
  22. column := 1
  23. when '%R' then
  24. -- ignored
  25. else
  26. column := column + 1
  27. end
  28. end
  29. Result := Current
  30. end
  31. feature {EIFFEL_GRAMMAR, EIFFEL_IMAGE, EIFFEL_POSITION}
  32. line: INTEGER
  33. column: INTEGER
  34. index: INTEGER
  35. feature {ANY}
  36. is_equal (other: like Current): BOOLEAN is
  37. do
  38. Result := index = other.index
  39. end
  40. feature {}
  41. default_create is
  42. do
  43. index := 1
  44. line := 1
  45. column := 1
  46. end
  47. end -- class EIFFEL_POSITION
  48. --
  49. -- Copyright (c) 2009 by all the people cited in the AUTHORS file.
  50. --
  51. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  52. -- of this software and associated documentation files (the "Software"), to deal
  53. -- in the Software without restriction, including without limitation the rights
  54. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  55. -- copies of the Software, and to permit persons to whom the Software is
  56. -- furnished to do so, subject to the following conditions:
  57. --
  58. -- The above copyright notice and this permission notice shall be included in
  59. -- all copies or substantial portions of the Software.
  60. --
  61. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  62. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  63. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  64. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  65. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  66. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  67. -- THE SOFTWARE.