Class: VER::Syntax::Processor
- Inherits:
-
Struct
- Object
- Struct
- VER::Syntax::Processor
- Defined in:
- lib/ver/syntax/processor.rb
Instance Attribute Summary collapse
-
#lineno ⇒ Object
Returns the value of attribute lineno.
-
#stack ⇒ Object
Returns the value of attribute stack.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#textarea ⇒ Object
Returns the value of attribute textarea.
-
#theme ⇒ Object
Returns the value of attribute theme.
Instance Method Summary collapse
- #close_tag(name, mark) ⇒ Object
- #end_parsing(syntax_name) ⇒ Object
- #new_line(line) ⇒ Object
- #open_tag(name, pos) ⇒ Object
- #start_parsing(syntax_name) ⇒ Object
Instance Attribute Details
#lineno ⇒ Object
Returns the value of attribute lineno
3 4 5 |
# File 'lib/ver/syntax/processor.rb', line 3 def lineno @lineno end |
#stack ⇒ Object
Returns the value of attribute stack
3 4 5 |
# File 'lib/ver/syntax/processor.rb', line 3 def stack @stack end |
#tags ⇒ Object
Returns the value of attribute tags
3 4 5 |
# File 'lib/ver/syntax/processor.rb', line 3 def @tags end |
#textarea ⇒ Object
Returns the value of attribute textarea
3 4 5 |
# File 'lib/ver/syntax/processor.rb', line 3 def textarea @textarea end |
#theme ⇒ Object
Returns the value of attribute theme
3 4 5 |
# File 'lib/ver/syntax/processor.rb', line 3 def theme @theme end |
Instance Method Details
#close_tag(name, mark) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ver/syntax/processor.rb', line 39 def close_tag(name, mark) sname, pos = stack.pop [name] << "#{lineno}.#{pos}" << "#{lineno}.#{mark}" rescue RuntimeError => exception # if you modify near the end of the textarea, sometimes the last tag # cannot be closed because the contents of the textarea changed since # the last highlight was issued. # this will cause Tk to raise an error that doesn't have a message and # is of no major consequences. # We swallow that exception to avoid confusion. raise exception unless exception..empty? end |
#end_parsing(syntax_name) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ver/syntax/processor.rb', line 10 def end_parsing(syntax_name) .each do |name, indices| tag_name = theme.get(name) || name textarea.fast_tag_add(tag_name, *indices) end @tag_stack.uniq! @tag_stack.each_cons(2){|under, over| textarea.tag_raise(under, over) } stack.clear end |
#new_line(line) ⇒ Object
22 23 24 |
# File 'lib/ver/syntax/processor.rb', line 22 def new_line(line) self.lineno += 1 end |
#open_tag(name, pos) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ver/syntax/processor.rb', line 26 def open_tag(name, pos) stack << [name, pos] if tag_name = theme.get(name) if stack.size > 1 below_name = stack[-2][0] below = theme.get(below_name) return if !below || below.empty? @tag_stack << tag_name << below end end end |
#start_parsing(syntax_name) ⇒ Object
4 5 6 7 8 |
# File 'lib/ver/syntax/processor.rb', line 4 def start_parsing(syntax_name) self.stack = [] self. = Hash.new{|h,k| h[k] = [] } @tag_stack = [] end |