Module: CTokenizer::Scoped
- Included in:
- SkipMacros, DBC::Parser
- Defined in:
- lib/dbc/ctokenizer.rb
Overview
provides a way of keeping track of the current scope
Instance Attribute Summary collapse
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
179 180 181 |
# File 'lib/dbc/ctokenizer.rb', line 179 def scope @scope end |
Instance Method Details
#macro? ⇒ Boolean
185 186 187 |
# File 'lib/dbc/ctokenizer.rb', line 185 def macro? @macro end |
#process_scope(t) ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/dbc/ctokenizer.rb', line 189 def process_scope(t) case t[0] when :SPACE, :COMMENT # do nothing when :NEWLINE @start_line = true @macro = false else unless @macro # these tokens are ignored if inside of a macro case t[1] when '#' @macro = @start_line when '{' @scope += 1 when '}' @scope -= 1 end end @start_line = false end t end |
#start_of_line? ⇒ Boolean
181 182 183 |
# File 'lib/dbc/ctokenizer.rb', line 181 def start_of_line? @start_line end |