Class: Dhaka::LexerSupport::DFARun

### Home Classes Methods

### In Files

- lib/dhaka/lexer/dfa.rb

### Parent

Object

### Methods

- ::new
- #accept
- #accept_last_saved_checkpoint
- #match
- #save_checkpoint

### Class/Module Index

Quicksearch

- Dhaka
- Dhaka::CompiledLexer
- Dhaka::CompiledParser
- Dhaka::Evaluator
- Dhaka::Grammar
- Dhaka::GrammarSymbol
- Dhaka::Lexeme
- Dhaka::Lexer
- Dhaka::LexerRun
- Dhaka::LexerSpecification
- Dhaka::LexerSupport
- Dhaka::LexerSupport::AcceptAction
- Dhaka::LexerSupport::CheckpointAction
- Dhaka::LexerSupport::DFARun
- Dhaka::LexerSupport::InvalidRegexException
- Dhaka::LexerSupport::LookaheadAcceptAction
- Dhaka::LexerSupport::RegexParser
- Dhaka::LexerSupport::RegexTokenizer
- Dhaka::LexerSupport::State
- Dhaka::LexerSupport::StateMachine
- Dhaka::NoStartProductionsError
- Dhaka::ParseErrorResult
- Dhaka::ParseSuccessResult
- Dhaka::ParseTreeCompositeNode
- Dhaka::ParseTreeLeafNode
- Dhaka::Parser
- Dhaka::ParserMethods
- Dhaka::PrecedenceBuilder
- Dhaka::Production
- Dhaka::ProductionBuilder
- Dhaka::Token
- Dhaka::Tokenizer
- Dhaka::TokenizerErrorResult
- Dhaka::TokenizerState
- Dhaka::TokenizerSuccessResult

No matching classes.

# Dhaka::LexerSupport::DFARun

### Public Class Methods

new(dfa, input) click to toggle source

    # File lib/dhaka/lexer/dfa.rb, line 89
    def initialize(dfa, input)
      @dfa, @input = dfa, input
      @matched = ""
      @not_yet_accepted = ""
      @curr_state = @dfa.start_state
    end

### Public Instance Methods

accept(pattern) click to toggle source

    # File lib/dhaka/lexer/dfa.rb, line 110
    def accept(pattern)
      @matched.concat @not_yet_accepted
      @not_yet_accepted = ""
    end

accept_last_saved_checkpoint(pattern) click to toggle source

    # File lib/dhaka/lexer/dfa.rb, line 115
    def accept_last_saved_checkpoint(pattern)
      @matched = @last_saved_checkpoint
      @not_yet_accepted = ""
    end

match() click to toggle source

    # File lib/dhaka/lexer/dfa.rb, line 96
    def match
      @input.unpack("C*").each do |i|
        break unless dest_state = @curr_state.transitions[i.chr]
        @not_yet_accepted << i.chr
        @curr_state = dest_state
        @curr_state.process(self)
      end
      @matched
    end

save_checkpoint(pattern) click to toggle source

    # File lib/dhaka/lexer/dfa.rb, line 106
    def save_checkpoint(pattern)
      @last_saved_checkpoint = @matched + @not_yet_accepted
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.