/[papo]/gnue/appserver/src/_featuretest/GodlParser.py
ViewVC logotype

Diff of /gnue/appserver/src/_featuretest/GodlParser.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by styxman, Fri Nov 8 16:38:42 2002 UTC revision 1.1.4.1 by anthonyl, Tue Mar 4 22:03:55 2003 UTC
# Line 1  Line 1 
1  # GNU Enterprise Application Server - GODL: ODL Markup Language parser  # GNU Enterprise Application Server - GODL: ODL Markup Language parser
2  #  #
3  # Copyright 2002 Free Software Foundation, Inc.  # Copyright 2002-2003 Free Software Foundation, Inc.
4  #  #
5  # This file is part of GNU Enterprise.  # This file is part of GNU Enterprise.
6  #  #
# Line 30  import copy, types Line 30  import copy, types
30  # returns a GodlSpec object.  # returns a GodlSpec object.
31  #######################################################  #######################################################
32    
33  def loadDefinition(buffer, connections, initialize=1):  def loadDefinition(buffer, initialize=1):
34    return GParser.loadXMLObject (buffer, xmlGodlHandler, 'GodlSpec', 'odl_specification',    return GParser.loadXMLObject (buffer, xmlGodlHandler, 'GodlSpec', 'odl_specification',
35             initialize, attributes={})             initialize, attributes={})
36    
# Line 41  def getXMLelements(): Line 41  def getXMLelements():
41    global xmlElements    global xmlElements
42    
43    if xmlElements == None:    if xmlElements == None:
   
     #  
     #  
