parser

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2022 License: Apache-2.0 Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ModGlobal modifiers = 1 << iota
	ModPrivate
	ModASCII
	ModWide
	ModXor
	ModFullword
	ModNocase
	ModBase64
	ModBase64Wide
)
View Source
const COMMENT = 3
View Source
const REGEXP = 2
View Source
const STR = 1
View Source
const UNARY_MINUS = 57407

Variables

This section is empty.

Functions

func Parse

func Parse(input io.Reader) (rs *ast.RuleSet, err error)

func YYmain

func YYmain(filenames ...string) (interface{}, error)

Types

type Scanner

type Scanner struct {
	In     io.Reader
	Out    io.Writer
	Lineno int

	Filename      string
	Wrap          func(*Scanner) bool
	IsInteractive func(io.Reader) bool
	Context       YYcontext

	Interactive bool
	// contains filtered or unexported fields
}

func NewScanner

func NewScanner() *Scanner

func (*Scanner) Input

func (yy *Scanner) Input() (byte, error)

func (*Scanner) Lex

func (yy *Scanner) Lex() YYtype

The main scanner function which does all the work.

func (*Scanner) NewFile

func (yy *Scanner) NewFile()

func (*Scanner) Restart

func (yy *Scanner) Restart(input_file io.Reader)

* Immediately switch to a different input stream.

  • @param input_file A readable stream. *
  • @note This function does not reset the start condition to @c yyInitial .

func (*Scanner) Token added in v0.4.0

func (s *Scanner) Token(tokenType int) YYtype

Token creates a YYtype struct for the given token type with no associated value.

func (*Scanner) TokenFloat64 added in v0.5.4

func (s *Scanner) TokenFloat64(tokenType int, v float64) YYtype

func (*Scanner) TokenHexString added in v0.4.0

func (s *Scanner) TokenHexString(hexTokens []ast.HexToken) YYtype

func (*Scanner) TokenInt64 added in v0.4.0

func (s *Scanner) TokenInt64(tokenType int, v int64) YYtype

func (*Scanner) TokenRegExp added in v0.4.0

func (s *Scanner) TokenRegExp(reg *ast.LiteralRegexp) YYtype

func (*Scanner) TokenString added in v0.4.0

func (s *Scanner) TokenString(tokenType int, v string) YYtype

TokenString creates a YYtype struct for the given token type with an associated string.

type YYcontext

type YYcontext struct {
	Token string
}

type YYtype

type YYtype struct {
	Token    int        // One of the constants defined in grammar.y via the %token directive.
	Lineno   int        // Line number where the token is found.
	StartPos int        // Position within the parsed source code where the token starts (inclusive).
	EndPos   int        // Position within the parsed source code where the token ends (exclusive).
	Value    *yrSymType // Value associated with the toke.
	Error    gyperror.Error
}

YYtype is a structure that represents a token. The lexer/scanner returns an instance of this structure every time parser asks for the next token. Each token may have an associated value, for example, the _IDENTIFIER_ token has an associated string with the identifier's name. If the lexer/scanner wants to return an error to the parser it sets the Error field and leaves the Token and Value empty. This structure also stores information about the token's position within the original source code.

func Error

func Error(c gyperror.Code, msg string) YYtype

Jump to

Keyboard shortcuts

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