Class: SublimeDSL::TextMate::Grammar::RuleBuilder::BeginEndState
- Inherits:
-
State
- Object
- State
- SublimeDSL::TextMate::Grammar::RuleBuilder::BeginEndState
show all
- Defined in:
- lib/sublime_dsl/textmate/grammar/dsl_reader.rb
Instance Attribute Summary
Attributes inherited from State
#builder, #comment, #disabled, #scope
Instance Method Summary
collapse
Methods inherited from State
#patterns
Constructor Details
Returns a new instance of BeginEndState.
328
329
330
331
332
333
334
|
# File 'lib/sublime_dsl/textmate/grammar/dsl_reader.rb', line 328
def initialize(builder)
super builder
@from = @to = nil
@both = {}
@content_scope = nil
@to_last = nil
end
|
Instance Method Details
#both(captures) ⇒ Object
352
353
354
355
|
# File 'lib/sublime_dsl/textmate/grammar/dsl_reader.rb', line 352
def both(captures)
@both.empty? or raise Error, "'both' already specified"
@both.merge! captures
end
|
#content_scope=(scope) ⇒ Object
357
358
359
|
# File 'lib/sublime_dsl/textmate/grammar/dsl_reader.rb', line 357
def content_scope=(scope)
@content_scope = scope
end
|
#from(re, captures) ⇒ Object
340
341
342
343
344
|
# File 'lib/sublime_dsl/textmate/grammar/dsl_reader.rb', line 340
def from(re, captures)
@from and raise Error, "'from' called twice"
@from = Match.new(Tools::RegexpWannabe.new(re.source))
@from.captures.merge! captures
end
|
#match(re, captures) ⇒ Object
336
337
338
|
# File 'lib/sublime_dsl/textmate/grammar/dsl_reader.rb', line 336
def match(re, captures)
raise Error, "'match' is invalid with 'from' or 'to'"
end
|
#rule ⇒ Object
365
366
367
368
369
370
371
372
373
374
375
|
# File 'lib/sublime_dsl/textmate/grammar/dsl_reader.rb', line 365
def rule
r = BeginEndRule.new
init r
r.content_scope = @content_scope
r.from = @from
r.to = @to
r.to_last = @to_last
r.captures.merge! @both
r.patterns.concat @patterns
r
end
|
#to(re, captures) ⇒ Object
346
347
348
349
350
|
# File 'lib/sublime_dsl/textmate/grammar/dsl_reader.rb', line 346
def to(re, captures)
@to and raise Error, "'to' called twice"
@to = Match.new(Tools::RegexpWannabe.new(re.source, @from))
@to.captures.merge! captures
end
|
#to_last=(value) ⇒ Object
361
362
363
|
# File 'lib/sublime_dsl/textmate/grammar/dsl_reader.rb', line 361
def to_last=(value)
@to_last = value
end
|