rivescript-go: github.com/aichaos/rivescript-go/parser Index | Files

package parser

import "github.com/aichaos/rivescript-go/parser"

Package parser is a RiveScript language parser.

This package can be used as a stand-alone parser for third party developers to use, if you want to be able to simply parse (and syntax check!) RiveScript source code and get an "abstract syntax tree" back from it.

Index

Package Files

parser.go

Constants

const RS_VERSION float64 = 2.0

type Parser Uses

type Parser struct {
    C ParserConfig
}

func New Uses

func New(config ParserConfig) *Parser

New creates and returns a new instance of a RiveScript Parser.

func (*Parser) Parse Uses

func (self *Parser) Parse(filename string, code []string) (*ast.Root, error)

Parse reads and parses RiveScript source code.

This will return an AST Root object containing all of the relevant information parsed from the source code.

In case of errors (e.g. a syntax error while Strict Mode is enabled) will return a nil AST root and an error object.

Parameters

filename: An arbitrary name for the source code being parsed. It will be
	used when reporting warnings from this package.
code: An array of lines of RiveScript source code.

type ParserConfig Uses

type ParserConfig struct {
    Strict bool // Strict syntax checking enable (true by default)
    UTF8   bool // Enable UTF-8 mode (false by default)

    // Optional handlers for the caller to get debug information out.
    OnDebug func(message string, a ...interface{})
    OnWarn  func(message, filename string, lineno int, a ...interface{})
}

ParserConfig configures the parser.

Configuration Options

Strict: Enable strict syntax checking. Syntax errors will be considered
	fatal and abandon the parsing process.
UTF8: Enable UTF-8 mode. When enabled, this allows triggers to contain
	foreign symbols without raising a syntax error.
OnDebug: A function handler for receiving debug information from this
	package, if you want that information.
OnWarn: A function handler for receiving warnings (non-fatal errors) from
	this package.

All options have meaningful zero values.

Package parser imports 4 packages (graph) and is imported by 1 packages. Updated 2017-02-14. Refresh now. Tools for package owners.