Class: ActiveFacts::CQL::Parser

Inherits:
CQLParser
  • Object
show all
Includes:
ActiveFacts
Defined in:
lib/activefacts/cql/parser.rb,
lib/activefacts/cql/nodes.rb,
lib/activefacts/cql/parser.rb

Overview

Extend the generated parser:

Direct Known Subclasses

Compiler

Defined Under Namespace

Classes: Context, InputProxy, TermDefinitionNameNode, TermLANode, TermNode

Constant Summary

Constants included from ActiveFacts

VERSION

Instance Method Summary collapse

Instance Method Details

#contextObject



201
202
203
# File 'lib/activefacts/cql/parser.rb', line 201

def context
  @context ||= Context.new(self)
end

#parse(input, options = {}) ⇒ Object



210
211
212
213
# File 'lib/activefacts/cql/parser.rb', line 210

def parse(input, options = {})
  input = InputProxy.new(input, context, self) unless input.respond_to?(:context)
  super(input, options)
end

#parse_all(input, rule_name = nil, &block) ⇒ Object



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/activefacts/cql/parser.rb', line 215

def parse_all(input, rule_name = nil, &block)
  self.root = rule_name if rule_name

  @index = 0  # Byte offset to start next parse
  @block = block
  self.consume_all_input = false
  nodes = []
  begin
    node = parse(InputProxy.new(input, context, self), :index => @index)
    unless node 
      raise failure_reason unless @index == input.size
      return nil  # No input, or no more input
    end
    if @block
      @block.call(node)
    else
      nodes << node
    end
  end until self.index == @input_length
  @block ? true : nodes
end

#unit?(s) ⇒ Boolean

Returns:

  • (Boolean)


205
206
207
208
# File 'lib/activefacts/cql/parser.rb', line 205

def unit?(s)
  # puts "Asking whether #{s.inspect} is a unit"
  true
end