struct Novika::Classifier

Overview

Classifier brings unclassified forms to life.

Classifier assigns types to fragments of Novika code conveniently called unclassified forms: this unclassified form is a decimal, this one is a word, that one is a quote.

Unclassified forms are given to Classifier by Scissors, an object dedicated to cutting a big blob of Novika code into smaller fragments.

Scissors and Classifier are designed to work in tandem. Separating one from the other is possible and will work, but is not recommended unless you have read the source code of both.

Defined in:

novika/classifier.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(source : String, block : Novika::Block) #

Initializes a classifier from the given source string and Novika block.

block is treated as the ceiling (toplevel) block for source, meaning you can't close it in source, and it doesn't need to be open.


Instance Method Detail

def block : Novika::Block #

Returns the block used by this classifier.


def bytes : Pointer(UInt8) #

Returns the source code byte pointer used by this classifier.


def classify(start, count, dot) : Nil #

Classifies the subrange starting at byte index start, and count bytes long. dot is the byte index of '.'.

These three arguments are assumed to come from Scissors#cut.

This method does practically no bounds checks, is unsafe and must be worked with carefully.


def classify(start, count) #

Classifies the subrange starting at byte index start, and count bytes long.


def end #

Ends classification. Makes sure all blocks are closed (have their corresponding ]).