44      xmlElements = {      xmlElements = {
45        'odl_specification':        'odl_specification':
46        {        {
47          'BaseClass': Objects.GodlSpec,          'BaseClass': Objects.GodlSpec,
48          'Required': 1,          'Required': 1,
49          'SingleInstance': 0,          'SingleInstance': 1,
50          'ParentTags': (None, 'module',)          'ParentTags': (None, 'odl_definition', 'module',),
51        },        },
52    
53        'odl_definition':        'odl_definition':
54        {        {
55          'BaseClass': Objects.GodlDefinition,          'BaseClass': Objects.GodlDefinition,
56          'SingleInstance': 0,          'Required': 1,
57          'ParentTags':  ('odl_specification',)          'SingleInstance' :1,
58            'ParentTags': ('odl_specification',),
59        },        },
60    
61        'module':        'module':
62        {        {
63          'BaseClass': Objects.GodlModule,          'BaseClass': Objects.GodlModule,
64            'Importable': 1,
65          'Attributes':          'Attributes':
66          {          {
67            'id':            'name':
68             {             {
69               'Required': 1,               'Required': 1,
70               'Unique': 1,               'Unique': 1,
71               'Typecast': GTypecast.name               'Typecast': GTypecast.name,
72             }             },
73          },          },
74          'ParentTags':  ('odl_definition',)          'ParentTags': ('odl_definition',),
75        },        },
76    
77        'typedef':        'typedef':
78        {        {
79          'BaseClass': Objects.GodlTypedef,          'BaseClass': Objects.GodlTypedef,
80          'SingleInstance': 0,          'Attributes':
81          'ParentTags':  ('odl_definition',)          {
82              'type':
83              {
84                'Typecast': GTypecast.text,
85              },
86            },        
87            'ParentTags': ('odl_definition',),
88          },
89    
90          'alias':
91          {
92            'BaseClass': Objects.GodlAlias,
93            'Required': 1,
94            'Unique': 1,
95            'Typecast': GTypecast.name,
96            'ParentTags': ('typedef',),
97        },        },
98    
99        'struct':        'struct':
# Line 87  def getXMLelements(): Line 101  def getXMLelements():
101          'BaseClass': Objects.GodlStruct,          'BaseClass': Objects.GodlStruct,
102          'Attributes':          'Attributes':
103          {          {
104            'id':            'name':
105             {             {
106               'Required': 1,               'Required': 1,
107               'Unique': 1,               'Unique': 1,
108               'Typecast': GTypecast.name               'Typecast': GTypecast.name,
109             }             },
110          },          },
         'SingleInstance': 0,  
111          'ParentTags':  ('odl_definition',)          'ParentTags':  ('odl_definition',)
112        },        },
113    
114          'members':
115          {
116            'BaseClass': Objects.GodlMembers,
117            'SingleInstance' : 1,
118            'ParentTags': ('struct', 'exception',),
119          },
120    
121          'member':
122          {
123            'BaseClass': Objects.GodlMember,
124            'Attributes':
125            {
126               'name':
127               {
128                 'Required': 1,
129                 'Unique': 1,
130                 'Typecast': GTypecast.name,
131               },
132             },
133            'ParentTags': ('members',)
134          },
135    
136        'union':        'union':
137        {        {
138          'BaseClass': Objects.GodlStruct,          'BaseClass': Objects.GodlUnion,
139          'SingleInstance': 0,          'Attributes':
140          'ParentTags':  ('odl_definition',)          {
141              'name':
142              {
143                'Required': 1,
144                'Unique': 1,
145                'Typecast': GTypecast.name,
146              },
147            },
148            'ParentTags':  ('odl_definition',),
149        },        },
150    
151  #      'field':   {        'switch':
152  #         'BaseClass': Objects.GSField,        {
153  #         'Attributes': {          'BaseClass': Objects.GodlSwitch,
154  #            'name':          {          'Attributes':
155  #               'Required': 1,          {
156  #               'Unique': 1,            'type':
157  #               'Typecast': GTypecast.name },            {
158  #            'description': {              'Required': 1,
159  #               'Typecast': GTypecast.text },              'Typecast': GTypecast.text,
160  #            'type': {            },
161  #               'Required': 1,          },
162  #               'Typecast': GTypecast.name },          'SingleInstance': 1,
163  #            'size': {          'ParentTags': ('union',),
164  #               'Typecast': GTypecast.whole },        },
165  #            'nullable':     {  
166  #               'Typecast': GTypecast.boolean,        'case':
167  #               'Default': 1 },        {
168  #            'default':     {          'BaseClass': Objects.GodlCase,
169  #               'Typecast': GTypecast.text } },          'Attributes':
170  #          {
171  #      'ParentTags':  ('fields',) },            'label':
172  #            {
173  #      'primarykey':   {              'Required': 1,
174  #         'BaseClass': Objects.GSPrimaryKey,              'Typecast': GTypecast.text,
175  #         'SingleInstance': 1,            },
176  #         'Attributes': {            'name':
177  #            'name':        {            {
178  #               'Required': 1,              'Required': 1,
179  #               'Typecast': GTypecast.name } },              'Unique': 1,
180  #        'ParentTags':  ('table',) },              'Typecast': GTypecast.name,
181  #            },
182  #      'pkfield':   {          },
183  #         'BaseClass': Objects.GSPKField,          'ParentTags': ('switch',),
184  #         'Attributes': {        },
185  #            'name':        {  
186  #               'Required': 1,        'default':
187  #               'Typecast': GTypecast.name } },        {
188  #         'ParentTags':  ('primarykey',) },          'BaseClass': Objects.GodlDefault,
189  #          'Attributes':
190  #      'constraints':   {          {
191  #         'BaseClass': Objects.GSConstraints,            'name':
192  #         'SingleInstance': 1,            {
193  #         'ParentTags':  ('table',) },              'Required': 1,
194  #              'Unique': 1,
195  #      'constraint':    {              'Typecast': GTypecast.name,
196  #         'BaseClass': Objects.GSConstraint,            },
197  #         'Attributes': {          },
198  #           'name': {          'SingleInstance': 1,
199  #               'Required': 1,          'ParentTags': ('switch'),
200  #               'Typecast': GTypecast.name },        },
201  #            'type': {          
202  #               'Typecast': GTypecast.name } },        'enum':
203  #         'ParentTags':  ('constraints',) },        {
204  #          'BaseClass': Objects.GodlEnum,
205  #      'constraintfield':   {          'Attributes':
206  #         'BaseClass': Objects.GSConstraintField,          {
207  #         'Attributes': {            'name':
208  #            'name':        {            {
209  #               'Required': 1,              'Required': 1,
210  #               'Typecast': GTypecast.name } },              'Unique': 1,
211  #         'ParentTags':  ('constraint',) },              'Typecast': GTypecast.name,
212  #            },
213  #      'constraintref':   {          },
214  #         'BaseClass': Objects.GSConstraintField,          'ParentTags': ('odl_definition',),
215  #         'Attributes': {        },
216  #            'name':        {  
217  #               'Required': 1,        'element':
218  #              'Typecast': GTypecast.name },        {
219  #            'table':        {          'BaseClass': Objects.GodlElement,
220  #               'Required': 1,          'ParentTags': ('enum',),
221  #               'Typecast': GTypecast.name } },        },
 #         'ParentTags':  ('constraint',) },  
 #  
 #      'indexes':   {  
 #         'BaseClass': Objects.GSIndexes,  
 #         'SingleInstance': 1,  
 #         'ParentTags':  ('table',) },  
 #      'index':    {  
 #         'BaseClass': Objects.GSIndex,  
 #         'Attributes': {  
 #            'name': {  
 #               'Required': 1,  
 #               'Typecast': GTypecast.name },  
 #            'unique': {  
 #               'Typecast': GTypecast.boolean } },  
 #         'ParentTags':  ('indexes',) },  
 #  
 #      'indexfield':   {  
 #         'BaseClass': Objects.GSIndexField,  
 #         'Attributes': {  
 #            'name':        {  
 #               'Required': 1,  
 #               'Typecast': GTypecast.name } },  
 #         'ParentTags':  ('index',) },  
 #  
 #      'data':   {  
 #         'BaseClass': Objects.GSData,  
 #         'SingleInstance': 1,  
 #         'ParentTags':  ('schema',) },  
 #  
 #      'tabledata':   {  
 #         'BaseClass': Objects.GSTableData,  
 #         'Attributes': {  
 #            'name':        {  
 #               'Required': 1,  
 #               'Typecast': GTypecast.name },  
 #           'tablename':        {  
 #               'Required': 1,  
 #               'Typecast': GTypecast.name } },  
 #         'ParentTags':  ('data',) },  
 #  
 #  
 #      'rows':   {  
 #         'BaseClass': Objects.GSRows,  
 #         'SingleInstance': 1,  
 #         'ParentTags':  ('tabledata',) },  
 #  
 #      'row':   {  
 #         'BaseClass': Objects.GSRow,  
 #         'ParentTags':  ('rows',) },  
 #  
 #      'value':   {  
 #         'BaseClass': Objects.GSValue,  
 #         'Attributes': {  
 #            'field':        {  
 #               'Required': 0,  
 #               'Typecast': GTypecast.name },  
 #            'type':        {  
 #               'Required': 0,  
 #               'Typecast': GTypecast.name,  
 #               'Default':  'text' } },  
 #         'ParentTags':  ('row',),  
 #         'MixedContent': 1, },  
