PageRenderTime 22ms CodeModel.GetById 17ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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