package
module
Version:
v0.0.0-...-507a558
Opens a new window with list of versions in this module.
Published: Oct 6, 2021
License: LGPL-2.1
Opens a new window with license information.
Imports: 7
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
shred
A shift-reduce parser in Go
Documentation
¶
type Grammar struct {
Rules []*Rule
}
An attribute LR-grammar.
NewGrammar creates a new grammar with the given rules.
Build builds an automaton for the grammar.
Parse parses a sequence of tokens.
Kind is a token's type.
const (
KindIdent Kind = iota
KindInt
KindFloat
KindString
KindRawString
KindChar
KindEOF
KindOther
KindMatch
)
type Match struct {
Text string
}
A match terminal.
type NonTerminal struct {
Name string
}
NonTerminal is a non-terminal symbol.
String returns the name of the non-terminal.
type Rule struct {
Lhs string
Rhs []Symbol
Builder func([]interface{}) interface{}
}
A context-free rule with an assiciated AST builder.
Symbol is a terminal or non-terminal.
Terminal is a terminal symbol.
Token is a text token.
Tokenise tokenises the contents of a reader.
TokeniseString tokenises a string.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.