ragel

package module
v0.0.0-...-a540c87 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2015 License: BSD-3-Clause Imports: 3 Imported by: 0

README

bíogo

#RAGEL

Build Status

##Installation

    $ go get github.com/biogo/ragel/...

##Overview

The ragel package provide utility functions for using ragel FSM parsers.

Citing

If you use bíogo, please cite Kortschak and Adelson "bíogo: a simple high-performance bioinformatics toolkit for the Go language", doi:10.1101/005033.

##Library Structure and Coding Style

The coding style should be aligned with normal Go idioms as represented in the Go core libraries.

##Copyright and License

Copyright ©2011-2013 The bíogo Authors except where otherwise noted. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

The bíogo logo is derived from Bitstream Charter, Copyright ©1989-1992 Bitstream Inc., Cambridge, MA.

BITSTREAM CHARTER is a registered trademark of Bitstream Inc.

Documentation

Overview

Package ragel provides helper functions and types for building ragel-based parsers.

The ragel state machine compiler is available from http://www.complang.org/ragel/.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilData    = errors.New("ragel: nil value for expected ragel variable")
	ErrBufferFull = errors.New("ragel: buffer full")
	ErrNotFound   = errors.New("ragel: not found")
)

Functions

This section is empty.

Types

type AppendReader

type AppendReader struct {
	// contains filtered or unexported fields
}

AppendReader implements reading arbitrarily sized, byte delimited data into a slice and updating ragel state machine variables.

func NewAppendReader

func NewAppendReader(r *bufio.Reader, p, pe, eof *int, data *[]byte, delim byte) (*AppendReader, error)

NewAppendReader returns a new AppenReader that reads from r. Pointers to the ragel state machine variables p, pe, eof and data slice must be provided. These variables are updated on each read. An error is returned if a pointer to any of the required ragel variables is nil.

func (*AppendReader) BackupTo

func (r *AppendReader) BackupTo(b byte) error

BackupTo scans backwards from the position pe in the data variable to the first instance of b, setting pe to the next position from the found byte. ErrNotFound is returned and pe is not updated if b is not found.

func (*AppendReader) Buffered

func (r *AppendReader) Buffered() int

Buffered returns the number of bytes that can be processed in the current block.

func (*AppendReader) Read

func (r *AppendReader) Read() (n int, err error)

Read reads data from the underlying reader until the the first instant of the AppendReader's delim byte growing the data slice as necessary, but first moving read but unprocessed data to the start of the data slice if the p ragel variable has passed len(data)/2. Read returns the number of bytes read and any error encountered during the read. io.ErrUnexpectedEOF is returned if data does not end in the specified delimeter. Read sets the ragel eof variable to the value of pe if the read returns an io.EOF or io.ErrUnexpectedEOF error.

type AppendScanner

type AppendScanner struct {
	// contains filtered or unexported fields
}

AppendScanner implements reading arbitrarily sized, byte delimited data into a slice and updating ragel state machine variables.

func NewAppendScanner

func NewAppendScanner(r *bufio.Reader, p, pe, ts, te, eof *int, data *[]byte, delim byte) (*AppendScanner, error)

NewAppendScanner returns a new AppenReader that reads from r. Pointers to the ragel state machine variables p, pe, ts, te, eof and data must be provided. These variables are updated on each read. An error is returned if a pointer to any of the required ragel variables is nil.

func (*AppendScanner) Buffered

func (r *AppendScanner) Buffered() int

Buffered returns the number of bytes that can be processed in the current block.

func (*AppendScanner) Read

func (r *AppendScanner) Read() (n int, err error)

Read reads data from the underlying reader until the the first instant of the AppendScanner's delim byte growing the data slice as necessary, but first moving read unprocessed data to the start of the data array if the ts ragel variable is non-zero. Read returns the number of bytes read and any error encountered during the read. io.ErrUnexpectedEOF is returned if data does not end in the specified delimeter. Read sets the ragel eof variable to the value of pe if the read returns an io.EOF or io.ErrUnexpectedEOF error.

type BlockReader

type BlockReader struct {
	// contains filtered or unexported fields
}

BlockReader implements reading defined block size data into a provided slice and updating ragel state machine variables.

func NewBlockReader

func NewBlockReader(r io.Reader, p, pe, eof *int, data []byte) (*BlockReader, error)

NewBlockReader returns a new BlockReader that reads from r. Pointers to the ragel state machine variables p, pe and eof, and a data slice must be provided. These variables are updated on each read. An error is returned if a pointer to any of the required ragel variables is nil.

func (*BlockReader) BackupTo

func (r *BlockReader) BackupTo(b byte) error

BackupTo scans backwards from the position pe in the data variable to the first instance of b, setting pe to the next position from the found byte. ErrNotFound is returned and pe is not updated if b is not found.

func (*BlockReader) Buffered

func (r *BlockReader) Buffered() int

Buffered returns the number of bytes that can be processed in the current block.

func (*BlockReader) Read

func (r *BlockReader) Read() (n int, err error)

Read reads data from the underlying reader until the ragel data variable is full, first moving read but unprocessed data to the start of the data slice if the p ragel variable has passed len(data)/2. Read returns the number of bytes read and any error encountered during the read. ErrBufferFull is returned if the data variable is full prior to reading and after any potential data shift. Read sets the ragel eof variable to the value of pe if the read returns an io.EOF error.

type BlockScanner

type BlockScanner struct {
	// contains filtered or unexported fields
}

BlockScanner implements reading defined block size data into a provided slice and updating ragel state machine variables.

func NewBlockScanner

func NewBlockScanner(r io.Reader, p, pe, ts, te, eof *int, data []byte) (*BlockScanner, error)

NewBlockScanner returns a new BlockScanner that reads from r. Pointers to the ragel state machine variables p, pe, ts, te and eof, and a data slice must be provided. These variables are updated on each read. An error is returned if a pointer to any of the required ragel variables is nil.

func (*BlockScanner) Buffered

func (r *BlockScanner) Buffered() int

Buffered returns the number of bytes that can be processed in the current block.

func (*BlockScanner) Read

func (r *BlockScanner) Read() (n int, err error)

Read reads data from the underlying reader until the ragel data variable is full, first moving read but unprocessed data to the start of the data array if the ts ragel variable is non-zero. Read returns the number of bytes read and any error encountered during the read. ErrBufferFull is returned if the data variable is full prior to reading and after any potential data shift. Read sets the ragel eof variable to the value of pe if the read returns an io.EOF error.

Jump to

Keyboard shortcuts

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