lib

package
v0.0.0-...-170b523 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PBIT = iota
	SENT = iota
	PATB = iota
	PATC = iota
	RES  = iota
)
View Source
const (
	PAGE      = iota
	PARAGRAPH = iota
	SENTENCE  = iota
	PATTERN   = iota
	KW_SINGLE = "'"
	MBUFSIZE  = 512
)
View Source
const (
	COLLECTQUOTE = iota
	COLLECTLINE  = iota
	COLLECTNEXT  = iota
	ENDOFBUFFER  = "jxLmZJ7gPY"
)
View Source
const (
	KW_PARAGRAPH_CAPACITY = 10
	KW_PARAGRAPH_EXTEND   = 5
)
View Source
const (
	KW_COLON   = ":"
	KW_LBRACE  = "{"
	KW_RBRACE  = "}"
	KW_DQUOTE  = "\""
	KW_SQUOTE  = "'"
	KW_DRSTART = KW_COLON
	KW_TFOUND  = true
	KW_NFOUND  = false
	KW_TOKSEP  = "-"
	KW_DEFINED = 1
	KW_SEMI    = ";"
	KW_EQUAL   = "="
)
View Source
const (
	INSEQUENCE = 2 * 1 << iota
	UNSEQUENCE = 2 * 1 << iota
	PGMIXED    = 2 * 1 << iota
	PGLOWER    = 2 * 1 << iota
)

Page Constants

View Source
const (
	ONEOF   = 2 * 1 << iota
	SOMEOF  = 2 * 1 << iota
	ANYOF   = 2 * 1 << iota
	ALLOF   = 2 * 1 << iota
	BEGIN   = 2 * 1 << iota
	END     = 2 * 1 << iota
	PAMIXED = 2 * 1 << iota
	PALOWER = 2 * 1 << iota
)

Paragraph Constants

View Source
const (
	COLLECT_QUOTE = 2 * 1 << iota
	COLLECT_LINE  = 2 * 1 << iota
	COLLECT_NEXT  = 2 * 1 << iota
	COLLECT       = 2 * 1 << iota
	COLLECT_COMMA = 2 * 1 << iota
	CONCAT_TAB    = 2 * 1 << iota
	CONCAT        = 2 * 1 << iota
	COMPLETE      = 2 * 1 << iota
	ISTHERE       = 2 * 1 << iota
	EXACT         = 2 * 1 << iota
	ANY           = 2 * 1 << iota
	EXCLUDE       = 2 * 1 << iota
	FOLLOW        = 2 * 1 << iota
	REGARDLESS    = 2 * 1 << iota
	STMIXED       = 2 * 1 << iota
	STLOWER       = 2 * 1 << iota
	START         = 2 * 1 << iota
)

Sentence Constants

Variables

View Source
var (
	Seqidx = 0
	SeqInc = func() {
		Seqidx++
	}

	MatchTok = func(s StringList) {
		matchP = matchP[0:0]
		matchP = append(matchP, s...)
	}
)
View Source
var (
	ParaIdx = -1
	IncPara = func() {
		ParaIdx++
		SentIdx = -1
	}

	SentIdx = -1 /* Set to something stupid to shutup compiler */
	IncSent = func() {
		SentIdx++
		SrchIdx = -1
	}

	SrchIdx = -1
	IncSrch = func() {
		SrchIdx++
	}
)
View Source
var (
	Fset *token.FileSet
)

Functions

func BuildToken

func BuildToken(tok string, b string, e string) string

func ToString

func ToString(x StringList) string

func UpdateResults

func UpdateResults(r *Results, s string, u string) bool

Types

type CFParser

type CFParser interface {
	NextToken(s scanner.Scanner) (CFToken, scanner.Scanner)
	IsToken(s string) bool
}

type CFTErr

type CFTErr struct {
	Err  string
	Line token.Pos
	Code int
}

type CFToken

type CFToken struct {
	Pos   token.Pos
	PLine string
	PTok  token.Token
	PLit  string
}

func NextToken

func NextToken(f *token.FileSet, s scanner.Scanner) (CFToken, scanner.Scanner)

NextToken: Takes a scanner object and returns the next token NextToken: and updated Scanner position.

type Collect

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

func NewCollection

func NewCollection(p int, s int, pt string, pgdir Directive, padir Directive, stdir Directive, patdir Directive, pm StringList) Collect

func (*Collect) CheckParaGraphStatus

func (l *Collect) CheckParaGraphStatus()

CheckParaGraphStatus - Checks the pattern bit status and if set then sets CheckParaGraphStatus - sentence/paragrpah bit.

func (Collect) GetMatchToken

func (s Collect) GetMatchToken() StringList

func (Collect) GetPatternDirective

func (s Collect) GetPatternDirective(i int) Directive

func (Collect) GetSentence

func (s Collect) GetSentence() StringList

func (Collect) IsParagraphComplete

func (s Collect) IsParagraphComplete() bool

func (Collect) IsPatternComplete

func (s Collect) IsPatternComplete() bool

func (Collect) IsSentenceComplete

func (s Collect) IsSentenceComplete() bool

func (*Collect) MatchCollectSentence

func (s *Collect) MatchCollectSentence(t CFToken) bool

func (Collect) PutStr

func (o Collect) PutStr()

type CollectFuncs

type CollectFuncs Command

type CollectLine

type CollectLine struct{}

func (CollectLine) CollectResults

func (c CollectLine) CollectResults(df *os.File,
	f *token.FileSet,
	b *Mbuf,
	t *CFToken,
	rs *Results,
	ds scanner.Scanner) scanner.Scanner

type CollectList

type CollectList []Collect

func InitEngine

