Class: Piggly::Parser::Nodes::Expression

Inherits:
NodeClass show all
Defined in:
lib/piggly/parser/nodes.rb

Direct Known Subclasses

Sql

Instance Attribute Summary

Attributes inherited from NodeClass

#source_text

Instance Method Summary collapse

Methods inherited from NodeClass

#assignment?, #block?, #branch?, #comment?, #datatype?, #else?, #for?, #identifier?, #if?, #indent, #keyword?, #label?, #loop?, #named?, #sql?, #statement?, #string?, #stub?, #style, #tag_id, #tagged?, #token?, #while?, #whitespace?

Methods included from Traversal

#count, #find, #flatten, #inject, #select

Instance Method Details

#expression?Boolean



95
96
97
# File 'lib/piggly/parser/nodes.rb', line 95

def expression?
  true
end

#tag(prefix = nil, id = nil) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/piggly/parser/nodes.rb', line 99

def tag(prefix = nil, id = nil)
  unless defined? @tag_id
    if named?(:cond)
      if parent.while?
        # This node is the conditional in a WHILE loop
        Tags::ConditionalLoopTag.new(prefix, id)
      elsif parent.loop?
        # This node is the conditional in a loop
        Tags::UnconditionalLoopTag.new(prefix, id)
      elsif parent.branch?
        # This node is a conditional in a branch
        Tags::ConditionalBranchTag.new(prefix, id)
      else
        Tags::EvaluationTag.new(prefix, id)
      end
    else
      Tags::EvaluationTag.new(prefix, id)
    end.tap{|tag| @tag_id = tag.id }
  end
end

#terminal?Boolean



120
121
122
# File 'lib/piggly/parser/nodes.rb', line 120

def terminal?
  false
end