Documentation ¶
Index ¶
- Constants
- func Join(s []string) string
- type LexerState
- type Token
- type TokenSlice
- func (t TokenSlice) CurrentPipeline() TokenSlice
- func (t TokenSlice) CurrentToken() (token Token)
- func (t TokenSlice) FilterRedirects() TokenSlice
- func (t TokenSlice) Pipelines() []TokenSlice
- func (t TokenSlice) Strings() []string
- func (t TokenSlice) WordbreakPrefix() string
- func (t TokenSlice) Words() TokenSlice
- type TokenType
- type WordbreakType
Constants ¶
View Source
const BASH_WORDBREAKS = " \t\r\n" + `"'><=;|&(:`
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LexerState ¶
type LexerState int
the internal state used by the lexer state machine
const ( START_STATE LexerState = iota // no runes have been seen IN_WORD_STATE // processing regular runes in a word ESCAPING_STATE // we have just consumed an escape rune; the next rune is literal ESCAPING_QUOTED_STATE // we have just consumed an escape rune within a quoted string QUOTING_ESCAPING_STATE // we are within a quoted string that supports escaping ("...") QUOTING_STATE // we are within a string that does not support escaping ('...') COMMENT_STATE // we are within a comment (everything following an unquoted or unescaped # WORDBREAK_STATE // we have just consumed a wordbreak rune )
Lexer state machine states
func (LexerState) MarshalJSON ¶
func (l LexerState) MarshalJSON() ([]byte, error)
type Token ¶
type Token struct { Type TokenType Value string RawValue string Index int State LexerState WordbreakType WordbreakType `json:",omitempty"` WordbreakIndex int // index of last opening quote in Value (only correct when in quoting state) }
Token is a (type, value) pair representing a lexographical token.
type TokenSlice ¶ added in v0.0.3
type TokenSlice []Token
func (TokenSlice) CurrentPipeline ¶ added in v0.0.3
func (t TokenSlice) CurrentPipeline() TokenSlice
func (TokenSlice) CurrentToken ¶ added in v0.0.3
func (t TokenSlice) CurrentToken() (token Token)
func (TokenSlice) FilterRedirects ¶ added in v0.0.3
func (t TokenSlice) FilterRedirects() TokenSlice
func (TokenSlice) Pipelines ¶ added in v0.0.3
func (t TokenSlice) Pipelines() []TokenSlice
func (TokenSlice) Strings ¶ added in v0.0.3
func (t TokenSlice) Strings() []string
func (TokenSlice) WordbreakPrefix ¶ added in v0.0.4
func (t TokenSlice) WordbreakPrefix() string
func (TokenSlice) Words ¶ added in v0.0.3
func (t TokenSlice) Words() TokenSlice
type TokenType ¶
type TokenType int
TokenType is a top-level token classification: A word, space, comment, unknown.
Classes of lexographic token
func (TokenType) MarshalJSON ¶
type WordbreakType ¶ added in v0.0.3
type WordbreakType int
const ( WORDBREAK_UNKNOWN WordbreakType = iota // https://www.gnu.org/software/bash/manual/html_node/Redirections.html WORDBREAK_REDIRECT_INPUT WORDBREAK_REDIRECT_OUTPUT WORDBREAK_REDIRECT_OUTPUT_APPEND WORDBREAK_REDIRECT_OUTPUT_BOTH WORDBREAK_REDIRECT_OUTPUT_BOTH_APPEND WORDBREAK_REDIRECT_INPUT_STRING WORDBREAK_REDIRECT_INPUT_DUPLICATE WORDBREAK_REDIRECT_INPUT_OUTPUT // https://www.gnu.org/software/bash/manual/html_node/Pipelines.html WORDBREAK_PIPE WORDBREAK_PIPE_WITH_STDERR // https://www.gnu.org/software/bash/manual/html_node/Lists.html) WORDBREAK_LIST_ASYNC WORDBREAK_LIST_SEQUENTIAL WORDBREAK_LIST_AND WORDBREAK_LIST_OR // COMP_WORDBREAKS WORDBREAK_CUSTOM )
func (WordbreakType) IsPipelineDelimiter ¶ added in v0.0.3
func (w WordbreakType) IsPipelineDelimiter() bool
func (WordbreakType) IsRedirect ¶ added in v0.0.3
func (w WordbreakType) IsRedirect() bool
func (WordbreakType) MarshalJSON ¶ added in v0.0.3
func (w WordbreakType) MarshalJSON() ([]byte, error)
Click to show internal directories.
Click to hide internal directories.