func InitEngine(pg Page) CollectList

func (*CollectList) ClearPatternStatus

func (s *CollectList) ClearPatternStatus()

func (CollectList) CollectResults

func (c CollectList) CollectResults(df *os.File,
	f *token.FileSet,
	b *Mbuf,
	t *CFToken,
	rs *Results,
	ds scanner.Scanner) scanner.Scanner

type CollectNext

type CollectNext struct{}

func (CollectNext) CollectResults

func (c CollectNext) CollectResults(df *os.File,
	f *token.FileSet,
	b *Mbuf,
	t *CFToken,
	rs *Results,
	ds scanner.Scanner) scanner.Scanner

type CollectQuote

type CollectQuote struct{}

func (CollectQuote) CollectResults

func (c CollectQuote) CollectResults(df *os.File,
	f *token.FileSet,
	b *Mbuf,
	t *CFToken,
	rs *Results,
	ds scanner.Scanner) scanner.Scanner

type Command

type Command interface {
	CollectResults(*os.File, *token.FileSet, *Mbuf, *CFToken, *Results, scanner.Scanner) scanner.Scanner
}

type Directive

type Directive uint

func (Directive) ClearDirective

func (d Directive) ClearDirective(v Directive) Directive

func (Directive) IsDirectiveSet

func (d Directive) IsDirectiveSet(v Directive) bool

func (Directive) SetDirective

func (d Directive) SetDirective(v Directive) Directive

type DirectiveList

type DirectiveList []Directive

type Mbuf

type Mbuf []byte

func NewMbuf

func NewMbuf() Mbuf

func (*Mbuf) GetBuffer

func (by *Mbuf) GetBuffer(f *os.File) int

GetBuffer: Reads a buffer full of data and returns the buffer ending at GetBuffer: a whitespace character. It returns 0 if the end of file is reached.

func (Mbuf) IsWhiteSpace

func (by Mbuf) IsWhiteSpace(b byte) bool

func (Mbuf) NewKwScanner

func (bs Mbuf) NewKwScanner(s scanner.Scanner) (*token.FileSet, scanner.Scanner)

func (*Mbuf) NextDataToken

func (b *Mbuf) NextDataToken(df *os.File, f *token.FileSet, t *CFToken, s scanner.Scanner) (*token.FileSet, scanner.Scanner)

NextDataToken: Takes a scanner object and returns the next token NextDataToken: and updated Scanner position. If the line number NextDataToken: changes then a NewLine token is returned and the NextDataToken: subsequent call returns the cached token.

type Page

type Page struct {
	Paras ParagraphList
	// contains filtered or unexported fields
}

func NewPage

func NewPage() Page

NewPage: Allocates storage for the page.

func (Page) CheckDirectives

func (pg Page) CheckDirectives() bool

func (Page) GetPageDirective

func (pg Page) GetPageDirective() Directive

func (Page) GetParagraphCnt

func (pg Page) GetParagraphCnt() int

func (*Page) ProcessPage

func (pg *Page) ProcessPage(f *token.FileSet, s scanner.Scanner, t CFToken) (scanner.Scanner, bool)

ProcessPage takes a token and determines if it contains the start to the page command and then proccesses the command. ProcessPage returns true if successful. Otherwise ProcessPage returns false.

func (*Page) ProcessParagraph

func (pg *Page) ProcessParagraph(f *token.FileSet, s scanner.Scanner, t CFToken) (scanner.Scanner, bool)

func (*Page) ProcessSentence

func (pg *Page) ProcessSentence(f *token.FileSet, s scanner.Scanner, t CFToken) (scanner.Scanner, bool)

func (Page) String

func (p Page) String() string

type Paragraph

type Paragraph struct {
	Stc   PatternList // Sentences
	Stcnt int
	// contains filtered or unexported fields
}

func MakeParagraph

func MakeParagraph(p *Paragraph) *Paragraph

func (Paragraph) GetParagraphDirective

func (para Paragraph) GetParagraphDirective() Directive

func (Paragraph) String

func (pa Paragraph) String() string

type ParagraphList

type ParagraphList []Paragraph

func (*ParagraphList) AddParagraph

func (p *ParagraphList) AddParagraph(np ...Paragraph)

type Pattern

type Pattern struct {
	Pt StringList // pattern to match
	Nt StringList // Match next token
	// contains filtered or unexported fields
}

func (Pattern) GetMatchNextToken

func (pt Pattern) GetMatchNextToken() StringList

func (Pattern) GetPatternDirective

func (pt Pattern) GetPatternDirective(i int) Directive

func (Pattern) GetPatternDirectiveList

func (pt Pattern) GetPatternDirectiveList() DirectiveList

func (Pattern) GetSentenceDirective

func (sent Pattern) GetSentenceDirective() Directive

func (Pattern) GetSentenceName

func (sent Pattern) GetSentenceName() string

func (Pattern) PatternDirectiveTotal

func (pat Pattern) PatternDirectiveTotal() Directive

func (Pattern) String

func (stc Pattern) String() string

type PatternList

type PatternList []Pattern

func (*PatternList) AddPattern

func (p *PatternList) AddPattern(i func(), idx *int, np ...Pattern)

func AddPattern(p []Pattern, i func(), idx *int, np ...Pattern) []Pattern {

type Results

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

func (*Results) AddResults

func (r *Results) AddResults(rs string)

func (*Results) PutResults

func (rs *Results) PutResults()

type StringList

type StringList []string

func MakeTokenString

func MakeTokenString(tokestr string) StringList

func (*StringList) AddSearch

func (p *StringList) AddSearch(np ...string)

Jump to

Keyboard shortcuts

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