opa: github.com/open-policy-agent/opa/ast/internal/scanner Index | Files

package scanner

import "github.com/open-policy-agent/opa/ast/internal/scanner"

Index

Package Files

scanner.go

type Error Uses

type Error struct {
    Pos     Position
    Message string
}

Error represents a scanner error.

type Position Uses

type Position struct {
    Offset int // start offset in bytes
    End    int // end offset in bytes
    Row    int // line number computed in bytes
    Col    int // column number computed in bytes
}

Position represents a point in the scanned source code.

type Scanner Uses

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

Scanner is used to tokenize an input stream of Rego source code.

func New Uses

func New(r io.Reader) (*Scanner, error)

New returns an initialized scanner that will scan through the source code provided by the io.Reader.

func (*Scanner) Bytes Uses

func (s *Scanner) Bytes() []byte

Bytes returns the raw bytes for the full source which the scanner has read in.

func (*Scanner) Scan Uses

func (s *Scanner) Scan() (tokens.Token, Position, string, []Error)

Scan will increment the scanners position in the source code until the next token is found. The token, starting position of the token, string literal, and any errors encountered are returned. A token will always be returned, the caller must check for any errors before using the other values.

func (*Scanner) String Uses

func (s *Scanner) String() string

String returns a human readable string of the current scanner state.

Package scanner imports 6 packages (graph) and is imported by 1 packages. Updated 2020-03-26. Refresh now. Tools for package owners.