Documentation
¶
Overview ¶
Package token defines the lexical token types for OpenQASM 3.0 parsing.
Type is the token type enum with constants for keywords (GATE, QUBIT, MEASURE, …), operators, literals, and punctuation. Token pairs a Type with its literal text and source position. LookupIdent classifies an identifier as a keyword or plain IDENT.
Most users should use [parser.Parse] rather than importing this package directly.
Package token defines token types for the OpenQASM 3.0 lexer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Keywords = map[string]Type{ "OPENQASM": OPENQASM, "include": INCLUDE, "gate": GATE, "qubit": QUBIT, "bit": BIT, "qreg": QREG, "creg": CREG, "measure": MEASURE, "reset": RESET, "barrier": BARRIER, "if": IF, "else": ELSE, "for": FOR, "while": WHILE, "in": IN, "return": RETURN, "def": DEF, "const": CONST, "input": INPUT, "output": OUTPUT, "ctrl": CTRL, "negctrl": NEGCTRL, "inv": INV, "pow": POW, "gphase": GPHASE, "U": U, "pi": PI, "π": PI, "euler": EULER, "ℇ": EULER, "tau": TAU, "τ": TAU, "true": TRUE, "false": FALSE, "let": LET, "int": INT_TYPE, "uint": UINT_TYPE, "float": FLOAT_TYPE, "angle": ANGLE_TYPE, "bool": BOOL_TYPE, "complex": COMPLEX_TYPE, "duration": DURATION, "stretch": STRETCH, }
Keywords maps keyword strings to token types.
Functions ¶
This section is empty.
Types ¶
type Type ¶
type Type int
Type represents a token type.
const ( // Special EOF Type = iota ILLEGAL COMMENT // Literals IDENT // identifier INT // integer literal FLOAT // floating point literal STRING // string literal // Operators & delimiters LPAREN // ( RPAREN // ) LBRACKET // [ RBRACKET // ] LBRACE // { RBRACE // } SEMICOLON // ; COMMA // , COLON // : DOT // . AT // @ ARROW // -> EQUALS // = EQEQ // == NEQ // != PLUS // + MINUS // - STAR // * SLASH // / PERCENT // % POWER // ** AMP // & PIPE // | CARET // ^ TILDE // ~ BANG // ! LT // < GT // > LE // <= GE // >= LSHIFT // << RSHIFT // >> AMPAMP // && PIPEPIPE // || // Keywords OPENQASM INCLUDE GATE QUBIT BIT QREG CREG MEASURE RESET BARRIER IF ELSE FOR WHILE IN RETURN DEF CONST INPUT OUTPUT CTRL NEGCTRL INV POW GPHASE U // built-in U gate PI // pi constant EULER // euler constant TAU // tau constant TRUE FALSE LET INT_TYPE UINT_TYPE FLOAT_TYPE ANGLE_TYPE BOOL_TYPE COMPLEX_TYPE DURATION STRETCH )
func LookupIdent ¶
LookupIdent returns the token type for an identifier, checking keywords first.
Click to show internal directories.
Click to hide internal directories.