/src/tools/errors/liberty_semantics_position.e

http://github.com/tybor/Liberty · Specman e · 89 lines · 62 code · 13 blank · 14 comment · 2 complexity · 0cb28f96f56a59e53dc79a96df6e4c68 MD5 · raw file

  1. -- This file is part of Liberty Eiffel.
  2. --
  3. -- Liberty Eiffel is free software: you can redistribute it and/or modify
  4. -- it under the terms of the GNU General Public License as published by
  5. -- the Free Software Foundation, version 3 of the License.
  6. --
  7. -- Liberty Eiffel is distributed in the hope that it will be useful,
  8. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. -- GNU General Public License for more details.
  11. --
  12. -- You should have received a copy of the GNU General Public License
  13. -- along with Liberty Eiffel. If not, see <http://www.gnu.org/licenses/>.
  14. --
  15. class LIBERTY_SEMANTICS_POSITION
  16. inherit
  17. LIBERTY_POSITION
  18. redefine
  19. show
  20. end
  21. insert
  22. EIFFEL_NODE_HANDLER
  23. create {LIBERTY_ERRORS}
  24. make
  25. feature {ANY}
  26. is_unknown: BOOLEAN is False
  27. show (stream: OUTPUT_STREAM) is
  28. do
  29. generate_source
  30. if index <= source.upper then
  31. Precursor(stream)
  32. else
  33. debug
  34. stream.put_string(once "Invalid position ")
  35. stream.put_integer(index)
  36. stream.put_new_line
  37. end
  38. end
  39. end
  40. feature {}
  41. ast: LIBERTY_AST_NON_TERMINAL_NODE
  42. feature {}
  43. make (a_index: like index; a_ast: like ast; a_file: like file) is
  44. require
  45. a_ast /= Void
  46. a_index > 0
  47. a_file /= Void
  48. do
  49. index := a_index
  50. ast := a_ast
  51. file := a_file
  52. ensure
  53. index = a_index
  54. ast = a_ast
  55. file = a_file
  56. end
  57. generate_source is
  58. do
  59. if last_ast_in_code_buffer.item /= ast then
  60. code_buffer.clear
  61. ast.generate(code_buffer)
  62. last_ast_in_code_buffer.set_item(ast)
  63. end
  64. end
  65. last_ast_in_code_buffer: REFERENCE[EIFFEL_NODE] is
  66. once
  67. create Result
  68. end
  69. code_buffer: STRING_OUTPUT_STREAM is
  70. once
  71. create Result.connect_to(source)
  72. end
  73. source: STRING is ""
  74. invariant
  75. ast /= Void
  76. end