parse

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2015 License: MIT Imports: 4 Imported by: 0

README

Parse Build Status GoDoc GoCover

This package contains several lexers and parsers. All subpackages are built to be streaming, high performance and to be in accordance with the official (latest) specifications.

The lexers are implemented using Shifter in https://github.com/tdewolff/buffer and the parsers work on top of the lexers. Some subpackages have hashes defined (using Hasher) that speed up common byte-slice comparisons.

CSS GoDoc GoCover

This package is a CSS3 lexer and parser. Both follow the specification at CSS Syntax Module Level 3. The lexer takes an io.Reader and converts it into tokens until the EOF. The parser returns a parse tree of the full io.Reader input stream, but the low-level Next function can be used for stream parsing to returns grammar units until the EOF.

See README here.

HTML GoDoc GoCover

This package is an HTML5 lexer. It follows the specification at The HTML syntax. The lexer takes an io.Reader and converts it into tokens until the EOF.

See README here.

JS GoDoc GoCover

This package is a JS lexer (ECMA-262, edition 5.1). It follows the specification at ECMAScript Language Specification. The lexer takes an io.Reader and converts it into tokens until the EOF.

See README here.

JSON GoDoc GoCover

This package is a JSON parser (ECMA-404). It follows the specification at JSON. The parser takes an io.Reader and converts it into tokens until the EOF.

See README here.

SVG GoDoc GoCover

This package contains common hashes for SVG1.1 tags and attributes.

XML GoDoc GoCover

This package is an XML1.0 lexer. It follows the specification at Extensible Markup Language (XML) 1.0 (Fifth Edition). The lexer takes an io.Reader and converts it into tokens until the EOF.

See README here.

License

Released under the MIT license.

Documentation

Overview

Package parse contains a collection of parsers for various formats in its subpackages.

Index

Constants

This section is empty.

Variables

View Source
var ErrBadDataURI = errors.New("not a data URI")

Returned by DataURI when the byte slice does not start with 'data:' or is too short.

Functions

func Copy

func Copy(src []byte) (dst []byte)

Copy returns a copy of the given byte slice.

func DataURI

func DataURI(dataURI []byte) ([]byte, []byte, error)

DataURI parses the given data URI and returns the mediatype, data and ok.

func Dimension

func Dimension(b []byte) (int, int)

func Equal

func Equal(s, target []byte) bool

Equal returns true when s matches the target.

func EqualFold

func EqualFold(s, targetLower []byte) bool

EqualFold returns true when s matches case-insensitively the targetLower (which must be lowercase).

func Int

func Int(b []byte) (int64, bool)

Int parses a byte-slice and returns the integer it represents

func IsAllWhitespace

func IsAllWhitespace(b []byte) bool

IsAllWhitespace returns true when the entire byte slice consists of space, \n, \t, \f, \r.

func IsWhitespace

func IsWhitespace(c byte) bool

IsWhitespace returns true for space, \n, \t, \f, \r.

func Number

func Number(b []byte) int

Number returns the number of bytes that parse as a number of the regex format (+|-)?([0-9]+(\.[0-9]+)?|\.[0-9]+)((e|E)(+|-)?[0-9]+)?.

func QuoteEntity

func QuoteEntity(b []byte) (quote byte, n int)

QuoteEntity parses the given byte slice and returns the quote that got matched (' or "), its entity length and ok.

func ReplaceMultiple

func ReplaceMultiple(b []byte, f func(byte) bool, r byte) []byte

ReplaceMultiple replaces any character serie for which the function return true into a single character given by r.

func ToLower

func ToLower(src []byte) []byte

ToLower converts all characters in the byte slice from A-Z to a-z.

func Trim

func Trim(b []byte, f func(byte) bool) []byte

Trim removes any character from the start and end for which the function returns true.

Types

This section is empty.

Directories

Path Synopsis
Package css is a CSS3 lexer and parser following the specifications at http://www.w3.org/TR/css-syntax-3/.
Package css is a CSS3 lexer and parser following the specifications at http://www.w3.org/TR/css-syntax-3/.
Package html is an HTML5 lexer following the specifications at http://www.w3.org/TR/html5/syntax.html.
Package html is an HTML5 lexer following the specifications at http://www.w3.org/TR/html5/syntax.html.
Package js is an ECMAScript5.1 lexer following the specifications at http://www.ecma-international.org/ecma-262/5.1/.
Package js is an ECMAScript5.1 lexer following the specifications at http://www.ecma-international.org/ecma-262/5.1/.
Package jsom is a JSON parser following the specifications at http://json.org/.
Package jsom is a JSON parser following the specifications at http://json.org/.
Package xml is an XML1.0 lexer following the specifications at http://www.w3.org/TR/xml/.
Package xml is an XML1.0 lexer following the specifications at http://www.w3.org/TR/xml/.

Jump to

Keyboard shortcuts

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