Class: ActiveFacts::CQL::Parser

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

Overview

Extend the generated parser:

Direct Known Subclasses

Compiler

Defined Under Namespace

Classes: Context, InputProxy, TermDefinitionNameNode, TermLANode, TermNode

Instance Method Summary collapse

Instance Method Details

#contextObject



237
238
239
# File 'lib/activefacts/cql/parser.rb', line 237

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

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



246
247
248
249
# File 'lib/activefacts/cql/parser.rb', line 246

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



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/activefacts/cql/parser.rb', line 251

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)


241
242
243
244
# File 'lib/activefacts/cql/parser.rb', line 241

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