Class: Textpow::SyntaxNode

Inherits:
Object
  • Object
show all
Defined in:
lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb,
lib/ultra_pow_list/vendor/ruby1.9/textpow/textpow/syntax.rb

Constant Summary collapse

OPTIONS =
{:options => Oniguruma::OPTION_CAPTURE_GROUP}
@@syntaxes =

OPTIONS = => Oniguruma::OPTION_CAPTURE_GROUP

{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash, syntax = nil, name_space = :default) ⇒ SyntaxNode

Returns a new instance of SyntaxNode.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 79

def initialize hash, syntax = nil, name_space = :default
   @name_space = name_space
   @@syntaxes[@name_space] ||= {}
   @@syntaxes[@name_space][hash["scopeName"]] = self if hash["scopeName"]
   @syntax = syntax || self
   hash.each do |key, value|
      case key
      when "firstLineMatch", "foldingStartMarker", "foldingStopMarker", "match", "begin"
         begin
            instance_variable_set( "@#{key}", Oniguruma::ORegexp.new( value, OPTIONS ) )
         rescue ArgumentError => e
            raise ParsingError, "Parsing error in #{value}: #{e.to_s}"
         end
      when "content", "fileTypes", "name", "contentName", "end", "scopeName", "keyEquivalent"
         instance_variable_set( "@#{key}", value )
      when "captures", "beginCaptures", "endCaptures"
         instance_variable_set( "@#{key}", value.sort )
      when "repository"
         parse_repository value
      when "patterns"
         create_children value
      else
         STDERR.puts "Ignoring: #{key} => #{value.gsub("\n", "\n>>")}" if $DEBUG
      end
   end
end

Instance Attribute Details

#beginObject

Returns the value of attribute begin.



48
49
50
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 48

def begin
  @begin
end

#beginCapturesObject

Returns the value of attribute beginCaptures.



57
58
59
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 57

def beginCaptures
  @beginCaptures
end

#capturesObject

Returns the value of attribute captures.



56
57
58
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 56

def captures
  @captures
end

#contentObject

Returns the value of attribute content.



49
50
51
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 49

def content
  @content
end

#contentNameObject

Returns the value of attribute contentName.



52
53
54
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 52

def contentName
  @contentName
end

#endObject

Returns the value of attribute end.



53
54
55
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 53

def end
  @end
end

#endCapturesObject

Returns the value of attribute endCaptures.



58
59
60
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 58

def endCaptures
  @endCaptures
end

#fileTypesObject

Returns the value of attribute fileTypes.



50
51
52
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 50

def fileTypes
  @fileTypes
end

#firstLineMatchObject

Returns the value of attribute firstLineMatch.



44
45
46
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 44

def firstLineMatch
  @firstLineMatch
end

#foldingStartMarkerObject

Returns the value of attribute foldingStartMarker.



45
46
47
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 45

def foldingStartMarker
  @foldingStartMarker
end

#foldingStopMarkerObject

Returns the value of attribute foldingStopMarker.



46
47
48
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 46

def foldingStopMarker
  @foldingStopMarker
end

#keyEquivalentObject

Returns the value of attribute keyEquivalent.



55
56
57
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 55

def keyEquivalent
  @keyEquivalent
end

#matchObject

Returns the value of attribute match.



47
48
49
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 47

def match
  @match
end

#nameObject

Returns the value of attribute name.



51
52
53
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 51

def name
  @name
end

#patternsObject

Returns the value of attribute patterns.



60
61
62
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 60

def patterns
  @patterns
end

#repositoryObject

Returns the value of attribute repository.



59
60
61
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 59

def repository
  @repository
end

#scopeNameObject

Returns the value of attribute scopeName.



54
55
56
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 54

def scopeName
  @scopeName
end

#syntaxObject

Returns the value of attribute syntax.



43
44
45
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 43

def syntax
  @syntax
end

Class Method Details

.load(filename, name_space = :default) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 62

def self.load filename, name_space = :default
   table = nil
   case filename
   when /(\.tmSyntax|\.plist)$/
      table = Plist::parse_xml( filename )
   else
      File.open( filename ) do |f|
         table = YAML.load( f )
      end
   end
   if table
      SyntaxNode.new( table, nil, name_space )
   else
      nil
   end
end

Instance Method Details

#parse(string, processor = nil) ⇒ Object



111
112
113
114
115
116
117
118
119
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 111

def parse( string, processor = nil )
   processor.start_parsing self.scopeName if processor
   stack = [[self, nil]]
   string.each_line do |line|
      parse_line stack, line, processor
   end
   processor.end_parsing self.scopeName if processor
   processor
end

#syntaxesObject



107
108
109
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 107

def syntaxes
   @@syntaxes[@name_space]
end