token

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package token TODO

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Token

type Token struct {
	Type    Type
	Literal string
	Line    int
	Start   int
	End     int
}

Token is a struct representing a JSON token - It holds information like its Type and Literal, as well as Start, End, and Line fields. Line is used for better error handling, while Start and End are used to return objects/arrays from querys.

type Type

type Type string

Type is a type alias for a string

const (
	// Token/character we don't know about
	Illegal Type = "ILLEGAL"

	// End of file
	EOF Type = "EOF"

	// Literals
	String Type = "STRING"
	Number Type = "NUMBER"

	// The six structural tokens
	LeftBrace    Type = "{"
	RightBrace   Type = "}"
	LeftBracket  Type = "["
	RightBracket Type = "]"
	Comma        Type = ","
	Colon        Type = ":"

	// Values
	True  Type = "TRUE"
	False Type = "FALSE"
	Null  Type = "NULL"
)

All the different tokens for supporting JSON

func LookupIdentifier

func LookupIdentifier(identifier string) (Type, error)

LookupIdentifier checks our validJSONIdentifiers map for the scanned identifier. If it finds one, the identifier's token type is returned. If not found, an error is returned

Jump to

Keyboard shortcuts

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