scanner

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EOF byte = 0 // used to imitate end of file

	CommentSign             = '#'
	AnnotationDelimiterPart = '/'
	ObjectOpen              = '{'
	ArrayOpen               = '['
	ContextOpenSign         = '('
	ContextCloseSign        = ')'
	LinkSymbol              = '@'
	DoubleQuote             = '"'
	RegexDelimiter          = '/'
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexeme

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

func NewLexeme

func NewLexeme(type_ LexemeType, begin bytes.Index, end bytes.Index, file *fs.File) *Lexeme

func (Lexeme) Begin

func (lex Lexeme) Begin() bytes.Index

func (Lexeme) End

func (lex Lexeme) End() bytes.Index

func (Lexeme) File

func (lex Lexeme) File() *fs.File

func (*Lexeme) SetBegin

func (lex *Lexeme) SetBegin(begin bytes.Index)

func (*Lexeme) SetEnd

func (lex *Lexeme) SetEnd(end bytes.Index)

func (*Lexeme) SetFile

func (lex *Lexeme) SetFile(file *fs.File)

func (*Lexeme) SetType

func (lex *Lexeme) SetType(t LexemeType)

func (Lexeme) String

func (lex Lexeme) String() string

func (Lexeme) Type

func (lex Lexeme) Type() LexemeType

func (Lexeme) Value

func (lex Lexeme) Value() bytes.Bytes

type LexemeEvent

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

type LexemeEventType

type LexemeEventType uint8
const (
	KeywordBegin LexemeEventType = iota
	KeywordEnd
	ParameterBegin
	ParameterEnd
	AnnotationBegin
	AnnotationEnd
	SchemaBegin
	SchemaEnd
	JsonArrayBegin
	JsonArrayEnd
	TextBegin
	TextEnd
	ContextOpen
	ContextClose
)

func (LexemeEventType) IsBeginning

func (e LexemeEventType) IsBeginning() bool

func (LexemeEventType) IsEnding

func (e LexemeEventType) IsEnding() bool

func (LexemeEventType) IsSingle

func (e LexemeEventType) IsSingle() bool

func (LexemeEventType) String

func (e LexemeEventType) String() string

func (LexemeEventType) ToLexemeType

func (e LexemeEventType) ToLexemeType() LexemeType

type LexemeType

type LexemeType uint8
const (
	Keyword                LexemeType = iota // Name of a Directive, i.e. URL, GET, Path, 200, etc
	Parameter                                // Parameter for directive (regexp/jsight fot TYPE)
	Annotation                               // user's annotation to directive in a free-text form
	Schema                                   // jSchema inside directive's body (Body, TYPE, 200, etc)
	Json                                     // json inside directive's body (CONFIG)
	Array                                    // Array of string values inside ENUM body
	Text                                     // Text inside directive Description body
	ContextExplicitOpening                   // Explicitly opens context, so that it can ba later explicitly closed
	ContextExplicitClosing                   // Explicitly opens context, so that it can ba later explicitly closed
)

func (LexemeType) String

func (t LexemeType) String() string

type Scanner

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

func NewJApiScanner

func NewJApiScanner(file *fs.File) *Scanner

func (*Scanner) CurrentIndex

func (s *Scanner) CurrentIndex() bytes.Index

func (*Scanner) Next

func (s *Scanner) Next() (*Lexeme, *jerr.JAPIError)

Next reads japi file by bytes, detects lexemes beginnings and ends and returns them as soon as they found returns false for the end of file

func (*Scanner) SetCurrentIndex

func (s *Scanner) SetCurrentIndex(i bytes.Index)

SetCurrentIndex to continue scanning from certain position

Jump to

Keyboard shortcuts

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