Class: RLTK::Lexer::Rule

Inherits:
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

#initialize(pattern, action, state, flags) ⇒ Rule

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.



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

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

Instance Attribute Details

#actionProc (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.



340
341
342
# File 'lib/rltk/lexer.rb', line 340

def action
  @action
end

#flagsArray<Symbol> (readonly)

Returns Flags currently set in this lexing environment.

Returns:

  • (Array<Symbol>)

    Flags currently set in this lexing environment.



346
347
348
# File 'lib/rltk/lexer.rb', line 346

def flags
  @flags
end

#patternRegexp (readonly)

Returns Regular expression for matching this rule.

Returns:

  • (Regexp)

    Regular expression for matching this rule.



343
344
345
# File 'lib/rltk/lexer.rb', line 343

def pattern
  @pattern
end