Class: RLTK::Lexer::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/rltk/lexer.rb

Overview

The Rule class is used simply for data encapsulation.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Rule) initialize(pattern, action, state, flags)

Instantiates a new Rule object.

Parameters:

  • pattern (Regexp)

    Regular expression used to match to this rule.

  • action (Proc)

    Token producing action associated with this rule.

  • state (Symbol)

    State in which this rule is active.

  • flags (Array<Symbol>)

    Flags that must be enabled for this rule to match.



364
365
366
367
368
369
# File 'lib/rltk/lexer.rb', line 364

def initialize(pattern, action, state, flags)
	@pattern	= pattern
	@action	= action
	@state	= state
	@flags	= flags
end

Instance Attribute Details

- (Proc) action (readonly)

Returns Token producting action to be taken when this rule is matched.

Returns:

  • (Proc)

    Token producting action to be taken when this rule is matched.



350
351
352
# File 'lib/rltk/lexer.rb', line 350

def action
  @action
end

- (Array<Symbol>) flags (readonly)

Returns Flags currently set in this lexing environment.

Returns:

  • (Array<Symbol>)

    Flags currently set in this lexing environment.



356
357
358
# File 'lib/rltk/lexer.rb', line 356

def flags
  @flags
end

- (Regexp) pattern (readonly)

Returns Regular expression for matching this rule.

Returns:

  • (Regexp)

    Regular expression for matching this rule.



353
354
355
# File 'lib/rltk/lexer.rb', line 353

def pattern
  @pattern
end