222    
223          'const':
224          {
225            'BaseClass': Objects.GodlConst,
226            'Attributes':
227            {
228              'name':
229              {
230                'Required': 1,
231                'Unique': 1,
232                'Typecast': GTypecast.name,
233              },
234    
235              'type':
236              {
237                'Required': 1,
238                'Typecast': GTypecast.text,
239              },
240            },
241            'ParentTags': ('odl_definition',)
242          },
243          
244          'exception':
245          {
246            'BaseClass': Objects.GodlException,
247            'Attributes':
248            {
249              'name':
250              {
251                'Required': 1,
252                'Unique': 1,
253                'Typecast': GTypecast.name,
254              },
255            },
256            'ParentTags': ('odl_definition', 'interface', 'class','raises',),
257          },
258            
259          'interface':
260          {
261            'BaseClass': Objects.GodlInterface,
262            'Attributes':
263            {
264              'name':
265              {
266                'Required': 1,
267                'Unique': 1,
268                'Typecast': GTypecast.name,
269              }
270            },
271            'ParentTags': ('odl_definition',),
272          },
273    
274          'inherits':
275          {
276            'BaseClass': Objects.GodlInherits,
277            'SingleInstance': 1,
278            'ParentTags': ('interface', 'class',),
279          },
280          
281          'attribute':
282          {
283            'BaseClass': Objects.GodlAttribute,
284            'Attributes':
285            {
286              'name':
287              {
288                'Required': 1,
289                'Unique': 1,
290                'Typecast': GTypecast.name,
291              },
292              
293              'readonly':
294              {
295                'Typecast': GTypecast.boolean,
296              },
297            },
298            'ParentTags': ('interface', 'class',),
299          },
300    
301          'operation':
302          {
303            'BaseClass': Objects.GodlOperation,
304            'Attributes':
305            {
306              'name':
307              {
308                'Required': 1,
309                'Unique': 1,
310                'Typecast': GTypecast.name,
311              },
312              
313              'oneway':
314              {
315                'Required': 0,
316                'Typecast': GTypecast.boolean,
317              },
318            },
319          },
320    
321          'returns':
322          {
323            'BaseClass': Objects.GodlReturns,
324            'Required': 0,
325            'ParentTags': ('operation',),
326          },
327    
328          'parameters':
329          {
330            'BaseClass': Objects.GodlParameters,
331            'Required': 0,
332            'SingleInstance': 1,
333            'ParentTags': ('operation',),
334          },
335    
336          'parameter':
337          {
338            'BaseClass': Objects.GodlParameter,
339            'Attributes':
340            {
341              'name':
342              {
343                'Required': 1,
344                'Unique': 1,
345                'Typecast': GTypecast.name,
346              },
347    
348              'mode':
349              {
350                'Typecast': GTypecast.text,
351              },
352            },
353            'ParentTags': ('parameters',),
354          },
355    
356          'raises':
357          {
358            'BaseClass': Objects.GodlRaises,
359            'ParentTags': ('operation',),
360          },
361                    
362          'class':
363          {
364            'BaseClass': Objects.GodlClass,
365            'Attributes':
366            {
367              'name':
368              {
369                'Required': 1,
370                'Unique': 1,
371                'Typecast': GTypecast.name,
372              },
373            },
374            'ParentTags': ('odl_definition',),
375          },
376            
377          'extends':
378          {
379            'BaseClass': Objects.GodlExtends,
380            'ParentTags': ('class',),
381          },
382            
383          'extent':
384          {
385            'BaseClass': Objects.GodlExtent,
386            'ParentTags': ('class',),
387          },
388            
389          'relationship':
390          {
391            'BaseClass': Objects.GodlRelationship,
392            'Attributes':
393            {
394              'name':
395              {
396                'Required': 1,
397                'Unique': 1,
398                'Typecast': GTypecast.name,
399              },
400            },
401            'ParentTags': ('class',),
402          },
403            
404          'target':
405          {
406            'BaseClass': Objects.GodlTarget,
407            'ParentTags': ('relationship',),
408          },
409    
410          'inverse':
411          {
412            'BaseClass': Objects.GodlInverse,
413            'ParentTags': ('relationship',),
414          },
415    
416          'string':
417          {
418            'BaseClass': Objects.GodlString,
419            'Attributes':
420            {
421              'size':
422              {
423                'Typecast': GTypecast.whole,
424              },
425            },
426            'ParentTags': ('typedef', 'array', 'set', 'bag', 'list',
427                           'sequence', 'key', 'value', 'member', 'case',
428                           'default', 'target', 'returns', 'parameter',
429                           'attribute',),
430          },
431            
432          'array':
433          {
434            'BaseClass': Objects.GodlArray,
435            'Attributes':
436            {
437              'size':
438              {
439                'Typecast': GTypecast.integer, # TODO: Should this be GTypecast.whole?
440              },
441            },
442            'ParentTags': ('typedef', 'array', 'set', 'bag', 'list',
443                           'sequence', 'key', 'value', 'member', 'case',
444                           'default', 'target', 'returns', 'parameter',
445                           'attribute',),
446          },
447            
448          'sequence':
449          {
450            'BaseClass': Objects.GodlSequence,
451            'ParentTags': ('typedef', 'array', 'set', 'bag', 'list',
452                           'sequence', 'key', 'value', 'member', 'case',
453                           'default', 'target', 'returns', 'parameter',
454                           'attribute',),
455          },
456    
457          'set':
458          {
459            'BaseClass': Objects.GodlSet,
460            'ParentTags': ('typedef', 'array', 'set', 'bag', 'list',
461                           'sequence', 'key', 'value', 'member', 'case',
462                           'default', 'target', 'returns', 'parameter',
463                           'attribute',),
464          },
465    
466          'bag':
467          {
468            'BaseClass': Objects.GodlBag,
469            'ParentTags': ('typedef', 'array', 'set', 'bag', 'list',
470                           'sequence', 'key', 'value', 'member', 'case',
471                           'default', 'target', 'returns', 'parameter',
472                           'attribute',),
473          },
474    
475          'list':
476          {
477            'BaseClass': Objects.GodlList,
478            'ParentTags': ('typedef', 'array', 'set', 'bag', 'list',
479                           'sequence', 'key', 'value', 'member', 'case',
480                           'default', 'target', 'returns', 'parameter',
481                           'attribute',),
482          },
483            
484          'dictionary':
485          {
486            'BaseClass': Objects.GodlDictionary,
487            'ParentTags': ('typedef', 'array', 'set', 'bag', 'list',
488                           'sequence', 'key', 'value', 'member', 'case',
489                           'default', 'target', 'returns', 'parameter',
490                           'attribute',),
491          },
492    
493          'key':
494          {
495            'BaseClass': Objects.GodlKey,
496            'Required': 1,
497            'SingleInstance': 1,
498            'ParentTags': ('dictionary',),
499          },
500    
501          'value':
502          {
503            'BaseClass': Objects.GodlValue,
504            'Required': 1,
505            'SingleInstance': 1,
506            'ParentTags': ('dictionary',),
507          },
508      }      }
509    
510    return xmlElements    return xmlElements
# Line 258  class xmlGodlHandler (GParser.xmlHandler Line 523  class xmlGodlHandler (GParser.xmlHandler
523      GParser.xmlHandler.__init__(self)      GParser.xmlHandler.__init__(self)
524    
525      self.xmlElements = getXMLelements()      self.xmlElements = getXMLelements()
526    
527    if __name__ == '__main__':
528      import sys
529      from gnue.common.FileUtils import openResource
530      
531      fin = openResource(sys.argv[1])
532      objdefs = loadDefinition(fin, 0)
533      fin.close()
534      objdefs.showTree()

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.4.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26