Class: Textpow::SyntaxNode

Inherits:
Object
  • Object
show all
Defined in:
lib/textpow/syntax.rb

Constant Summary collapse

@@syntaxes =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table, options = {}) ⇒ SyntaxNode

Returns a new instance of SyntaxNode.



64
65
66
67
68
69
70
# File 'lib/textpow/syntax.rb', line 64

def initialize(table, options={})
  @syntax = options[:syntax] || self
  @name_space = options[:name_space]

  register_in_syntaxes(table["scopeName"])
  parse_and_store_syntax_info(table)
end

Instance Attribute Details

#beginObject

Returns the value of attribute begin.



45
46
47
# File 'lib/textpow/syntax.rb', line 45

def begin
  @begin
end

#beginCapturesObject

Returns the value of attribute beginCaptures.



54
55
56
# File 'lib/textpow/syntax.rb', line 54

def beginCaptures
  @beginCaptures
end

#capturesObject

Returns the value of attribute captures.



53
54
55
# File 'lib/textpow/syntax.rb', line 53

def captures
  @captures
end

#contentObject

Returns the value of attribute content.



46
47
48
# File 'lib/textpow/syntax.rb', line 46

def content
  @content
end

#contentNameObject

Returns the value of attribute contentName.



49
50
51
# File 'lib/textpow/syntax.rb', line 49

def contentName
  @contentName
end

#endObject

Returns the value of attribute end.



50
51
52
# File 'lib/textpow/syntax.rb', line 50

def end
  @end
end

#endCapturesObject

Returns the value of attribute endCaptures.



55
56
57
# File 'lib/textpow/syntax.rb', line 55

def endCaptures
  @endCaptures
end

#fileTypesObject

Returns the value of attribute fileTypes.



47
48
49
# File 'lib/textpow/syntax.rb', line 47

def fileTypes
  @fileTypes
end

#firstLineMatchObject

Returns the value of attribute firstLineMatch.



41
42
43
# File 'lib/textpow/syntax.rb', line 41

def firstLineMatch
  @firstLineMatch
end

#foldingStartMarkerObject

Returns the value of attribute foldingStartMarker.



42
43
44
# File 'lib/textpow/syntax.rb', line 42

def foldingStartMarker
  @foldingStartMarker
end

#foldingStopMarkerObject

Returns the value of attribute foldingStopMarker.



43
44
45
# File 'lib/textpow/syntax.rb', line 43

def foldingStopMarker
  @foldingStopMarker
end

#keyEquivalentObject

Returns the value of attribute keyEquivalent.



52
53
54
# File 'lib/textpow/syntax.rb', line 52

def keyEquivalent
  @keyEquivalent
end

#matchObject

Returns the value of attribute match.



44
45
46
# File 'lib/textpow/syntax.rb', line 44

def match
  @match
end

#nameObject

Returns the value of attribute name.



48
49
50
# File 'lib/textpow/syntax.rb', line 48

def name
  @name
end

#patternsObject

Returns the value of attribute patterns.



57
58
59
# File 'lib/textpow/syntax.rb', line 57

def patterns
  @patterns
end

#repositoryObject

Returns the value of attribute repository.



56
57
58
# File 'lib/textpow/syntax.rb', line 56

def repository
  @repository
end

#scopeNameObject

Returns the value of attribute scopeName.



51
52
53
# File 'lib/textpow/syntax.rb', line 51

def scopeName
  @scopeName
end

#syntaxObject

Returns the value of attribute syntax.



40
41
42
# File 'lib/textpow/syntax.rb', line 40

def syntax
  @syntax
end

Class Method Details

.load(file, options = {}) ⇒ Object



59
60
61
62
# File 'lib/textpow/syntax.rb', line 59

def self.load(file, options={})
  table = convert_file_to_table(file)
  SyntaxNode.new(table, options)
end

Instance Method Details

#parse(string, processor = RecordingProcessor.new) ⇒ Object



76
77
78
79
80
81
82
83
84
85
# File 'lib/textpow/syntax.rb', line 76

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

  processor
end

#syntaxesObject



72
73
74
# File 'lib/textpow/syntax.rb', line 72

def syntaxes
  @@syntaxes[@name_space]
end