Documentation
¶
Overview ¶
Package token defines constants representing the lexical tokens of the DOT language together with operations like printing, detecting Keywords or identifiers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Kind ¶
type Kind uint32
Kind represents the types of lexical tokens of the DOT language. Token kinds are powers of 2 and can be combined using bitwise OR to create token sets for efficient membership testing.
const ( ERROR Kind = 1 << iota // EOF is not part of the DOT language and is used to indicate the end of the file or stream. No // language token should follow the EOF token. EOF ID // like _A 12 "234" Comment // like C pre-processor ones '# 34' LeftBrace // { RightBrace // } LeftBracket // [ RightBracket // ] Colon // : Semicolon // ; Equal // = Comma // , DirectedEdge // -> UndirectedEdge // -- // Keywords Digraph // digraph Edge // edge Graph // graph Node // node Strict // strict Subgraph // subgraph )
func Lookup ¶
Lookup returns the token type associated with given identifier which is either a DOT keyword or a DOT ID. DOT keywords are case-insensitive. This function expects that the input is a valid DOT ID as specified in IDs.
func (Kind) IsTerminal ¶
IsTerminal reports whether the token type is a terminal symbol (punctuation or operator). Terminal symbols include braces, brackets, colon, semicolon, equal, and comma.
type Position ¶
type Position struct {
Line uint32 // line number, starting at 1
Column uint32 // column number, starting at 1 (byte offset)
}
Position describes a position in DOT source code. A Position is valid if the line number is > 0.