struct Novika::Scissors

Overview

Scissors deal with cutting a source string into fragments, known as unclassified forms. They are then fed to an instance of Classifier, which determines whether an unclassified form is actually a decimal, quoted word, quote, etc. You can think of Scissors as a fancy split- by-whitespace.

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/scissors.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(source : String) #

Class Method Detail

def self.cut(source : String, & : Int32, Int32, Int32 | Nil -> ) #

Cuts source into a series of unclassified forms; yields start byte index and byte length of each to the block.


Instance Method Detail

def each(&) #

Cuts the source string into a series of unclassified forms; yields start byte index, byte length, and first dot '.' byte index of each to the block.

Dot byte index is yielded to save an O(N) search, which would be otherwise required since '.' is handled specially by several forms in Novika.