rangeutil

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2013 License: BSD-3-Clause Imports: 2 Imported by: 8

Documentation

Overview

Package rangeutil provides services for conversion and iteration of range specifications for use with iNamik/go_lexer

Currently, a 'range specifiction' is defined as a string of unicode characters, with the ability to specify a range of chararacters by using a '-' between two characters. Think of it as a simplified version of standard regex bracket expression.

Here are some examples:

Digit        "0123456789" // With no range specifiers
Digit        "0-9"        // With range specifiers
Hex Digit    "0-9a-zA-F"  // Allowing for upper and lower case
Decimal      "-.0-9"      // '-' At beginning means litteral '-'

NOTE: The current implentation of the range specification processer may allow a literal '-' anywhere that a range is not implied, but the only officially supported location for a literal '-' is at the beginning of the string.

NOTE: The full unicode character set should be supported

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IterateRangeSpec

func IterateRangeSpec(rangeSpec string, callBack RangeIteratorCallback)

IterateRangeSpec processes a range specification, calling a callback function for each rune-range encountered

func RangeToBytes

func RangeToBytes(rangeSpec string) []byte

RangeToBytes converts a range specifier into a byte array suitable for the Match*Bytes calls of iNamik/go_lexer

func RangeToRunes

func RangeToRunes(rangeSpec string) []rune

RangeToRunes converts a range specifier into a rune array suitable for the Match*Runes calls of the iNamik/go_lexer

Types

type RangeIteratorCallback

type RangeIteratorCallback func(low, hi rune) (ok bool)

RangeIteratorCallback defines the prototype for the IterateRangeSpec callback function. The function takes two rune parameters, 'low' and 'hi' (which can have the same value) and returns a boolean indicating if it is ok to continue processing the rangeSpec (true == ok, false == quit)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL