Class: ANTLR3::AST::Wizard::Pattern

Inherits:
CommonTree show all
Defined in:
lib/antlr3/tree/wizard.rb

Overview

A simple tree class that represents the skeletal structure of tree. It is used to validate tree structures as well as to extract nodes that match the pattern.

Direct Known Subclasses

WildcardPattern

Instance Attribute Summary collapse

Attributes inherited from BaseTree

#parent

Attributes included from Tree

#child_index, #column, #line, #start_index, #stop_index, #text, #token, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CommonTree

#column, #copy_node, #flat_list?, #infer_boundaries, #initialize_copy, #line, #name, #pretty_print, #source_range, #start_index, #stop_index, #text, #token_range, #type, #unknown_boundaries?

Methods inherited from BaseTree

#add_child, #children, #delete_child, #detach, #first_with_type, #flat_list?, #freshen, #inspect, #prune, #replace_children, #root?, #sanity_check, #set_child, #walk

Methods included from Tree

#ancestors, #depth, #each_ancestor, #has_child?, #leaf?, #root, #root?, #siblings, #walk

Methods inherited from Array

#pad, #pad!

Constructor Details

#initialize(payload) ⇒ Pattern

Returns a new instance of Pattern.


292
293
294
295
296
# File 'lib/antlr3/tree/wizard.rb', line 292

def initialize( payload )
  super( payload )
  @label = nil
  @has_text_arg = nil
end

Instance Attribute Details

#has_text_argObject Also known as: has_text_arg?

Returns the value of attribute has_text_arg


289
290
291
# File 'lib/antlr3/tree/wizard.rb', line 289

def has_text_arg
  @has_text_arg
end

#labelObject

Returns the value of attribute label


289
290
291
# File 'lib/antlr3/tree/wizard.rb', line 289

def label
  @label
end

Class Method Details

.parse(pattern_str, scheme) ⇒ Object


283
284
285
286
287
# File 'lib/antlr3/tree/wizard.rb', line 283

def self.parse( pattern_str, scheme )
  PatternParser.parse( 
    pattern_str, scheme, PatternAdaptor.new( scheme.token_class )
  )
end

Instance Method Details

#to_sObject


298
299
300
301
# File 'lib/antlr3/tree/wizard.rb', line 298

def to_s
  prefix = @label ? '%' << @label << ':' : ''
  return( prefix << super )
end