/src/tools/configuration/etc/liberty_etc_grammar.e

http://github.com/tybor/Liberty · Specman e · 225 lines · 189 code · 12 blank · 24 comment · 3 complexity · c40694a9d44480de1c9286e9038d30ef 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_ETC_GRAMMAR
  16. --
  17. -- Grammar for the etc files (i.e. master configuration, in /etc for UNIX)
  18. --
  19. insert
  20. EIFFEL_GRAMMAR
  21. redefine
  22. the_table
  23. end
  24. create {LIBERTY_ETC}
  25. make
  26. feature {}
  27. the_table: PARSE_TABLE is
  28. once
  29. Result := {PARSE_TABLE <<
  30. -- Non terminals
  31. "Master", {PARSE_NON_TERMINAL << {FAST_ARRAY[STRING] << "KW master", "KW entity name", "Environment", "Clusters", "KW end", "KW end of file" >> }, agent build_root >> };
  32. "Cluster_Definition", {PARSE_NON_TERMINAL << {FAST_ARRAY[STRING] << "KW cluster", "KW cluster name", "Version", "Locations", "Needs", "Concurrency", "Assertion", "Debug", "Environment", "Clusters", "KW end", "KW end of file" >> }, agent build_root >> };
  33. "Environment", {PARSE_NON_TERMINAL << epsilon, Void;
  34. {FAST_ARRAY[STRING] << "KW environment", "Environment_Variable*" >> }, Void >> };
  35. "Environment_Variable*", {PARSE_NON_TERMINAL << epsilon, agent build_empty_list("Environment_Variable*");
  36. {FAST_ARRAY[STRING] << "Environment_Variable", "Environment_Variable*" >> }, agent build_continue_list("Environment_Variable", 0, "Environment_Variable*") >> };
  37. "Environment_Variable", {PARSE_NON_TERMINAL << {FAST_ARRAY[STRING] << "KW entity name", "KW is", "KW string" >> }, Void >> };
  38. "Clusters", {PARSE_NON_TERMINAL << epsilon, Void;
  39. {FAST_ARRAY[STRING] << "KW cluster", "Cluster*" >> }, Void >> };
  40. "Cluster*", {PARSE_NON_TERMINAL << epsilon, agent build_empty_list("Cluster*");
  41. {FAST_ARRAY[STRING] << "Cluster", "Cluster*" >> }, agent build_continue_list("Cluster", 0, "Cluster*") >> };
  42. "Cluster", {PARSE_NON_TERMINAL << {FAST_ARRAY[STRING] << "KW cluster name", "KW :", "KW string", "Configure" >> }, agent build_root >> };
  43. "Configure", {PARSE_NON_TERMINAL << epsilon, Void;
  44. {FAST_ARRAY[STRING] << "KW configure", "Concurrency", "Assertion", "Debug", "KW end" >> }, Void >> };
  45. "Version", {PARSE_NON_TERMINAL << {FAST_ARRAY[STRING] << "KW version", "KW string" >> }, Void >> };
  46. "Locations", {PARSE_NON_TERMINAL << {FAST_ARRAY[STRING] << "KW locations", "Location+" >> }, Void >> };
  47. "Location+", {PARSE_NON_TERMINAL << {FAST_ARRAY[STRING] << "Location" >> }, agent build_new_list("Location", "Location+");
  48. {FAST_ARRAY[STRING] << "Location", "Location+" >> }, agent build_continue_list("Location", 0, "Location+");
  49. {FAST_ARRAY[STRING] << "Location", "KW ;", "Location+" >> }, agent build_continue_list("Location", 1, "Location+") >> };
  50. "Location", {PARSE_NON_TERMINAL << {FAST_ARRAY[STRING] << "KW string" >> }, Void >> };
  51. "Needs", {PARSE_NON_TERMINAL << epsilon, Void;
  52. {FAST_ARRAY[STRING] << "KW needs", "Cluster_Configuration*" >>}, Void >> };
  53. "Cluster_Configuration*", {PARSE_NON_TERMINAL << epsilon, agent build_empty_list("Cluster_Configuration*");
  54. {FAST_ARRAY[STRING] << "Cluster_Configuration", "Cluster_Configuration*" >> }, agent build_continue_list("Cluster_Configuration", 0, "Cluster_Configuration*");
  55. {FAST_ARRAY[STRING] << "Cluster_Configuration", "KW ;", "Cluster_Configuration*" >> }, agent build_continue_list("Cluster_Configuration", 1, "Cluster_Configuration*") >> };
  56. "Cluster_Configuration", { PARSE_NON_TERMINAL << {FAST_ARRAY[STRING] << "KW cluster name", "Cluster_Constraints" >> }, Void;
  57. {FAST_ARRAY[STRING] << "KW cluster name", "Cluster_Constraints" >> }, Void>> };
  58. "Cluster_Constraints", {PARSE_NON_TERMINAL << epsilon, Void;
  59. {FAST_ARRAY[STRING] << "KW (", "Cluster_Version_Constraint", "KW )" >> }, Void >> };
  60. "Cluster_Version_Constraint", {PARSE_NON_TERMINAL << {FAST_ARRAY[STRING] << "KW version", "Version_Operator", "KW string" >> }, Void >> };
  61. "Version_Operator", {PARSE_NON_TERMINAL << {FAST_ARRAY[STRING] << "KW =" >> }, Void;
  62. {FAST_ARRAY[STRING] << "KW <=" >> }, Void;
  63. {FAST_ARRAY[STRING] << "KW >=" >> }, Void;
  64. {FAST_ARRAY[STRING] << "KW /=" >> }, Void;
  65. {FAST_ARRAY[STRING] << "KW <" >> }, Void;
  66. {FAST_ARRAY[STRING] << "KW >" >> }, Void >> };
  67. "Assertion", {PARSE_NON_TERMINAL << epsilon, Void;
  68. {FAST_ARRAY[STRING] << "KW assertion", "Assertion_Level" >> }, Void >> };
  69. "Assertion_Level", {PARSE_NON_TERMINAL << {FAST_ARRAY[STRING] << "KW none" >> }, Void;
  70. {FAST_ARRAY[STRING] << "KW require" >> }, Void;
  71. {FAST_ARRAY[STRING] << "KW ensure" >> }, Void;
  72. {FAST_ARRAY[STRING] << "KW loop" >> }, Void;
  73. {FAST_ARRAY[STRING] << "KW check" >> }, Void;
  74. {FAST_ARRAY[STRING] << "KW all" >> }, Void >> };
  75. "Debug", {PARSE_NON_TERMINAL << epsilon, Void;
  76. {FAST_ARRAY[STRING] << "KW debug", "Debug_Configuration*" >> }, Void >> };
  77. "Debug_Configuration*", {PARSE_NON_TERMINAL << epsilon, agent build_empty_list("Debug_Configuration*");
  78. {FAST_ARRAY[STRING] << "Debug_Configuration", "Debug_Configuration*" >> }, agent build_continue_list("Debug_Configuration", 0, "Debug_Configuration+");
  79. {FAST_ARRAY[STRING] << "Debug_Configuration", "KW ;", "Debug_Configuration*" >> }, agent build_continue_list("Debug_Configuration", 1, "Debug_Configuration*") >> };
  80. "Debug_Configuration", {PARSE_NON_TERMINAL << {FAST_ARRAY[STRING] << "KW default", "KW :", "Debug_Key+" >> }, Void;
  81. {FAST_ARRAY[STRING] << "KW class name", "KW :", "Debug_Key+" >> }, Void >> };
  82. "Debug_Key+", {PARSE_NON_TERMINAL << {FAST_ARRAY[STRING] << "Debug_Key" >> }, agent build_new_list("Debug_Key", "Debug_Key+");
  83. {FAST_ARRAY[STRING] << "Debug_Key", "KW ,", "Debug_Key+" >> }, agent build_continue_list("Debug_Key", 1, "Debug_Key+") >> };
  84. "Debug_Key", {PARSE_NON_TERMINAL << {FAST_ARRAY[STRING] << "KW string" >> }, Void >> };
  85. "Concurrency", {PARSE_NON_TERMINAL << epsilon, Void >> };
  86. -- Symbols
  87. "KW <=", create {PARSE_TERMINAL}.make(agent parse_symbol(?, "<=", ""), Void);
  88. "KW <", create {PARSE_TERMINAL}.make(agent parse_symbol(?, "<", "<="), Void);
  89. "KW =", create {PARSE_TERMINAL}.make(agent parse_symbol(?, "=", ""), Void);
  90. "KW >=", create {PARSE_TERMINAL}.make(agent parse_symbol(?, ">=", ""), Void);
  91. "KW >", create {PARSE_TERMINAL}.make(agent parse_symbol(?, ">", ">="), Void);
  92. "KW ,", create {PARSE_TERMINAL}.make(agent parse_symbol(?, ",", ""), Void);
  93. "KW ;", create {PARSE_TERMINAL}.make(agent parse_symbol(?, ";", ";"), Void);
  94. "KW :", create {PARSE_TERMINAL}.make(agent parse_symbol(?, ":", ":="), Void);
  95. "KW /=", create {PARSE_TERMINAL}.make(agent parse_symbol(?, "/=", ""), Void);
  96. "KW .", create {PARSE_TERMINAL}.make(agent parse_symbol(?, ".", "."), Void);
  97. "KW (", create {PARSE_TERMINAL}.make(agent parse_symbol(?, "(", ""), Void);
  98. "KW )", create {PARSE_TERMINAL}.make(agent parse_symbol(?, ")", ""), Void);
  99. -- Identifiers
  100. "KW class name", create {PARSE_TERMINAL}.make(agent parse_class_or_cluster_name(True, ?), Void);
  101. "KW cluster name", create {PARSE_TERMINAL}.make(agent parse_class_or_cluster_name(False, ?), Void);
  102. "KW entity name", create {PARSE_TERMINAL}.make(agent parse_entity_name, Void);
  103. "KW string", create {PARSE_TERMINAL}.make(agent parse_string, Void);
  104. -- Keywords
  105. "KW all", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "all"), Void);
  106. "KW as needed", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "as needed"), Void);
  107. "KW assertion", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "assertion"), Void);
  108. "KW check", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "check"), Void);
  109. "KW client", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "client"), Void);
  110. "KW cluster", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "cluster"), Void);
  111. "KW clusters", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "clusters"), Void);
  112. "KW concurrency", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "concurrency"), Void);
  113. "KW configuration", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "configuration"), Void);
  114. "KW configure", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "configure"), Void);
  115. "KW connect", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "connect"), Void);
  116. "KW creation", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "creation"), Void);
  117. "KW daemon", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "daemon"), Void);
  118. "KW debug", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "debug"), Void);
  119. "KW default", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "default"), Void);
  120. "KW end", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "end"), Void);
  121. "KW end of file", create {PARSE_TERMINAL}.make(agent parse_end, Void);
  122. "KW ensure", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "ensure"), Void);
  123. "KW environment", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "environment"), Void);
  124. "KW False", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "False"), Void);
  125. "KW is", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "is"), Void);
  126. "KW listen", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "listen"), Void);
  127. "KW locations", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "locations"), Void);
  128. "KW loop", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "loop"), Void);
  129. "KW master", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "master"), Void);
  130. "KW message", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "message"), Void);
  131. "KW mmap", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "mmap"), Void);
  132. "KW needs", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "needs"), Void);
  133. "KW none", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "none"), Void);
  134. "KW not", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "not"), Void);
  135. "KW overrides", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "overrides"), Void);
  136. "KW pool of", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "pool of"), Void);
  137. "KW process", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "process"), Void);
  138. "KW require", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "require"), Void);
  139. "KW server", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "server"), Void);
  140. "KW shared", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "shared"), Void);
  141. "KW thread", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "thread"), Void);
  142. "KW True", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "True"), Void);
  143. "KW version", create {PARSE_TERMINAL}.make(agent parse_keyword(?, "version"), Void)
  144. >> };
  145. end
  146. parse_class_or_cluster_name (allow_dots: BOOLEAN; buffer: MINI_PARSER_BUFFER): UNTYPED_EIFFEL_IMAGE is
  147. local
  148. old_position, start_position, dot_position: like position; image: STRING; c: CHARACTER; s: INTEGER
  149. do
  150. old_position := position
  151. skip_blanks(buffer)
  152. start_position := position
  153. from
  154. image := once ""
  155. image.clear_count
  156. until
  157. s < 0
  158. loop
  159. if buffer.end_reached then
  160. s := -1
  161. else
  162. c := buffer.current_character
  163. inspect s
  164. when 0 then
  165. -- expecting a letter
  166. inspect c
  167. when 'A'..'Z' then
  168. image.extend(c)
  169. next_character(buffer)
  170. s := 1
  171. else
  172. s := -1
  173. end
  174. when 1 then
  175. -- at least a letter read
  176. inspect c
  177. when 'A'..'Z', '_', '0'..'9' then
  178. image.extend(c)
  179. next_character(buffer)
  180. when '.' then
  181. if allow_dots then
  182. dot_position := position
  183. next_character(buffer)
  184. s := 2
  185. else
  186. s := -1
  187. end
  188. else
  189. s := -1
  190. end
  191. when 2 then
  192. -- after a dot
  193. check allow_dots end
  194. inspect c
  195. when 'A'..'Z' then
  196. image.extend('.')
  197. image.extend(c)
  198. next_character(buffer)
  199. s := 1
  200. else
  201. restore(buffer, dot_position)
  202. s := -1
  203. end
  204. end
  205. end
  206. end
  207. if image.is_empty then
  208. restore(buffer, old_position)
  209. else
  210. create Result.make(image.twin, last_blanks.twin, start_position)
  211. end
  212. end
  213. end