Sha256: b4a5b7d209257c43d7aa194f328724299cedbe71bf728747f0de31ad655da748

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

#
#       ActiveFacts CQL Parser.
#       Parse rules relating to definition context.
#
# Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
#
module ActiveFacts
  module CQL
    grammar Context
      rule context_note
        '('
        w:who_says? s context_type discussion agreed:(',' a:as_agreed_by)? s
        ')'
        {
	  def value
	    [ w.empty? ? nil : w.value, context_type.value, discussion.text_value, agreed.empty? ? [] : agreed.a.value]
	  end
	  def ast
	    who = w.empty? ? nil : w.value
	    ag = agreed.empty? ? [] : agreed.a.value
	    Compiler::ContextNote.new context_type.value, discussion.text_value, who, ag
	  end
	}
      end

      rule who_says
        according_to agents s ','
        { def value; agents.value; end }
      end

      rule context_type
        because s       { def value; 'because'; end } /
        as_opposed_to   { def value; 'as_opposed_to'; end } /
        so_that         { def value; 'so_that'; end } /
        to_avoid        { def value; 'to_avoid'; end }
      end

      # An enforcement action, like SMS, email, log, alarm, etc.
      rule action
	id
      end

      rule discussion
        (
	  '(' discussion ')' / (!( [()] / ',' as_agreed_by) .)*
	)
	{
	  def node_type; :linking; end
	}
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activefacts-0.8.16 lib/activefacts/cql/Context.treetop
activefacts-0.8.15 lib/activefacts/cql/Context.treetop
activefacts-0.8.13 lib/activefacts/cql/Context.treetop
activefacts-0.8.12 lib/activefacts/cql/Context.treetop
activefacts-0.8.10 lib/activefacts/cql/Context.treetop