monkey-lang: github.com/prologic/monkey-lang/token Index | Files

package token

import "github.com/prologic/monkey-lang/token"

Index

Package Files

token.go

Constants

const (
    // ILLEGAL represents an illegal token
    ILLEGAL = "ILLEGAL"

    // EOF end of file
    EOF = "EOF"

    // COMMENT a line comment, e.g: # this is a comment
    COMMENT = "COMMENT"

    // IDENT an identifier, e.g: add, foobar, x, y, ...
    IDENT = "IDENT"
    // INT an integer, e.g: 1234
    INT = "INT"
    // STRING a string, e.g: "1234"
    STRING = "STRING"

    // BIND the bind operator
    BIND = ":="
    // ASSIGN the assignment operator
    ASSIGN = "="
    // PLUS the addition operator
    PLUS = "+"
    // MINUS the substraction operator
    MINUS = "-"
    // MULTIPLY the multiplication operator
    MULTIPLY = "*"
    // DIVIDE the division operator
    DIVIDE = "/"
    // MODULO the modulo operator
    MODULO = "%"
    // LeftShift
    LeftShift = "<<"
    // RightShift
    RightShift = ">>"

    // Bitwise AND
    BitwiseAND = "&"
    // Bitwise OR
    BitwiseOR = "|"
    // Bitwise XOR
    BitwiseXOR = "^"
    // Bitwise NOT
    BitwiseNOT = "~"

    // NOT the not operator
    NOT = "!"
    // AND the and operator
    AND = "&&"
    // OR the or operator
    OR  = "||"

    // LT the less than comparision operator
    LT  = "<"
    // LTE  the less than or equal comparision operator
    LTE = "<="

    // GT the greater than comparision operator
    GT  = ">"
    // GTE the grather than or equal comparision operator
    GTE = ">="

    // EQ the equality operator
    EQ  = "=="
    // NEQ the inequality operator
    NEQ = "!="

    // COMMA a comma
    COMMA = ","
    // SEMICOLON a semi-colon
    SEMICOLON = ";"
    // COLON a comon
    COLON = ":"
    // DOT a dot
    DOT = "."

    // LPAREN a left paranthesis
    LPAREN = "("
    // RPAREN a right parenthesis
    RPAREN = ")"
    // LBRACE a left brace
    LBRACE = "{"
    // RBRACE a right brace
    RBRACE = "}"
    // LBRACKET a left bracket
    LBRACKET = "["
    // RBRACKET a right bracket
    RBRACKET = "]"

    // FUNCTION the `fn` keyword (function)
    FUNCTION = "FUNCTION"
    // TRUE the `true` keyword (true)
    TRUE = "TRUE"
    // FALSE the `false` keyword (false)
    FALSE = "FALSE"
    // NULL the `null` keyword (null)
    NULL = "NULL"
    // IF the `if` keyword (if)
    IF  = "IF"
    // ELSE the `else` keyword (else)
    ELSE = "ELSE"
    // RETURN the `return` keyword (return)
    RETURN = "RETURN"
    // WHILE the `while` keyword (while)
    WHILE = "WHILE"
    // IMPORT the `import` keyword (import)
    IMPORT = "IMPORT"
)

type Token Uses

type Token struct {
    Type    Type
    Literal string
}

Token holds a single token type and its literal value

type Type Uses

type Type string

Type represents the type of a token

func LookupIdent Uses

func LookupIdent(ident string) Type

LookupIdent looks up the identifier in ident and returns the appropriate token type depending on whether the identifier is user-defined or a keyword

Package token is imported by 3 packages. Updated 2019-03-06. Refresh now. Tools for package owners.