Class: Textpow::SyntaxNode
- Inherits:
-
Object
- Object
- Textpow::SyntaxNode
- 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
-
#begin ⇒ Object
Returns the value of attribute begin.
-
#beginCaptures ⇒ Object
Returns the value of attribute beginCaptures.
-
#captures ⇒ Object
Returns the value of attribute captures.
-
#content ⇒ Object
Returns the value of attribute content.
-
#contentName ⇒ Object
Returns the value of attribute contentName.
-
#end ⇒ Object
Returns the value of attribute end.
-
#endCaptures ⇒ Object
Returns the value of attribute endCaptures.
-
#fileTypes ⇒ Object
Returns the value of attribute fileTypes.
-
#firstLineMatch ⇒ Object
Returns the value of attribute firstLineMatch.
-
#foldingStartMarker ⇒ Object
Returns the value of attribute foldingStartMarker.
-
#foldingStopMarker ⇒ Object
Returns the value of attribute foldingStopMarker.
-
#keyEquivalent ⇒ Object
Returns the value of attribute keyEquivalent.
-
#match ⇒ Object
Returns the value of attribute match.
-
#name ⇒ Object
Returns the value of attribute name.
-
#patterns ⇒ Object
Returns the value of attribute patterns.
-
#repository ⇒ Object
Returns the value of attribute repository.
-
#scopeName ⇒ Object
Returns the value of attribute scopeName.
-
#syntax ⇒ Object
Returns the value of attribute syntax.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash, syntax = nil, name_space = :default) ⇒ SyntaxNode
constructor
A new instance of SyntaxNode.
- #parse(string, processor = nil) ⇒ Object
- #syntaxes ⇒ Object
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
#begin ⇒ Object
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 |
#beginCaptures ⇒ Object
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 |
#captures ⇒ Object
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 |
#content ⇒ Object
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 |
#contentName ⇒ Object
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 |
#end ⇒ Object
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 |
#endCaptures ⇒ Object
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 |
#fileTypes ⇒ Object
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 |
#firstLineMatch ⇒ Object
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 |
#foldingStartMarker ⇒ Object
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 |
#foldingStopMarker ⇒ Object
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 |
#keyEquivalent ⇒ Object
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 |
#match ⇒ Object
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 |
#name ⇒ Object
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 |
#patterns ⇒ Object
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 |
#repository ⇒ Object
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 |
#scopeName ⇒ Object
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 |
#syntax ⇒ Object
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 |
#syntaxes ⇒ Object
107 108 109 |
# File 'lib/ultra_pow_list/vendor/ruby1.8/textpow/textpow/syntax.rb', line 107 def syntaxes @@syntaxes[@name_space] end |