Sha256: 4df5e85ae57d7a1e8b6d63320ec54bc35a7745b6716a5703d9f89a70f9f2edaa

Contents?: true

Size: 1.17 KB

Versions: 16

Compression:

Stored size: 1.17 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
        '('
        s w:who_says? s context_type discussion agreed:(',' a:as_agreed_by)? s
        ')' 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

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

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
activefacts-cql-1.8.1 lib/activefacts/cql/parser/Context.treetop
activefacts-cql-1.8.0 lib/activefacts/cql/parser/Context.treetop
activefacts-cql-1.7.1 lib/activefacts/cql/parser/Context.treetop
activefacts-1.6.0 lib/activefacts/cql/Context.treetop
activefacts-1.5.3 lib/activefacts/cql/Context.treetop
activefacts-1.5.2 lib/activefacts/cql/Context.treetop
activefacts-1.5.1 lib/activefacts/cql/Context.treetop
activefacts-1.5.0 lib/activefacts/cql/Context.treetop
activefacts-1.3.0 lib/activefacts/cql/Context.treetop
activefacts-1.2.1 lib/activefacts/cql/Context.treetop
activefacts-1.2.0 lib/activefacts/cql/Context.treetop
activefacts-1.1.0 lib/activefacts/cql/Context.treetop
activefacts-1.0.2 lib/activefacts/cql/Context.treetop
activefacts-1.0.1 lib/activefacts/cql/Context.treetop
activefacts-1.0.0 lib/activefacts/cql/Context.treetop
activefacts-0.8.18 lib/activefacts/cql/Context.treetop