Class: Rouge::RegexLexer::StateDSL
- Inherits:
-
Object
- Object
- Rouge::RegexLexer::StateDSL
- Defined in:
- lib/rouge/lexer.rb
Instance Attribute Summary collapse
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Instance Method Summary collapse
-
#initialize(rules) ⇒ StateDSL
constructor
A new instance of StateDSL.
- #mixin(lexer_name) ⇒ Object
- #rule(re, tok = nil, next_state = nil, &callback) ⇒ Object
Constructor Details
#initialize(rules) ⇒ StateDSL
Returns a new instance of StateDSL.
264 265 266 |
# File 'lib/rouge/lexer.rb', line 264 def initialize(rules) @rules = rules end |
Instance Attribute Details
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
263 264 265 |
# File 'lib/rouge/lexer.rb', line 263 def rules @rules end |
Instance Method Details
#mixin(lexer_name) ⇒ Object
288 289 290 |
# File 'lib/rouge/lexer.rb', line 288 def mixin(lexer_name) rules << lexer_name.to_s end |
#rule(re, tok = nil, next_state = nil, &callback) ⇒ Object
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
# File 'lib/rouge/lexer.rb', line 268 def rule(re, tok=nil, next_state=nil, &callback) if block_given? next_state = tok else tok = Token[tok] callback = proc do |ss| token tok, ss[0] case next_state when :pop! pop! when Symbol push next_state end # else pass end end rules << Rule.new(re, callback, next_state) end |