parser

package
v0.0.0-...-06b8323 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2017 License: LGPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ILLEGAL token = iota

	IDENT // main
	ARG   // arg[0-5]
	INT   // 12345, 0b01010, 0xFFF, 0777

	ADD // +
	SUB // -
	MUL // *
	DIV // /
	MOD // %

	AND // &
	OR  // |
	XOR // ^
	LSH // <<
	RSH // >>
	INV // ~

	LAND // &&
	LOR  // ||

	EQL // ==
	LT  // <
	GT  // >
	NOT // !

	NEQ    // !=
	LTE    // <=
	GTE    // >=
	BITSET // &?

	LPAREN // (
	LBRACK // [
	COMMA  // ,

	RPAREN // )
	RBRACK // ]

	TRUE  // true
	FALSE // false

	IN    // in
	NOTIN //notin

	EOF
)

These define all legal token types

Variables

This section is empty.

Functions

func Parse

func Parse(s Source) (tree.RawPolicy, error)

Parse will parse the given Source and return a raw parse tree or the error generated

func ParseFile

func ParseFile(path string) (tree.RawPolicy, error)

ParseFile will parse the given file and return a raw parse tree or the error generated This function is deprecated and shouldn't be used in new code

func ParseString

func ParseString(str string) (tree.RawPolicy, error)

ParseString will parse the given string and return a raw parse tree or the error generated This function is deprecated and shouldn't be used in new code

Types

type CombinedSource

type CombinedSource struct {
	// Sources is a list of the sources to parse
	Sources []Source
}

CombinedSource allow you to combine more than one source and have them parsed as a unit

func CombineSources

func CombineSources(s ...Source) *CombinedSource

CombineSources returns a CombinedSource with all the given sources

func (*CombinedSource) Parse

func (s *CombinedSource) Parse() (tree.RawPolicy, error)

Parse implements the Source interface by parsing each one of the sources

type FileSource

type FileSource struct {
	// Filename is the name of the file to parse definitions from
	Filename string
}

FileSource represents the source of parsing coming from a file

func (*FileSource) Parse

func (s *FileSource) Parse() (tree.RawPolicy, error)

Parse implements the Source interface by parsing the file

type LineType

type LineType int

LineType represents the different types of lines available in a policy file

type ParseError

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

ParseError represents error parsing a policy file. It will report the filename and the line number as well as the actual error.

func (*ParseError) Error

func (e *ParseError) Error() string

type Source

type Source interface {
	Parse() (tree.RawPolicy, error)
}

Source represents a source of parsing data

type StringSource

type StringSource struct {
	// Name is the name to report for this string during parsing errors
	Name string
	// Content is the actual string containing definitions
	Content string
}

StringSource contains the definitions as a string

func (*StringSource) Parse

func (s *StringSource) Parse() (tree.RawPolicy, error)

Parse implements the Source interface by parsing the string

Jump to

Keyboard shortcuts

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