source: ruby/trunk/adl_parser/lib/adl_parser.rb@ 4

Last change on this file since 4 was 4, checked in by KOBAYASHI, Shinji, 16 years ago

restructuring repository tree

File size: 12.0 KB
Line 
1#
2# DO NOT MODIFY!!!!
3# This file is automatically generated by racc 1.4.5
4# from racc grammer file "lib/adl_parser.y".
5#
6
7require 'racc/parser'
8
9
10
11$:.unshift File.join(File.dirname(__FILE__))
12$DEBUG = false
13
14
15
16module OpenEHR
17
18 class ADLParser < Racc::Parser
19
20module_eval <<'..end lib/adl_parser.y modeval..id1ff841bfe3', 'lib/adl_parser.y', 93
21###----------/* keywords */ ---------------------------------------------
22@@reserved = {
23 'archetype' => :SYM_ARCHETYPE,
24 'adl_version' => :SYM_ADL_VERSION,
25 'controlled' => :SYM_IS_CONTROLLED,
26 'specialize' => :SYM_SPECIALIZE,
27 'concept' => :SYM_CONCEPT,
28 'language' => :SYM_LANGUAGE,
29 'description' => :SYM_DESCRIPTION,
30 'definition' => :SYM_DEFINITION,
31 'invariant' => :SYM_INVARIANT,
32 'ontology' => :SYM_ONTOLOGY,
33 'true' => :SYM_TRUE, #[Tt][Rr][Uu][Ee] -- -> SYM_TRUE
34 'false' => :SYM_FALSE, # [Ff][Aa][Ll][Ss][Ee] -- -> SYM_FALSE
35 'infinity' => :SYM_INFINITY # [Ii][Nn][Ff][Ii][Nn][Ii][Tt][Yy] -- -> SYM_INFINITY
36}
37
38###----------/* Scanner */ -----------------------------------------------
39
40def scan
41 until @data.nil? do
42 case @data
43 when /\A\n/ # carriage return
44 @lineno += 1
45 ;
46 when /\A[ \t\r\f]+/ #just drop it
47 ;
48 when /\A--.*\n/ # single line comment
49 @lineno += 1
50 ;
51 ###----------/* symbols */ -------------------------------------------------
52 when /\A[a-zA-Z][a-zA-Z0-9_-]+\.[a-zA-Z][a-zA-Z0-9_-]+\.[a-zA-Z0-9]+/ #V_ARCHETYPE_ID
53 yield :V_ARCHETYPE_ID, $&
54 when /\A[a-z][a-zA-Z0-9_]*/
55 word = $&.downcase
56 if @@reserved[word]
57 yield @@reserved[word], @@reserved[word]
58 end
59 when /\A\=/ # =
60 yield :SYM_EQ, :SYM_EQ
61 when /\A\>=/ # >=
62 yield :SYM_GE, :SYM_GE
63 when /\A\<=/ # <=
64 yield :SYM_LE, :SYM_LE
65 when /\A\</ # <
66 if @in_interval
67 @start_block_received = false
68 yield :SYM_LT, :SYM_LT
69 else
70 @start_block_received = true
71 yield :SYM_START_DBLOCK, :SYM_START_DBLOCK
72 end
73 when /\A\>/ # >
74 if @in_interval
75 yield :SYM_GT, :SYM_GT
76 else
77 yield :SYM_END_DBLOCK, :SYM_END_DBLOCK
78 end
79 when /\A\-/ # -
80 yield :Minus_code, :Minus_code
81 when /\A\+/ # +
82 yield :Plus_code, :Plus_code
83 when /\A\*/ # *
84 yield :Star_code, :Star_code
85 when /\A\// # /
86 yield :Slash_code, :Slash_code
87 when /\A\^/ # ^
88 yield :Caret_code, :Caret_code
89 when /\A\=/ # =
90 yield :Equal_code, :Equal_code
91 when /\A\./ # .
92 yield :Dot_code, :Dot_code
93 when /\A\;/ # ;
94 yield :Semicolon_code, :Semicolon_code
95 when /\A\,/ # ,
96 yield :Comma_code, :Comma_code
97 when /\A\:/ # :
98 yield :Colon_code, :Colon_code
99 when /\A\!/ # !
100 yield :Exclamation_code, :Exclamation_code
101 when /\A\(/ # (
102 yield :Left_parenthesis_code, :Left_parenthesis_code
103 when /\A\)/ # )
104 yield :Right_parenthesis_code, :Right_parenthesis_code
105 when /\A\$/ # $
106 yield :Dollar_code, :Dollar_code
107 when /\A\?\?/ # ??
108 yield :SYM_DT_UNKNOWN, :SYM_DT_UNKNOWN
109 when /\A\?/ # ?
110 yield :Question_mark_code, :Question_mark_code
111 when /\A[0-9]+\.[0-9]+(\.[0-9]+)*/ # ?
112 yield :V_VERSION_STRING, :V_VERSION_STRING
113 when /\A\[[a-zA-Z0-9][a-zA-Z0-9._\-]*\]/ #V_LOCAL_TERM_CODE_REF
114 yield :V_LOCAL_TERM_CODE_REF, $&
115 when /\A[a-zA-Z][a-zA-Z0-9_]*/
116 yield :V_IDENTIFIER, $&
117 when /\A\|/ # |
118 if @in_interval
119 @in_interval = false
120 elsif @start_block_received
121 @in_interval = true
122 @start_block_received = false
123 end
124 yield :SYM_INTERVAL_DELIM, :SYM_INTERVAL_DELIM
125 when /\A\[/ # [
126 yield :Left_bracket_code, :Left_bracket_code
127 when /\A\]/ # ]
128 yield :Right_bracket_code, :Right_bracket_code
129 when /\A\../ # ..
130 yield :SYM_ELLIPSIS, :SYM_ELLIPSIS
131 when /\A\.../ # ...
132 yield :SYM_LIST_CONTINUE, :SYM_LIST_CONTINUE
133
134 when /\A\[[a-zA-Z0-9._\-]+::[a-zA-Z0-9._\-]+\]/ #V_QUALIFIED_TERM_CODE_REF form [ICD10AM(1998)::F23]
135 yield :V_QUALIFIED_TERM_CODE_REF, $&
136 when /\A\[[a-zA-Z0-9._\- ]+::[a-zA-Z0-9._\- ]+\]/ #ERR_V_QUALIFIED_TERM_CODE_REF
137 yield :ERR_V_QUALIFIED_TERM_CODE_REF, $&
138 when /\Aa[ct][0-9.]+/ #V_LOCAL_CODE
139 yield :V_LOCAL_CODE, $&
140 when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})?|[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9](Z|[+-][0-9]{4})?/ #V_ISO8601_EXTENDED_DATE_TIME YYYY-MM-DDThh:mm:ss[,sss][Z|+/- -n-n-n-n-]-
141 yield :V_ISO8601_EXTENDED_DATE_TIME, $&
142 when /\A[0-2][0-9]:[0-6][0-9]:[0-6][0-9](,[0-9]+)?(Z|[+-][0-9]{4})?|[0-2][0-9]:[0-6][0-9](Z|[+-][0-9]{4})? / #V_ISO8601_EXTENDED_TIME hh:mm:ss[,sss][Z|+/-nnnn]
143 yield :V_ISO8601_EXTENDED_TIME, $&
144 when /\A[0-9]{4}-[0-1][0-9]-[0-3][0-9]|[0-9]{4}-[0-1][0-9]/ #V_ISO8601_EXTENDED_DATE YYYY-MM-DD
145 yield :V_ISO8601_EXTENDED_DATE, $&
146 when /\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?|P([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/ #V_ISO8601_DURATION PnYnMnWnDTnnHnnMnnS
147 yield :V_ISO8601_DURATION, $&
148 when /\A[A-Z][a-zA-Z0-9_]*/ #V_TYPE_IDENTIFIER
149 yield :V_ISO8601_DURATION, $&
150 when /\A[A-Z][a-zA-Z0-9_]*<[a-zA-Z0-9,_<>]+>/ #V_GENERIC_TYPE_IDENTIFIER
151 yield :V_GENERIC_TYPE_IDENTIFIER, $&
152 when /\A[0-9]+|[0-9]+[eE][+-]?[0-9]+/ #V_INTEGER
153 yield :V_INTEGER, $&
154 when /\A[0-9]+\.[0-9]+|[0-9]+\.[0-9]+[eE][+-]?[0-9]+ / #V_REAL
155 yield :V_REAL, $&
156# when /\A"((?:[^"\\]+|\\.)*)"/ #V_STRING
157 when /\A"([^"]*)"/m #V_STRING
158 yield :V_STRING, $1
159# \"[^\\\n"]*\"
160# \"[^\\\n"]*{ -- beginning of a multi-line string
161# <IN_STR> {
162# \\\\ -- match escaped backslash, i.e. \\ -> \
163# \\\" -- match escaped double quote, i.e. \” -> “
164# {UTF8CHAR}+ -- match UTF8 chars
165# [^\\\n"]+ -- match any other characters
166# \\\n[ \t\r]* -- match LF in line
167# [^\\\n"]*\" -- match final end of string
168# .|\n |
169# <<EOF>> -- unclosed String -> ERR_STRING
170# }
171# ###----------/* V_CHARACTER */ --------------------------------------------
172# \'[^\\\n']\' -- normal character in 0-127
173# \'\\n\ -- \n
174# \'\\r\ -- \r
175# \'\\t\ -- \t
176# \'\\'\ -- \’
177# \'\\\\ -- \\
178# \'{UTF8CHAR}\' -- UTF8 char
179# \'.{1,2} |
180# \'\\[0-9]+(\/)? -- invalid character -> ERR_CHARACTER
181 when /\A[a-z]+:\/\/[^<>|\\{}^~"\[\] ]*/ #V_URI
182 yield :V_URI, $&
183 when /\A\S/ #UTF8CHAR
184 yield :UTF8CHAR, $&
185 end
186 @data = $' # variable $' receives the string after the match
187 end
188 yield :EOF, nil
189 yield false, '$'
190end # of scan
191
192
193def parse(data, filename, lineno = 1, debug = false)
194 @yydebug = true
195 @parsestring = data
196 @data = data
197 @lineno = lineno
198 @filename = filename
199 @in_interval = false
200 @start_block_received = false
201 @start_block_received = false
202 yyparse self, :scan
203end
204
205def on_error( t, v, values)
206 raise Racc::ParseError, "#{@filename}:#{@lineno}: Inline syntax error on #{v.inspect}"
207end
208
209# ###----------/* CADL Blocks */ -------------------------------------------
210# \{[^{}]* -- beginning of CADL block
211# <IN_CADL_BLOCK>\{[^{}]* -- got an open brace
212# <IN_CADL_BLOCK>[^{}]*\} -- got a close brace
213
214
215
216
217
218
219### Local Variables:
220### mode:ruby
221### mode:font-lock
222### comment-column:0
223### comment-start: "### "
224### comment-end:""
225### End:
226
227
228
229
230..end lib/adl_parser.y modeval..id1ff841bfe3
231
232##### racc 1.4.5 generates ###
233
234racc_reduce_table = [
235 0, 0, :racc_error,
236 1, 36, :_reduce_none,
237 8, 37, :_reduce_none,
238 2, 38, :_reduce_none,
239 1, 46, :_reduce_none,
240 2, 46, :_reduce_none,
241 3, 47, :_reduce_none,
242 1, 48, :_reduce_none,
243 3, 48, :_reduce_none,
244 3, 49, :_reduce_none,
245 1, 49, :_reduce_none,
246 0, 39, :_reduce_none,
247 2, 39, :_reduce_none,
248 2, 40, :_reduce_none,
249 0, 41, :_reduce_none,
250 2, 41, :_reduce_none,
251 0, 42, :_reduce_none,
252 2, 42, :_reduce_none,
253 2, 43, :_reduce_none,
254 0, 44, :_reduce_none,
255 2, 44, :_reduce_none,
256 2, 45, :_reduce_none ]
257
258racc_reduce_n = 22
259
260racc_shift_n = 41
261
262racc_action_table = [
263 19, 19, 16, 16, 23, 24, 25, 11, 12, 13,
264 14, 5, 20, 21, 7, 8, 26, 27, 6, 30,
265 31, 32, 34, 36, 37, 39, 40 ]
266
267racc_action_check = [
268 11, 24, 11, 24, 17, 17, 19, 5, 7, 8,
269 9, 0, 14, 15, 2, 4, 21, 22, 1, 25,
270 27, 28, 32, 33, 35, 36, 37 ]
271
272racc_action_pointer = [
273 -6, 2, 14, nil, -9, -11, nil, 8, -7, -15,
274 nil, -21, nil, nil, -14, -14, nil, -15, nil, -2,
275 nil, -12, -12, nil, -20, -3, nil, -8, -9, nil,
276 nil, nil, -9, -9, nil, -10, -8, -2, nil, nil,
277 nil ]
278
279racc_action_default = [
280 -22, -22, -22, -1, -11, -4, -3, -22, -22, -22,
281 -5, -22, 41, -12, -22, -14, -10, -22, -7, -22,
282 -13, -22, -16, -6, -22, -22, -15, -22, -22, -8,
283 -9, -17, -22, -19, -18, -22, -22, -22, -2, -20,
284 -21 ]
285
286racc_goto_table = [
287 18, 33, 4, 9, 15, 22, 28, 3, 35, 38,
288 1, 10, 17, 29, 2 ]
289
290racc_goto_check = [
291 14, 8, 3, 4, 5, 6, 7, 2, 9, 10,
292 11, 12, 13, 14, 1 ]
293
294racc_goto_pointer = [
295 nil, 14, 7, 2, -1, -5, -10, -16, -27, -25,
296 -26, 10, 6, 1, -11 ]
297
298racc_goto_default = [
299 nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
300 nil, nil, nil, nil, nil ]
301
302racc_token_table = {
303 false => 0,
304 Object.new => 1,
305 :UMINUS => 2,
306 :UPLUS => 3,
307 "*" => 4,
308 "/" => 5,
309 "+" => 6,
310 "-" => 7,
311 :SYM_EQ => 8,
312 :SYM_NE => 9,
313 :SYM_LT => 10,
314 :SYM_START_DBLOCK => 11,
315 :SYM_GT => 12,
316 :SYM_END_DBLOCK => 13,
317 :SYM_LE => 14,
318 :SYM_GE => 15,
319 :V_ARCHETYPE_ID => 16,
320 :SYM_ARCHETYPE => 17,
321 :Left_parenthesis_code => 18,
322 :Right_parenthesis_code => 19,
323 ";" => 20,
324 :SYM_ADL_VERSION => 21,
325 :V_VERSION_STRING => 22,
326 :SYM_IS_CONTROLLED => 23,
327 :SYM_SPECIALIZE => 24,
328 :SYM_CONCEPT => 25,
329 :V_LOCAL_TERM_CODE_REF => 26,
330 :SYM_LANGUAGE => 27,
331 :V_DADL_TEXT => 28,
332 :SYM_DESCRIPTION => 29,
333 :SYM_DEFINITION => 30,
334 :V_CADL_TEXT => 31,
335 :SYM_INVARIANT => 32,
336 :V_ASSERTION_TEXT => 33,
337 :SYM_ONTOLOGY => 34 }
338
339racc_use_result_var = true
340
341racc_nt_base = 35
342
343Racc_arg = [
344 racc_action_table,
345 racc_action_check,
346 racc_action_default,
347 racc_action_pointer,
348 racc_goto_table,
349 racc_goto_check,
350 racc_goto_default,
351 racc_goto_pointer,
352 racc_nt_base,
353 racc_reduce_table,
354 racc_token_table,
355 racc_shift_n,
356 racc_reduce_n,
357 racc_use_result_var ]
358
359Racc_token_to_s_table = [
360'$end',
361'error',
362'UMINUS',
363'UPLUS',
364'"*"',
365'"/"',
366'"+"',
367'"-"',
368'SYM_EQ',
369'SYM_NE',
370'SYM_LT',
371'SYM_START_DBLOCK',
372'SYM_GT',
373'SYM_END_DBLOCK',
374'SYM_LE',
375'SYM_GE',
376'V_ARCHETYPE_ID',
377'SYM_ARCHETYPE',
378'Left_parenthesis_code',
379'Right_parenthesis_code',
380'";"',
381'SYM_ADL_VERSION',
382'V_VERSION_STRING',
383'SYM_IS_CONTROLLED',
384'SYM_SPECIALIZE',
385'SYM_CONCEPT',
386'V_LOCAL_TERM_CODE_REF',
387'SYM_LANGUAGE',
388'V_DADL_TEXT',
389'SYM_DESCRIPTION',
390'SYM_DEFINITION',
391'V_CADL_TEXT',
392'SYM_INVARIANT',
393'V_ASSERTION_TEXT',
394'SYM_ONTOLOGY',
395'$start',
396'input',
397'archetype',
398'arch_identification',
399'arch_specialisation',
400'arch_concept',
401'arch_language',
402'arch_description',
403'arch_definition',
404'arch_invariant',
405'arch_ontology',
406'arch_head',
407'arch_meta_data',
408'arch_meta_data_items',
409'arch_meta_data_item']
410
411Racc_debug_parser = true
412
413##### racc system variables end #####
414
415 # reduce 0 omitted
416
417 # reduce 1 omitted
418
419 # reduce 2 omitted
420
421 # reduce 3 omitted
422
423 # reduce 4 omitted
424
425 # reduce 5 omitted
426
427 # reduce 6 omitted
428
429 # reduce 7 omitted
430
431 # reduce 8 omitted
432
433 # reduce 9 omitted
434
435 # reduce 10 omitted
436
437 # reduce 11 omitted
438
439 # reduce 12 omitted
440
441 # reduce 13 omitted
442
443 # reduce 14 omitted
444
445 # reduce 15 omitted
446
447 # reduce 16 omitted
448
449 # reduce 17 omitted
450
451 # reduce 18 omitted
452
453 # reduce 19 omitted
454
455 # reduce 20 omitted
456
457 # reduce 21 omitted
458
459 def _reduce_none( val, _values, result )
460 result
461 end
462
463 end # class ADLParser
464
465end # module OpenEHR
Note: See TracBrowser for help on using the repository browser.