hcl: github.com/hashicorp/hcl/hcl/token Index | Files

package token

import "github.com/hashicorp/hcl/hcl/token"

Package token defines constants representing the lexical tokens for HCL (HashiCorp Configuration Language)

Index

Package Files

position.go token.go

type Pos Uses

type Pos struct {
    Filename string // filename, if any
    Offset   int    // offset, starting at 0
    Line     int    // line number, starting at 1
    Column   int    // column number, starting at 1 (character count)
}

Pos describes an arbitrary source position including the file, line, and column location. A Position is valid if the line number is > 0.

func (Pos) After Uses

func (p Pos) After(u Pos) bool

After reports whether the position p is after u.

func (Pos) Before Uses

func (p Pos) Before(u Pos) bool

Before reports whether the position p is before u.

func (*Pos) IsValid Uses

func (p *Pos) IsValid() bool

IsValid returns true if the position is valid.

func (Pos) String Uses

func (p Pos) String() string

String returns a string in one of several forms:

file:line:column    valid position with file name
line:column         valid position without file name
file                invalid position with file name
-                   invalid position without file name

type Token Uses

type Token struct {
    Type Type
    Pos  Pos
    Text string
    JSON bool
}

Token defines a single HCL token which can be obtained via the Scanner

func (Token) String Uses

func (t Token) String() string

String returns the token's literal text. Note that this is only applicable for certain token types, such as token.IDENT, token.STRING, etc..

func (Token) Value Uses

func (t Token) Value() interface{}

Value returns the properly typed value for this token. The type of the returned interface{} is guaranteed based on the Type field.

This can only be called for literal types. If it is called for any other type, this will panic.

type Type Uses

type Type int

Type is the set of lexical tokens of the HCL (HashiCorp Configuration Language)

const (
    // Special tokens
    ILLEGAL Type = iota
    EOF
    COMMENT

    IDENT // literals

    NUMBER  // 12345
    FLOAT   // 123.45
    BOOL    // true,false
    STRING  // "abc"
    HEREDOC // <<FOO\nbar\nFOO

    LBRACK // [
    LBRACE // {
    COMMA  // ,
    PERIOD // .

    RBRACK // ]
    RBRACE // }

    ASSIGN // =
    ADD    // +
    SUB    // -

)

func (Type) IsIdentifier Uses

func (t Type) IsIdentifier() bool

IsIdentifier returns true for tokens corresponding to identifiers and basic type literals; it returns false otherwise.

func (Type) IsLiteral Uses

func (t Type) IsLiteral() bool

IsLiteral returns true for tokens corresponding to basic type literals; it returns false otherwise.

func (Type) IsOperator Uses

func (t Type) IsOperator() bool

IsOperator returns true for tokens corresponding to operators and delimiters; it returns false otherwise.

func (Type) String Uses

func (t Type) String() string

String returns the string corresponding to the token tok.

Package token imports 4 packages (graph) and is imported by 87 packages. Updated 2016-11-10. Refresh now. Tools for package owners.