class Crodoc::Tokenizer

Overview

Represents a Crystal syntaxt tokenizer based on Crystal::Lexer.

Example:

source = Crodoc::Source.new(code, path)
tokenizer = Crodoc::Tokenizer.new(source)
tokenizer.run do |token|
  puts token
end

Defined in:

crodoc/tokenizer.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(source : Source) #

Instantiates a Tokenizer using source.

Example:

source = Crodoc::Source.new(code, path)
Crodoc::Tokenizer.new(source)

[View source]
def self.new(lexer : Crystal::Lexer) #

Instantiates a Tokenizer using a Crystal::Lexer.

Example:

lexer = Crystal::Lexer.new(code)
Crodoc::Tokenizer.new(lexer)

[View source]

Instance Method Detail

def run(&block : Crystal::Token -> ) #

Runs the tokenizer and yields each token as a block argument.

Example:

Crodoc::Tokenizer.new(source).run do |token|
  puts token
end

[View source]