Class: VER::Syntax::Processor
- Inherits:
-
VER::Struct
- Object
- Struct
- VER::Struct
- VER::Syntax::Processor
- Defined in:
- lib/ver/syntax/processor.rb
Constant Summary
Constants inherited from VER::Struct
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
Methods inherited from VER::Struct
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
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ver/syntax/processor.rb', line 40 def close_tag(name, mark) from_name, from_lineno, pos = stack.pop [name] << "#{from_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 conpatterns. # We swallow that exception to avoid confusion. raise exception unless exception..empty? end |
#end_parsing(syntax_name) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ver/syntax/processor.rb', line 11 def end_parsing(syntax_name) .each do |name, indices| tag_name = theme.get(name) || name textarea.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
23 24 25 |
# File 'lib/ver/syntax/processor.rb', line 23 def new_line(line) self.lineno += 1 end |
#open_tag(name, pos) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ver/syntax/processor.rb', line 27 def open_tag(name, pos) stack << [name, lineno, 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 9 |
# File 'lib/ver/syntax/processor.rb', line 4 def start_parsing(syntax_name) self.stack = [] self. = Hash.new{|h,k| h[k] = [] } @tag_stack = [] [syntax_name] << "1.0" << "end" end |