package tokens

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

Index

Types

type Token

type Token int

Token represents a single Rego source code token for use by the Parser.

const (
	Illegal Token = iota
	EOF
	Whitespace
	Ident
	Comment

	Package
	Import
	As
	Default
	Else
	Not
	Some
	With
	Null
	True
	False

	Number
	String

	LBrack
	RBrack
	LBrace
	RBrace
	LParen
	RParen
	Comma
	Colon

	Add
	Sub
	Mul
	Quo
	Rem
	And
	Or
	Unify
	Equal
	Assign
	Neq
	Gt
	Lt
	Gte
	Lte
	Dot
	Semicolon
)

All tokens must be defined here

func Keyword

func Keyword(lit string) Token

Keyword will return a token for the passed in literal value. If the value is a Rego keyword then the appropriate token is returned. Everything else is an Ident.

func (Token) String

func (t Token) String() string

Source Files

tokens.go

Version
v0.19.2
Published
Apr 27, 2020
Platform
js/wasm
Last checked
4 minutes ago

Tools for package owners.