johaus: Index | Files | Directories

package parser

import ""

Package parser contains the interface for using parsers for all supported Lojban dialects.


Package Files

dialect.go error.go loc.go parser.go simplify.go walk.go


const SpaceChars = ".\t\n\r?!\x20"

SpaceChars is the string of all whitespace characters.

func AddElidedTerminators Uses

func AddElidedTerminators(n *peg.Node)

AddElidedTerminators sets the Text of an elided terminator node to the terminator name in all caps. This flags any functions removing empty Nodes to keep the elided terminator Node, as its Text is no longer empty.

func CollapseLists Uses

func CollapseLists(n *peg.Node)

CollapseLists collapses chains of single-kid nodes.

func Locations Uses

func Locations(text string, n *peg.Fail) map[*peg.Fail]Loc

Locations returns a mapping from nodes to their Locs.

func Parse Uses

func Parse(dialect string, text string) (*peg.Node, error)

Parse parses text using a given Lojban dialect. On success, the parseTree is returned. On failure, both the word-level and the raw, morphological errors are returned.

func Register Uses

func Register(d Dialect, makeParser func(string) Parser)

Register registers a dialect.

func RemoveMorphology Uses

func RemoveMorphology(n *peg.Node)

RemoveMorphology removes all nodes beneath whole words.

func RemoveSpace Uses

func RemoveSpace(n *peg.Node)

RemoveSpace removes whitespace-only nodes.

type Dialect Uses

type Dialect struct {
    // Name is the name of the dialect.
    Name string

    // Version is the version of the dialect's grammar.
    Version string

    // Descr is a map from language codes
    // to text describing the dialect
    // in the corresponding language.
    Descr map[string]string

    // OfficialURL is the official URL for the parser's homepage.
    OfficialURL string

    // GrammarURL is the URL of the grammar file.
    GrammarURL string

A Dialect describes a dialect of the Lojban language.

func Dialects Uses

func Dialects() []Dialect

Dialects returns all registered dialects in lexical order by name.

type Error Uses

type Error struct {
    FilePath string
    Want     []string

A Error represents an error at some location in the input text.

func (Error) Error Uses

func (err Error) Error() string

type Loc Uses

type Loc struct {
    Byte   int
    Rune   int
    Line   int
    Column int

A Loc is a location in the input text.

func Location Uses

func Location(text string, byte int) Loc

Location returns the Loc at the corresponding byte offset in the text.

type Parser Uses

type Parser interface {
    // Parse parses the text and returns
    // the maximum error position seen during the parse
    // and whether the parse succeeded.
    Parse() (int, bool)

    // ErrorTree returns the parse error tree for a failed parse.
    // The tree contains all errors at or beyond minErrorPos.
    ErrorTree(minErrorPos int) *peg.Fail

    // ParseTree returns the parse tree for a successful parse.
    ParseTree() *peg.Node

Parser is a low-level interface to a Lojban parser.


alldialectsPackage alldialects can be imported to register all supported Lojban dialects.
camxesPackage camxes is the camxes implementation of the official Lojban grammar.
camxes-betaPackage camxes is the camxes implementation of the official Lojban grammar.
ilmentufaPackage ilmentufa is the ilmentufa dialect of Lojban.
maftufaPackage maftufa is the maftufa dialect of Lojban grammar.
zantufaPackage zantufa is the zantufa dialect of Lojban.

Package parser imports 7 packages (graph) and is imported by 18 packages. Updated 2019-06-03. Refresh now. Tools for package owners.