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.
338 339 340 |
# File 'lib/rouge/lexer.rb', line 338 def initialize(rules) @rules = rules end |
Instance Attribute Details
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
337 338 339 |
# File 'lib/rouge/lexer.rb', line 337 def rules @rules end |
Instance Method Details
#mixin(lexer_name) ⇒ Object
362 363 364 |
# File 'lib/rouge/lexer.rb', line 362 def mixin(lexer_name) rules << lexer_name.to_s end |
#rule(re, tok = nil, next_state = nil, &callback) ⇒ Object
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
# File 'lib/rouge/lexer.rb', line 342 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 |