# # Autogenerated from a Treetop grammar. Edits may be lost. # ActiveFacts CQL Parser. # Parse rules relating to high-level CQL definitions and constraints. # # Copyright (c) 2009 Clifford Heath. Read the LICENSE file. # require 'activefacts/cql/parser/LexicalRules' require 'activefacts/cql/parser/Language/English' require 'activefacts/cql/parser/Expressions' require 'activefacts/cql/parser/Terms' require 'activefacts/cql/parser/ObjectTypes' require 'activefacts/cql/parser/ValueTypes' require 'activefacts/cql/parser/FactTypes' require 'activefacts/cql/parser/TransformRules' require 'activefacts/cql/parser/Context' module ActiveFacts module CQL module CQL include Treetop::Runtime def root @root ||= :cql_file end include LexicalRules include Expressions include Terms include ObjectTypes include ValueTypes include FactTypes include TransformRules include Context module CqlFile0 def s elements[0] end def seq elements[1] end end module CqlFile1 def definitions seq.elements.map{|e| e.value rescue $stderr.puts "Can't call value() on #{e.inspect}" } end end def _nt_cql_file start_index = index if node_cache[:cql_file].has_key?(index) cached = node_cache[:cql_file][index] if cached node_cache[:cql_file][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_s s0 << r1 if r1 s2, i2 = [], index loop do r3 = _nt_definition if r3 s2 << r3 else break end end r2 = instantiate_node(SyntaxNode,input, i2...index, s2) s0 << r2 end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(CqlFile0) r0.extend(CqlFile1) else @index = i0 r0 = nil end node_cache[:cql_file][start_index] = r0 r0 end module Definition0 def definition_body elements[0] end def s elements[1] end end module Definition1 def ast definition_body.ast end def body definition_body.text_value end end def _nt_definition start_index = index if node_cache[:definition].has_key?(index) cached = node_cache[:definition][index] if cached node_cache[:definition][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_definition_body s0 << r1 if r1 r2 = _nt_s s0 << r2 end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(Definition0) r0.extend(Definition1) else @index = i0 r0 = nil end node_cache[:definition][start_index] = r0 r0 end module DefinitionBody0 end module DefinitionBody1 def s1 elements[0] end def s2 elements[2] end end module DefinitionBody2 def ast; nil; end end def _nt_definition_body start_index = index if node_cache[:definition_body].has_key?(index) cached = node_cache[:definition_body][index] if cached node_cache[:definition_body][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index r1 = _nt_vocabulary_definition if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else r2 = _nt_import_definition if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r0 = r2 else i3, s3 = index, [] if (match_len = has_terminal?('', false, index)) r4 = true @index += match_len else terminal_parse_failure('\'\'') r4 = nil end s3 << r4 if r4 i5 = index r6 = lambda {|s| _nt_prescan; false }.call(s3) if !r6 terminal_parse_failure("") end if r6 @index = i5 r5 = instantiate_node(SyntaxNode,input, index...index) else @index = i5 r5 = nil end s3 << r5 end if s3.last r3 = instantiate_node(SyntaxNode,input, i3...index, s3) r3.extend(DefinitionBody0) else @index = i3 r3 = nil end if r3 r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true r0 = r3 else r7 = _nt_constraint if r7 r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true r0 = r7 else r8 = _nt_unit_definition if r8 r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true r0 = r8 else r9 = _nt_object_type if r9 r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true r0 = r9 else r10 = _nt_informal_description if r10 r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true r0 = r10 else r11 = _nt_query if r11 r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true r0 = r11 else r12 = _nt_transform_rule if r12 r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true r0 = r12 else i13, s13 = index, [] r14 = _nt_s s13 << r14 if r14 if (match_len = has_terminal?(';', false, index)) r15 = true @index += match_len else terminal_parse_failure('\';\'') r15 = nil end s13 << r15 if r15 r16 = _nt_s s13 << r16 end end if s13.last r13 = instantiate_node(SyntaxNode,input, i13...index, s13) r13.extend(DefinitionBody1) r13.extend(DefinitionBody2) else @index = i13 r13 = nil end if r13 r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true r0 = r13 else @index = i0 r0 = nil end end end end end end end end end end node_cache[:definition_body][start_index] = r0 r0 end def _nt_vocabulary_definition start_index = index if node_cache[:vocabulary_definition].has_key?(index) cached = node_cache[:vocabulary_definition][index] if cached node_cache[:vocabulary_definition][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index r1 = _nt_schema_definition if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else r2 = _nt_transform_definition if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r0 = r2 else @index = i0 r0 = nil end end node_cache[:vocabulary_definition][start_index] = r0 r0 end module SchemaDefinition0 def s1 elements[0] end def S elements[2] end def vocabulary_name elements[3] end def vn elements[4] end def s2 elements[5] end end module SchemaDefinition1 def ast Compiler::Vocabulary.new(vocabulary_name.value, false, vn.empty? ? nil : vn.value) end end def _nt_schema_definition start_index = index if node_cache[:schema_definition].has_key?(index) cached = node_cache[:schema_definition][index] if cached node_cache[:schema_definition][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_s s0 << r1 if r1 i2 = index r3 = _nt_schema if r3 r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true r2 = r3 else r4 = _nt_topic if r4 r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true r2 = r4 else r5 = _nt_vocabulary if r5 r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true r2 = r5 else @index = i2 r2 = nil end end end s0 << r2 if r2 r6 = _nt_S s0 << r6 if r6 r7 = _nt_vocabulary_name s0 << r7 if r7 r9 = _nt_version_number if r9 r8 = r9 else r8 = instantiate_node(SyntaxNode,input, index...index) end s0 << r8 if r8 r10 = _nt_s s0 << r10 if r10 if (match_len = has_terminal?(';', false, index)) r11 = true @index += match_len else terminal_parse_failure('\';\'') r11 = nil end s0 << r11 end end end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(SchemaDefinition0) r0.extend(SchemaDefinition1) else @index = i0 r0 = nil end node_cache[:schema_definition][start_index] = r0 r0 end module TransformDefinition0 def s1 elements[0] end def transform elements[1] end def S elements[2] end def vocabulary_name elements[3] end def vn elements[4] end def s2 elements[5] end end module TransformDefinition1 def ast Compiler::Vocabulary.new(vocabulary_name.value, true, vn.empty? ? nil : vn.value) end end def _nt_transform_definition start_index = index if node_cache[:transform_definition].has_key?(index) cached = node_cache[:transform_definition][index] if cached node_cache[:transform_definition][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_s s0 << r1 if r1 r2 = _nt_transform s0 << r2 if r2 r3 = _nt_S s0 << r3 if r3 r4 = _nt_vocabulary_name s0 << r4 if r4 r6 = _nt_version_number if r6 r5 = r6 else r5 = instantiate_node(SyntaxNode,input, index...index) end s0 << r5 if r5 r7 = _nt_s s0 << r7 if r7 if (match_len = has_terminal?(';', false, index)) r8 = true @index += match_len else terminal_parse_failure('\';\'') r8 = nil end s0 << r8 end end end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(TransformDefinition0) r0.extend(TransformDefinition1) else @index = i0 r0 = nil end node_cache[:transform_definition][start_index] = r0 r0 end module VocabularyName0 def S elements[0] end def id elements[2] end end module VocabularyName1 def id elements[0] end def tail elements[1] end end module VocabularyName2 def node_type; :vocabulary; end def value [id.value, *tail.elements.map{|e| e.id.value }].join(' ') end end def _nt_vocabulary_name start_index = index if node_cache[:vocabulary_name].has_key?(index) cached = node_cache[:vocabulary_name][index] if cached node_cache[:vocabulary_name][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_id s0 << r1 if r1 s2, i2 = [], index loop do i3, s3 = index, [] r4 = _nt_S s3 << r4 if r4 i5 = index r6 = _nt_version if r6 @index = i5 r5 = nil else @index = i5 r5 = instantiate_node(SyntaxNode,input, index...index) end s3 << r5 if r5 r7 = _nt_id s3 << r7 end end if s3.last r3 = instantiate_node(SyntaxNode,input, i3...index, s3) r3.extend(VocabularyName0) else @index = i3 r3 = nil end if r3 s2 << r3 else break end end r2 = instantiate_node(SyntaxNode,input, i2...index, s2) s0 << r2 end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(VocabularyName1) r0.extend(VocabularyName2) else @index = i0 r0 = nil end node_cache[:vocabulary_name][start_index] = r0 r0 end module ImportDefinition0 def s elements[0] end def import elements[1] end def i elements[2] end def S elements[3] end def vocabulary_name elements[4] end def vp elements[5] end def alias_list elements[6] end end module ImportDefinition1 def ast Compiler::Import.new( import.input.parser, vocabulary_name.value, i.empty? ? "topic" : i.value, vp.empty? ? nil : vp.value, alias_list.value ) end end def _nt_import_definition start_index = index if node_cache[:import_definition].has_key?(index) cached = node_cache[:import_definition][index] if cached node_cache[:import_definition][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_s s0 << r1 if r1 r2 = _nt_import s0 << r2 if r2 r4 = _nt_import_role if r4 r3 = r4 else r3 = instantiate_node(SyntaxNode,input, index...index) end s0 << r3 if r3 r5 = _nt_S s0 << r5 if r5 r6 = _nt_vocabulary_name s0 << r6 if r6 r8 = _nt_version_pattern if r8 r7 = r8 else r7 = instantiate_node(SyntaxNode,input, index...index) end s0 << r7 if r7 r9 = _nt_alias_list s0 << r9 if r9 if (match_len = has_terminal?(';', false, index)) r10 = true @index += match_len else terminal_parse_failure('\';\'') r10 = nil end s0 << r10 end end end end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(ImportDefinition0) r0.extend(ImportDefinition1) else @index = i0 r0 = nil end node_cache[:import_definition][start_index] = r0 r0 end module VersionNumber0 def S1 elements[0] end def version elements[1] end def S2 elements[2] end def version_number_string elements[3] end end module VersionNumber1 def value version_number_string.text_value end end def _nt_version_number start_index = index if node_cache[:version_number].has_key?(index) cached = node_cache[:version_number][index] if cached node_cache[:version_number][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_S s0 << r1 if r1 r2 = _nt_version s0 << r2 if r2 r3 = _nt_S s0 << r3 if r3 r4 = _nt_version_number_string s0 << r4 end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(VersionNumber0) r0.extend(VersionNumber1) else @index = i0 r0 = nil end node_cache[:version_number][start_index] = r0 r0 end module VersionPattern0 def S1 elements[0] end def version elements[1] end def S2 elements[2] end def version_pattern_string elements[3] end end module VersionPattern1 def value version_pattern_string.text_value end end def _nt_version_pattern start_index = index if node_cache[:version_pattern].has_key?(index) cached = node_cache[:version_pattern][index] if cached node_cache[:version_pattern][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_S s0 << r1 if r1 r2 = _nt_version s0 << r2 if r2 r3 = _nt_S s0 << r3 if r3 r4 = _nt_version_pattern_string s0 << r4 end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(VersionPattern0) r0.extend(VersionPattern1) else @index = i0 r0 = nil end node_cache[:version_pattern][start_index] = r0 r0 end module VersionNumberString0 end module VersionNumberString1 end module VersionNumberString2 end def _nt_version_number_string start_index = index if node_cache[:version_number_string].has_key?(index) cached = node_cache[:version_number_string][index] if cached node_cache[:version_number_string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] s1, i1 = [], index loop do if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index) r2 = true @index += 1 else terminal_parse_failure('[0-9]') r2 = nil end if r2 s1 << r2 else break end end if s1.empty? @index = i1 r1 = nil else r1 = instantiate_node(SyntaxNode,input, i1...index, s1) end s0 << r1 if r1 if (match_len = has_terminal?('.', false, index)) r3 = true @index += match_len else terminal_parse_failure('\'.\'') r3 = nil end s0 << r3 if r3 s4, i4 = [], index loop do if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index) r5 = true @index += 1 else terminal_parse_failure('[0-9]') r5 = nil end if r5 s4 << r5 else break end end if s4.empty? @index = i4 r4 = nil else r4 = instantiate_node(SyntaxNode,input, i4...index, s4) end s0 << r4 if r4 if (match_len = has_terminal?('.', false, index)) r6 = true @index += match_len else terminal_parse_failure('\'.\'') r6 = nil end s0 << r6 if r6 s7, i7 = [], index loop do if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index) r8 = true @index += 1 else terminal_parse_failure('[0-9]') r8 = nil end if r8 s7 << r8 else break end end if s7.empty? @index = i7 r7 = nil else r7 = instantiate_node(SyntaxNode,input, i7...index, s7) end s0 << r7 if r7 i10, s10 = index, [] if (match_len = has_terminal?('-', false, index)) r11 = true @index += match_len else terminal_parse_failure('\'-\'') r11 = nil end s10 << r11 if r11 s12, i12 = [], index loop do if has_terminal?(@regexps[gr = '\A[0-9A-Za-z-]'] ||= Regexp.new(gr), :regexp, index) r13 = true @index += 1 else terminal_parse_failure('[0-9A-Za-z-]') r13 = nil end if r13 s12 << r13 else break end end if s12.empty? @index = i12 r12 = nil else r12 = instantiate_node(SyntaxNode,input, i12...index, s12) end s10 << r12 if r12 s14, i14 = [], index loop do i15, s15 = index, [] if (match_len = has_terminal?('.', false, index)) r16 = true @index += match_len else terminal_parse_failure('\'.\'') r16 = nil end s15 << r16 if r16 s17, i17 = [], index loop do if has_terminal?(@regexps[gr = '\A[0-9A-Za-z-]'] ||= Regexp.new(gr), :regexp, index) r18 = true @index += 1 else terminal_parse_failure('[0-9A-Za-z-]') r18 = nil end if r18 s17 << r18 else break end end if s17.empty? @index = i17 r17 = nil else r17 = instantiate_node(SyntaxNode,input, i17...index, s17) end s15 << r17 end if s15.last r15 = instantiate_node(SyntaxNode,input, i15...index, s15) r15.extend(VersionNumberString0) else @index = i15 r15 = nil end if r15 s14 << r15 else break end end r14 = instantiate_node(SyntaxNode,input, i14...index, s14) s10 << r14 end end if s10.last r10 = instantiate_node(SyntaxNode,input, i10...index, s10) r10.extend(VersionNumberString1) else @index = i10 r10 = nil end if r10 r9 = r10 else r9 = instantiate_node(SyntaxNode,input, index...index) end s0 << r9 end end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(VersionNumberString2) else @index = i0 r0 = nil end node_cache[:version_number_string][start_index] = r0 r0 end module VersionPatternString0 end module VersionPatternString1 end module VersionPatternString2 end module VersionPatternString3 end module VersionPatternString4 end def _nt_version_pattern_string start_index = index if node_cache[:version_pattern_string].has_key?(index) cached = node_cache[:version_pattern_string][index] if cached node_cache[:version_pattern_string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] s1, i1 = [], index loop do if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index) r2 = true @index += 1 else terminal_parse_failure('[0-9]') r2 = nil end if r2 s1 << r2 else break end end if s1.empty? @index = i1 r1 = nil else r1 = instantiate_node(SyntaxNode,input, i1...index, s1) end s0 << r1 if r1 i4, s4 = index, [] if (match_len = has_terminal?('.', false, index)) r5 = true @index += match_len else terminal_parse_failure('\'.\'') r5 = nil end s4 << r5 if r5 s6, i6 = [], index loop do if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index) r7 = true @index += 1 else terminal_parse_failure('[0-9]') r7 = nil end if r7 s6 << r7 else break end end if s6.empty? @index = i6 r6 = nil else r6 = instantiate_node(SyntaxNode,input, i6...index, s6) end s4 << r6 if r6 i9, s9 = index, [] if (match_len = has_terminal?('.', false, index)) r10 = true @index += match_len else terminal_parse_failure('\'.\'') r10 = nil end s9 << r10 if r10 s11, i11 = [], index loop do if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index) r12 = true @index += 1 else terminal_parse_failure('[0-9]') r12 = nil end if r12 s11 << r12 else break end end if s11.empty? @index = i11 r11 = nil else r11 = instantiate_node(SyntaxNode,input, i11...index, s11) end s9 << r11 if r11 i14, s14 = index, [] if (match_len = has_terminal?('-', false, index)) r15 = true @index += match_len else terminal_parse_failure('\'-\'') r15 = nil end s14 << r15 if r15 s16, i16 = [], index loop do if has_terminal?(@regexps[gr = '\A[0-9A-Za-z-]'] ||= Regexp.new(gr), :regexp, index) r17 = true @index += 1 else terminal_parse_failure('[0-9A-Za-z-]') r17 = nil end if r17 s16 << r17 else break end end if s16.empty? @index = i16 r16 = nil else r16 = instantiate_node(SyntaxNode,input, i16...index, s16) end s14 << r16 if r16 s18, i18 = [], index loop do i19, s19 = index, [] if (match_len = has_terminal?('.', false, index)) r20 = true @index += match_len else terminal_parse_failure('\'.\'') r20 = nil end s19 << r20 if r20 s21, i21 = [], index loop do if has_terminal?(@regexps[gr = '\A[0-9A-Za-z-]'] ||= Regexp.new(gr), :regexp, index) r22 = true @index += 1 else terminal_parse_failure('[0-9A-Za-z-]') r22 = nil end if r22 s21 << r22 else break end end if s21.empty? @index = i21 r21 = nil else r21 = instantiate_node(SyntaxNode,input, i21...index, s21) end s19 << r21 end if s19.last r19 = instantiate_node(SyntaxNode,input, i19...index, s19) r19.extend(VersionPatternString0) else @index = i19 r19 = nil end if r19 s18 << r19 else break end end r18 = instantiate_node(SyntaxNode,input, i18...index, s18) s14 << r18 end end if s14.last r14 = instantiate_node(SyntaxNode,input, i14...index, s14) r14.extend(VersionPatternString1) else @index = i14 r14 = nil end if r14 r13 = r14 else r13 = instantiate_node(SyntaxNode,input, index...index) end s9 << r13 end end if s9.last r9 = instantiate_node(SyntaxNode,input, i9...index, s9) r9.extend(VersionPatternString2) else @index = i9 r9 = nil end if r9 r8 = r9 else r8 = instantiate_node(SyntaxNode,input, index...index) end s4 << r8 end end if s4.last r4 = instantiate_node(SyntaxNode,input, i4...index, s4) r4.extend(VersionPatternString3) else @index = i4 r4 = nil end if r4 r3 = r4 else r3 = instantiate_node(SyntaxNode,input, index...index) end s0 << r3 end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(VersionPatternString4) else @index = i0 r0 = nil end node_cache[:version_pattern_string][start_index] = r0 r0 end module ImportRole0 def S elements[0] end def id elements[1] end end module ImportRole1 def value id.text_value end end def _nt_import_role start_index = index if node_cache[:import_role].has_key?(index) cached = node_cache[:import_role][index] if cached node_cache[:import_role][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_S s0 << r1 if r1 r2 = _nt_id s0 << r2 end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(ImportRole0) r0.extend(ImportRole1) else @index = i0 r0 = nil end node_cache[:import_role][start_index] = r0 r0 end module AliasList0 def s1 elements[0] end def s2 elements[2] end def alias elements[3] end def S1 elements[4] end def aliased_from elements[5] end def S2 elements[6] end def as elements[7] end def S3 elements[8] end def alias_to elements[9] end def s3 elements[10] end end module AliasList1 def value elements.inject({}){|h, e| h[e.aliased_from.value] = e.alias_to; h } end end def _nt_alias_list start_index = index if node_cache[:alias_list].has_key?(index) cached = node_cache[:alias_list][index] if cached node_cache[:alias_list][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end s0, i0 = [], index loop do i1, s1 = index, [] r2 = _nt_s s1 << r2 if r2 if (match_len = has_terminal?(',', false, index)) r3 = true @index += match_len else terminal_parse_failure('\',\'') r3 = nil end s1 << r3 if r3 r4 = _nt_s s1 << r4 if r4 r5 = _nt_alias s1 << r5 if r5 r6 = _nt_S s1 << r6 if r6 r7 = _nt_alias_term s1 << r7 if r7 r8 = _nt_S s1 << r8 if r8 r9 = _nt_as s1 << r9 if r9 r10 = _nt_S s1 << r10 if r10 r11 = _nt_alias_term s1 << r11 if r11 r12 = _nt_s s1 << r12 end end end end end end end end end end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(AliasList0) else @index = i1 r1 = nil end if r1 s0 << r1 else break end end r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(AliasList1) r0.extend(AliasList1) node_cache[:alias_list][start_index] = r0 r0 end module AliasTerm0 def node_type; :term; end end def _nt_alias_term start_index = index if node_cache[:alias_term].has_key?(index) cached = node_cache[:alias_term][index] if cached node_cache[:alias_term][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end r0 = _nt_id r0.extend(AliasTerm0) r0.extend(AliasTerm0) node_cache[:alias_term][start_index] = r0 r0 end module InformalDescription0 def informally elements[0] end def s1 elements[1] end def s2 elements[3] end def subject elements[4] end def s3 elements[5] end def informal_description_body elements[6] end def informal_description_closer elements[7] end end module InformalDescription1 def ast kind = subject.signifier.text_value.to_sym subject_name = (kind == :each ? subject.term.text_value : subject.reading.text_value) phrases = subject.reading.elements.map(&:ast) if kind == :when Compiler::InformalDefinition.new(kind, subject_name, phrases, informal_description_body.text_value) end end def _nt_informal_description start_index = index if node_cache[:informal_description].has_key?(index) cached = node_cache[:informal_description][index] if cached node_cache[:informal_description][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0, s0 = index, [] r1 = _nt_informally s0 << r1 if r1 r2 = _nt_s s0 << r2 if r2 if (match_len = has_terminal?(',', false, index)) r3 = true @index += match_len else terminal_parse_failure('\',\'') r3 = nil end s0 << r3 if r3 r4 = _nt_s s0 << r4 if r4 r5 = _nt_informal_description_subject s0 << r5 if r5 r6 = _nt_s s0 << r6 if r6 r7 = _nt_informal_description_body s0 << r7 if r7 r8 = _nt_informal_description_closer s0 << r8 end end end end end end end if s0.last r0 = instantiate_node(SyntaxNode,input, i0...index, s0) r0.extend(InformalDescription0) r0.extend(InformalDescription1) else @index = i0 r0 = nil end node_cache[:informal_description][start_index] = r0 r0 end module InformalDescriptionSubject0 def signifier elements[0] end def S elements[1] end def term elements[2] end end module InformalDescriptionSubject1 def signifier elements[0] end def S elements[1] end def reading elements[2] end def s elements[3] end end def _nt_informal_description_subject start_index = index if node_cache[:informal_description_subject].has_key?(index) cached = node_cache[:informal_description_subject][index] if cached node_cache[:informal_description_subject][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index i1, s1 = index, [] r2 = _nt_each s1 << r2 if r2 r3 = _nt_S s1 << r3 if r3 r4 = _nt_term s1 << r4 end end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(InformalDescriptionSubject0) else @index = i1 r1 = nil end if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else i5, s5 = index, [] r6 = _nt_when s5 << r6 if r6 r7 = _nt_S s5 << r7 if r7 s8, i8 = [], index loop do r9 = _nt_phrase if r9 s8 << r9 else break end end if s8.empty? @index = i8 r8 = nil else r8 = instantiate_node(SyntaxNode,input, i8...index, s8) end s5 << r8 if r8 r10 = _nt_s s5 << r10 if r10 if (match_len = has_terminal?(',', false, index)) r11 = true @index += match_len else terminal_parse_failure('\',\'') r11 = nil end s5 << r11 end end end end if s5.last r5 = instantiate_node(SyntaxNode,input, i5...index, s5) r5.extend(InformalDescriptionSubject1) else @index = i5 r5 = nil end if r5 r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true r0 = r5 else @index = i0 r0 = nil end end node_cache[:informal_description_subject][start_index] = r0 r0 end module InformalDescriptionBody0 end def _nt_informal_description_body start_index = index if node_cache[:informal_description_body].has_key?(index) cached = node_cache[:informal_description_body][index] if cached node_cache[:informal_description_body][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end s0, i0 = [], index loop do i1, s1 = index, [] i2 = index r3 = _nt_informal_description_closer if r3 @index = i2 r2 = nil else @index = i2 r2 = instantiate_node(SyntaxNode,input, index...index) end s1 << r2 if r2 i4 = index r5 = _nt_string if r5 r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true r4 = r5 else if index < input_length r6 = true @index += 1 else terminal_parse_failure("any character") r6 = nil end if r6 r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true r4 = r6 else @index = i4 r4 = nil end end s1 << r4 end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(InformalDescriptionBody0) else @index = i1 r1 = nil end if r1 s0 << r1 else break end end r0 = instantiate_node(SyntaxNode,input, i0...index, s0) node_cache[:informal_description_body][start_index] = r0 r0 end module InformalDescriptionCloser0 end def _nt_informal_description_closer start_index = index if node_cache[:informal_description_closer].has_key?(index) cached = node_cache[:informal_description_closer][index] if cached node_cache[:informal_description_closer][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index i1 = index if index < input_length r2 = true @index += 1 else terminal_parse_failure("any character") r2 = nil end if r2 @index = i1 r1 = nil terminal_parse_failure("any character", true) else @terminal_failures.pop @index = i1 r1 = instantiate_node(SyntaxNode,input, index...index) end if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else i3, s3 = index, [] if (match_len = has_terminal?('.', false, index)) r4 = true @index += match_len else terminal_parse_failure('\'.\'') r4 = nil end s3 << r4 if r4 s5, i5 = [], index loop do if has_terminal?(@regexps[gr = '\A[ \\t\\r]'] ||= Regexp.new(gr), :regexp, index) r6 = true @index += 1 else terminal_parse_failure('[ \\t\\r]') r6 = nil end if r6 s5 << r6 else break end end r5 = instantiate_node(SyntaxNode,input, i5...index, s5) s3 << r5 if r5 if (match_len = has_terminal?("\n", false, index)) r7 = true @index += match_len else terminal_parse_failure('"\\n"') r7 = nil end s3 << r7 end end if s3.last r3 = instantiate_node(SyntaxNode,input, i3...index, s3) r3.extend(InformalDescriptionCloser0) else @index = i3 r3 = nil end if r3 r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true r0 = r3 else @index = i0 r0 = nil end end node_cache[:informal_description_closer][start_index] = r0 r0 end def _nt_constraint start_index = index if node_cache[:constraint].has_key?(index) cached = node_cache[:constraint][index] if cached node_cache[:constraint][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index r1 = _nt_subset_constraint if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else r2 = _nt_equality_constraint if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r0 = r2 else r3 = _nt_set_constraint if r3 r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true r0 = r3 else r4 = _nt_presence_constraint if r4 r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true r0 = r4 else @index = i0 r0 = nil end end end end node_cache[:constraint][start_index] = r0 r0 end module Enforcement0 def s1 elements[0] end def s2 elements[2] end def otherwise elements[3] end def s3 elements[4] end def action elements[5] end def s4 elements[6] end def a elements[7] end def s5 elements[8] end def s6 elements[10] end end module Enforcement1 def ast; Compiler::Enforcement.new(action.text_value, a.empty? ? nil : a.text_value); end end module Enforcement2 def ast; nil; end end def _nt_enforcement start_index = index if node_cache[:enforcement].has_key?(index) cached = node_cache[:enforcement][index] if cached node_cache[:enforcement][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index i1, s1 = index, [] r2 = _nt_s s1 << r2 if r2 if (match_len = has_terminal?('(', false, index)) r3 = true @index += match_len else terminal_parse_failure('\'(\'') r3 = nil end s1 << r3 if r3 r4 = _nt_s s1 << r4 if r4 r5 = _nt_otherwise s1 << r5 if r5 r6 = _nt_s s1 << r6 if r6 r7 = _nt_id s1 << r7 if r7 r8 = _nt_s s1 << r8 if r8 r10 = _nt_agent if r10 r9 = r10 else r9 = instantiate_node(SyntaxNode,input, index...index) end s1 << r9 if r9 r11 = _nt_s s1 << r11 if r11 if (match_len = has_terminal?(')', false, index)) r12 = true @index += match_len else terminal_parse_failure('\')\'') r12 = nil end s1 << r12 if r12 r13 = _nt_s s1 << r13 end end end end end end end end end end if s1.last r1 = instantiate_node(SyntaxNode,input, i1...index, s1) r1.extend(Enforcement0) r1.extend(Enforcement1) else @index = i1 r1 = nil end if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 else if (match_len = has_terminal?('', false, index)) r14 = instantiate_node(SyntaxNode,input, index...(index + match_len)) r14.extend(Enforcement2) @index += match_len else terminal_parse_failure('\'\'') r14 = nil end if r14 r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true r0 = r14 else @index = i0 r0 = nil end end node_cache[:enforcement][start_index] = r0 r0 end module PresenceConstraint0 def ast Compiler::PresenceConstraint.new c, enforcement.ast, clauses_ast, role_list_ast, quantifier_ast end end def _nt_presence_constraint start_index = index if node_cache[:presence_constraint].has_key?(index) cached = node_cache[:presence_constraint][index] if cached node_cache[:presence_constraint][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index r1 = _nt_each_occurs_in_clauses if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 r0.extend(PresenceConstraint0) r0.extend(PresenceConstraint0) else r2 = _nt_either_or if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r0 = r2 r0.extend(PresenceConstraint0) r0.extend(PresenceConstraint0) else @index = i0 r0 = nil end end node_cache[:presence_constraint][start_index] = r0 r0 end module SetConstraint0 def ast Compiler::SetExclusionConstraint.new c, enforcement.ast, clauses_ast, role_list_ast, quantifier_ast end end def _nt_set_constraint start_index = index if node_cache[:set_constraint].has_key?(index) cached = node_cache[:set_constraint][index] if cached node_cache[:set_constraint][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index r1 = _nt_for_each_how_many if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 r0.extend(SetConstraint0) r0.extend(SetConstraint0) else r2 = _nt_either_or_not_both if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r0 = r2 r0.extend(SetConstraint0) r0.extend(SetConstraint0) else @index = i0 r0 = nil end end node_cache[:set_constraint][start_index] = r0 r0 end module SubsetConstraint0 def ast Compiler::SubsetConstraint.new c, enforcement.ast, [clauses.ast, r2.ast] end end def _nt_subset_constraint start_index = index if node_cache[:subset_constraint].has_key?(index) cached = node_cache[:subset_constraint][index] if cached node_cache[:subset_constraint][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end i0 = index r1 = _nt_a_only_if_b if r1 r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true r0 = r1 r0.extend(SubsetConstraint0) r0.extend(SubsetConstraint0) else r2 = _nt_if_b_then_a if r2 r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true r0 = r2 r0.extend(SubsetConstraint0) r0.extend(SubsetConstraint0) else @index = i0 r0 = nil end end node_cache[:subset_constraint][start_index] = r0 r0 end module EqualityConstraint0 def ast all_clauses = [clauses.ast, *tail.elements.map{|e| e.clauses.ast }] Compiler::SetEqualityConstraint.new c, enforcement.ast, all_clauses end end def _nt_equality_constraint start_index = index if node_cache[:equality_constraint].has_key?(index) cached = node_cache[:equality_constraint][index] if cached node_cache[:equality_constraint][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true @index = cached.interval.end end return cached end r0 = _nt_if_and_only_if r0.extend(EqualityConstraint0) r0.extend(EqualityConstraint0) node_cache[:equality_constraint][start_index] = r0 r0 end end class CQLParser < Treetop::Runtime::CompiledParser include CQL end end end