Sha256: ac9eab4003a55df25458baf5fb74f66749d4a9e8a1c9696691efa8827e79cba6

Contents?: true

Size: 846 Bytes

Versions: 1

Compression:

Stored size: 846 Bytes

Contents

%%{
  machine puffer_lexer;

  variable data @data;
  variable te @te;
  variable ts @ts;
  variable p @p;

  action RegexpCheck {
    if (!regexp_possible)
      emit_operator;
      fgoto expression;
    end
  }

  include "lexer.rl";
}%%

Hotcell::Lexer.class_eval do
  def current_position
    @ts
  end

  def current_value
    @data[@ts...@te].pack(Hotcell::Source::PACK_MODE).force_encoding(@source.encoding)
  end

  def current_error
    value = @data[@ts..@p].pack(Hotcell::Source::PACK_MODE).force_encoding(@source.encoding)
    [value, *@source.info(@ts).values_at(:line, :column)]
  end

  def tokenize
    %% write data;
    #%

    @data = @source.data
    @token_array = []

    %% write init;
    #%

    eof = pe
    stack = []

    %% write exec;
    #%

    raise_unexpected_symbol unless @ts.nil?

    @token_array
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hotcell-0.2.0 lib/hotcell/lexerr.rl