### Install the HTML package Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/html Command to install the package via go get. ```bash go get -u github.com/tdewolff/parse/v2/html ``` -------------------------------- ### Install the XML package Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/xml Use the go get command to add the package to your project. ```bash go get -u github.com/tdewolff/parse/v2/xml ``` -------------------------------- ### Install the js package Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Command to install the package via go get. ```bash go get -u github.com/tdewolff/parse/v2/js ``` -------------------------------- ### Install the CSS package Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/css Use the go get command to install the package or add it to your project imports. ```bash go get -u github.com/tdewolff/parse/v2/css ``` ```go import "github.com/tdewolff/parse/v2/css" ``` -------------------------------- ### Install the JSON package Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/json Use the go get command to add the package to your project. ```bash go get -u github.com/tdewolff/parse/v2/json ``` -------------------------------- ### Full XML Tokenization Example Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/xml A complete example demonstrating how to read from stdin and process tags and attributes. ```go package main import ( "os" "github.com/tdewolff/parse/v2/xml" ) // Tokenize XML from stdin. func main() { l := xml.NewLexer(parse.NewInput(os.Stdin)) for { tt, data := l.Next() switch tt { case xml.ErrorToken: if l.Err() != io.EOF { fmt.Println("Error on line", l.Line(), ":", l.Err()) } return case xml.StartTagToken: fmt.Println("Tag", string(data)) for { ttAttr, dataAttr := l.Next() if ttAttr != xml.AttributeToken { break } key := dataAttr val := l.AttrVal() fmt.Println("Attribute", string(key), "=", string(val)) } // ... } } } ``` -------------------------------- ### Full Tokenization Example Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/html Complete example demonstrating how to tokenize HTML from stdin and extract attributes. ```go package main import ( "os" "github.com/tdewolff/parse/v2/html" ) // Tokenize HTML from stdin. func main() { l := html.NewLexer(parse.NewInput(os.Stdin)) for { tt, data := l.Next() switch tt { case html.ErrorToken: if l.Err() != io.EOF { fmt.Println("Error on line", l.Line(), ":", l.Err()) } return case html.StartTagToken: fmt.Println("Tag", string(data)) for { ttAttr, dataAttr := l.Next() if ttAttr != html.AttributeToken { break } key := dataAttr val := l.AttrVal() fmt.Println("Attribute", string(key), "=", string(val)) } // ... } } } ``` -------------------------------- ### Install and Import the JSON Package Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/json Commands to install the package via go get and the required import statement for Go projects. ```bash go get -u github.com/tdewolff/parse/v2/json ``` ```go import "github.com/tdewolff/parse/v2/json" ``` -------------------------------- ### Example output Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/buffer Displays the expected output format. ```text Output: Lorem ipsum ``` -------------------------------- ### Lexer Example Output Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/html Example output from the lexer. ```text Output: John Doe ``` -------------------------------- ### Tokenize JS from stdin Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Full example demonstrating how to read and process tokens from standard input. ```go package main import ( "os" "github.com/tdewolff/parse/v2/js" ) // Tokenize JS from stdin. func main() { l := js.NewLexer(parse.NewInput(os.Stdin)) for { tt, text := l.Next() switch tt { case js.ErrorToken: if l.Err() != io.EOF { fmt.Println("Error on line", l.Line(), ":", l.Err()) } return case js.IdentifierToken: fmt.Println("Identifier", string(text)) case js.NumericToken: fmt.Println("Numeric", string(text)) // ... } } } ``` -------------------------------- ### Parser Output Example Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/json Example output for a parser operation. ```text {"key":5} ``` -------------------------------- ### Get Var info Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/js Retrieves information about the variable. ```go func (v *Var) Info() string ``` -------------------------------- ### Tokenize CSS from stdin Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/css Complete example demonstrating how to read CSS from standard input and process specific tokens. ```go package main import ( "os" "github.com/tdewolff/parse/v2/css" ) // Tokenize CSS3 from stdin. func main() { l := css.NewLexer(parse.NewInput(os.Stdin)) for { tt, text := l.Next() switch tt { case css.ErrorToken: if l.Err() != io.EOF { fmt.Println("Error on line", l.Line(), ":", l.Err()) } return case css.IdentToken: fmt.Println("Identifier", string(text)) case css.NumberToken: fmt.Println("Number", string(text)) // ... } } } ``` -------------------------------- ### Tokenize JSON from Stdin Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/json A complete example demonstrating how to read JSON from standard input and handle specific grammar types. ```go package main import ( "os" "github.com/tdewolff/parse/v2/json" ) // Tokenize JSON from stdin. func main() { p := json.NewParser(parse.NewInput(os.Stdin)) for { gt, text := p.Next() switch gt { case json.ErrorGrammar: if p.Err() != io.EOF { fmt.Println("Error on line", p.Line(), ":", p.Err()) } return case json.LiteralGrammar: fmt.Println("Literal", string(text)) case json.NumberGrammar: fmt.Println("Number", string(text)) // ... } } } ``` -------------------------------- ### Parse CSS stylesheet Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/css Complete example demonstrating how to parse a CSS string and reconstruct it from grammar units. ```go package main import ( "bytes" "fmt" "github.com/tdewolff/parse/v2/css" ) func main() { // true because this is the content of an inline style attribute p := css.NewParser(parse.NewInput(bytes.NewBufferString("color: red;")), true) out := "" for { gt, _, data := p.Next() if gt == css.ErrorGrammar { break } else if gt == css.AtRuleGrammar || gt == css.BeginAtRuleGrammar || gt == css.BeginRulesetGrammar || gt == css.DeclarationGrammar { out += string(data) if gt == css.DeclarationGrammar { out += ":" } for _, val := range p.Values() { out += string(val.Data) } if gt == css.BeginAtRuleGrammar || gt == css.BeginRulesetGrammar { out += "{" } else if gt == css.AtRuleGrammar || gt == css.DeclarationGrammar { out += ";" } } else { out += string(data) } } fmt.Println(out) } ``` -------------------------------- ### Get String Representation of Property Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Returns the string representation of a property. ```go func (n Property) String() string ``` -------------------------------- ### Get String Representation of OpPrec Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Returns the string representation of an OpPrec value. ```go func (prec OpPrec) String() string ``` -------------------------------- ### Get Current Lexeme Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Returns the bytes of the current selection. ```go func (z *Input) Lexeme() []byte ``` -------------------------------- ### Get String Representation of Params Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Returns the string representation of parameters. ```go func (n Params) String() string ``` -------------------------------- ### Get Var name Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/js Returns the variable name as a byte slice. ```go func (v *Var) Name() []byte ``` -------------------------------- ### Get String Representation of Return Statement Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Returns the string representation of a return statement. ```go func (n ReturnStmt) String() string ``` -------------------------------- ### Get Character Offset Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Returns the character position in the buffer. ```go func (z *Input) Offset() int ``` -------------------------------- ### Get Buffer Length Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Returns the length of the underlying buffer. ```go func (z *Input) Len() int ``` -------------------------------- ### Get String Representation of Property Name Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Returns the string representation of a property name. ```go func (n PropertyName) String() string ``` -------------------------------- ### Initialize and use the CSS Parser Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/css Create a parser instance and iterate over grammar units. ```go // true because this is the content of an inline style attribute p := css.NewParser(parse.NewInput(bytes.NewBufferString("color: red;")), true) ``` ```go for { gt, _, data := p.Next() if gt == css.ErrorGrammar { break } // ... } ``` -------------------------------- ### Initialize the Lexer Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/xml Create a new lexer instance using an input source. ```go l := xml.NewLexer(parse.NewInput(r)) ``` -------------------------------- ### Get length of VarsByUses Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/js Returns the number of elements in the collection. ```go func (vs VarsByUses) Len() int ``` -------------------------------- ### Initialize the Lexer Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/html Create a new lexer instance using an io.Reader. ```go l := html.NewLexer(parse.NewInput(r)) ``` -------------------------------- ### Get Position Mark Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Returns a mark that can be used for rewinding. ```go func (z *Input) Pos() int ``` -------------------------------- ### Lexer Initialization Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/html Functions to create a new lexer instance. ```go func NewLexer(r *parse.Input) *Lexer ``` ```go func NewTemplateLexer(r *parse.Input, tmpl [2]string) *Lexer ``` -------------------------------- ### Initialize Lexer Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/xml Creates a new Lexer instance for a given input. ```go func NewLexer(r *parse.Input) *Lexer ``` -------------------------------- ### Initialize and use the CSS Lexer Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/css Create a new lexer from an io.Reader and iterate through tokens until EOF. ```go l := css.NewLexer(parse.NewInput(r)) ``` ```go for { tt, text := l.Next() switch tt { case css.ErrorToken: // error or EOF set in l.Err() return // ... } } ``` -------------------------------- ### Lexer Initialization and Usage Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Provides state for lexing and tokenizing input. ```go type Lexer struct { // contains filtered or unexported fields } ``` ```go func NewLexer(r *parse.Input) *Lexer ``` ```text Output: var x = 'lorem ipsum'; ``` ```go func (l *Lexer) Err() error ``` ```go func (l *Lexer) Next() (TokenType, []byte) ``` ```go func (l *Lexer) RegExp() (TokenType, []byte) ``` -------------------------------- ### Initialize the JSON Parser Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/json Create a new parser instance using an input reader. ```go p := json.NewParser(parse.NewInput(r)) ``` -------------------------------- ### Initialize and Use the JSON Parser Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/json Basic initialization of the parser and a loop structure to iterate through tokens until EOF or an error occurs. ```go p := json.NewParser(parse.NewInput(r)) ``` ```go for { gt, text := p.Next() switch gt { case json.ErrorGrammar: // error or EOF set in p.Err() return // ... } } ``` -------------------------------- ### DirectivePrologueStmt Structure and Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Represents a string literal directive at the start of a scope. ```go type DirectivePrologueStmt struct { Value []byte } ``` ```go func (n DirectivePrologueStmt) JS(w io.Writer) ``` ```go func (n DirectivePrologueStmt) String() string ``` -------------------------------- ### Lexer navigation and state methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/buffer Methods to retrieve buffer data, current position, errors, and manage selection state. ```go func (z *Lexer) Bytes() []byte ``` ```go func (z *Lexer) Err() error ``` ```go func (z *Lexer) Lexeme() []byte ``` ```go func (z *Lexer) Move(n int) ``` ```go func (z *Lexer) Offset() int ``` ```go func (z *Lexer) Pos() int ``` ```go func (z *Lexer) Reset() ``` ```go func (z *Lexer) Restore() ``` ```go func (z *Lexer) Rewind(pos int) ``` ```go func (z *Lexer) Shift() []byte ``` ```go func (z *Lexer) Skip() ``` -------------------------------- ### Import the XML package Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/xml Add this import statement to your Go source files. ```go import "github.com/tdewolff/parse/v2/xml" ``` -------------------------------- ### Initialize Parser Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/css Creates a new Parser instance, with an option to specify if the input is an inline style attribute. ```go func NewParser(r *parse.Input, isInline bool) *Parser ``` -------------------------------- ### Get Input Error Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Returns the error from io.Input or io.EOF upon reaching the end. ```go func (z *Input) Err() error ``` -------------------------------- ### Import the JSON package Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/json Add this import statement to your Go source files. ```go import "github.com/tdewolff/parse/v2/json" ``` -------------------------------- ### Define Parser Options Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Configuration options for the parser behavior. ```go type Options struct { WhileToFor bool Inline bool } ``` -------------------------------- ### Initialize Reader Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/buffer Creates a new Reader instance for a given byte slice. ```go func NewReader(buf []byte) *Reader ``` -------------------------------- ### Lexer navigation methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/buffer Methods to move, skip, or rewind the position within the buffer. ```go func (z *Lexer) Move(n int) ``` ```go func (z *Lexer) Offset() int ``` ```go func (z *Lexer) Pos() int ``` ```go func (z *Lexer) Reset() ``` ```go func (z *Lexer) Restore() ``` ```go func (z *Lexer) Rewind(pos int) ``` ```go func (z *Lexer) Shift() []byte ``` ```go func (z *Lexer) Skip() ``` -------------------------------- ### Import the HTML package Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/html Import statement for including the package in a Go project. ```go import "github.com/tdewolff/parse/v2/html" ``` -------------------------------- ### Lexer Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/html Methods for interacting with the lexer state and retrieving token information. ```go func (l *Lexer) AttrKey() []byte ``` ```go func (l *Lexer) AttrVal() []byte ``` ```go func (l *Lexer) Err() error ``` ```go func (l *Lexer) HasTemplate() bool ``` ```go func (l *Lexer) Next() (TokenType, []byte) ``` ```go func (l *Lexer) Text() []byte ``` -------------------------------- ### Writer Definition and Initialization Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/buffer Defines the Writer structure and constructors for byte slice output. ```go type Writer struct { // contains filtered or unexported fields } ``` ```go func NewStaticWriter(buf []byte) *Writer ``` ```go func NewWriter(buf []byte) *Writer ``` -------------------------------- ### AST Traversal Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Utility to traverse the AST. ```go func Walk(v IVisitor, n INode) ``` -------------------------------- ### NewParser Constructor Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/json Creates a new parser for a given input. ```go func NewParser(r *parse.Input) *Parser ``` -------------------------------- ### Arg Struct and Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Represents an argument and provides methods to write it as JavaScript or convert it to a string. ```go func (n Arg) JS(w io.Writer) ``` ```go func (n Arg) String() string ``` -------------------------------- ### Printable Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Returns a printable string representation of a rune. ```go func Printable(r rune) string ``` -------------------------------- ### BinaryReader Constructors Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Various constructors for creating a BinaryReader from different sources. ```go func NewBinaryReader(f IBinaryReader) *BinaryReader ``` ```go func NewBinaryReaderBytes(data []byte) *BinaryReader ``` ```go func NewBinaryReaderFile(f *os.File) (*BinaryReader, error) ``` ```go func NewBinaryReaderMmap(filename string) (*BinaryReader, error) ``` ```go func NewBinaryReaderPath(filename string) (*BinaryReader, error) ``` ```go func NewBinaryReaderReader(r io.Reader, n int64) (*BinaryReader, error) ``` -------------------------------- ### BinaryReader Clone Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Creates a copy of the BinaryReader. ```go func (r *BinaryReader) Clone() *BinaryReader ``` -------------------------------- ### List of CSS grammar units Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/css Reference list of all grammar units returned by the parser. ```go ErrorGrammar AtRuleGrammar EndAtRuleGrammar RulesetGrammar EndRulesetGrammar DeclarationGrammar TokenGrammar ``` -------------------------------- ### NewStreamLexer Constructor Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/buffer Returns a new StreamLexer for a given io.Reader with a 4kB estimated buffer size. ```go func NewStreamLexer(r io.Reader) *StreamLexer ``` -------------------------------- ### Copy Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Returns a copy of the given byte slice. ```go func Copy(src []byte) (dst []byte) ``` -------------------------------- ### AST Structure and Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js The main AST structure and its serialization methods. ```go type AST struct { BlockStmt // module } ``` ```go func Parse(r *parse.Input, o Options) (*AST, error) ``` ```go func (ast AST) JS(w io.Writer) ``` ```go func (ast AST) JSON(w io.Writer) error ``` ```go func (ast AST) JSONString() (string, error) ``` ```go func (ast AST) JSString() string ``` ```go func (ast AST) String() string ``` -------------------------------- ### Available Token Types Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/html List of all possible token types returned by the lexer. ```go ErrorToken TokenType = iota // extra token when errors occur CommentToken DoctypeToken StartTagToken StartTagCloseToken StartTagVoidToken EndTagToken AttributeToken TextToken ``` -------------------------------- ### Convert Token to String Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/css Returns the string representation of a token. ```go func (t Token) String() string ``` -------------------------------- ### Import the js package Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Import statement for including the package in a Go project. ```go import "github.com/tdewolff/parse/v2/js" ``` -------------------------------- ### List of CSS tokens Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/css Reference list of all token types returned by the lexer. ```go ErrorToken // non-official token, returned when errors occur IdentToken FunctionToken // rgb( rgba( ... AtKeywordToken // @abc HashToken // #abc StringToken BadStringToken URLToken // url( BadURLToken DelimToken // any unmatched character NumberToken // 5 PercentageToken // 5% DimensionToken // 5em UnicodeRangeToken IncludeMatchToken // ~= DashMatchToken // |= PrefixMatchToken // ^= SuffixMatchToken // $= SubstringMatchToken // *= ColumnToken // || WhitespaceToken CDOToken // ColonToken SemicolonToken CommaToken BracketToken // ( ) [ ] { }, all bracket tokens use this, Data() can distinguish between the brackets CommentToken // non-official token ``` -------------------------------- ### NewStreamLexerSize Constructor Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/buffer Returns a new StreamLexer for a given io.Reader and estimated required buffer size. ```go func NewStreamLexerSize(r io.Reader, size int) *StreamLexer ``` -------------------------------- ### Mediatype Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Parses a mediatype string into its components. ```go func Mediatype(b []byte) ([]byte, map[string]string) ``` -------------------------------- ### Error Handling Utilities Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Structures and constructors for reporting parsing errors. ```go type Error struct { Message string Line int Column int Context string } ``` ```go func NewError(r io.Reader, offset int, message string, a ...interface{}) *Error ``` ```go func NewErrorLexer(l *Input, message string, a ...interface{}) *Error ``` ```go func (e *Error) Error() string ``` ```go func (e *Error) Position() (int, int, string) ``` -------------------------------- ### Writer Bytes Method Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/buffer Returns the underlying byte slice. ```go func (w *Writer) Bytes() []byte ``` -------------------------------- ### AST Interfaces Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Core interfaces for bindings, expressions, nodes, statements, and visitors. ```go type IBinding interface { INode // contains filtered or unexported methods } ``` ```go type IExpr interface { INode // contains filtered or unexported methods } ``` ```go type INode interface { String() string JS(io.Writer) } ``` ```go type IStmt interface { INode // contains filtered or unexported methods } ``` ```go type IVisitor interface { Enter(n INode) IVisitor Exit(n INode) } ``` -------------------------------- ### DoWhileStmt Structure and Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Represents a do-while iteration statement. ```go type DoWhileStmt struct { Cond IExpr Body IStmt } ``` ```go func (n DoWhileStmt) JS(w io.Writer) ``` ```go func (n DoWhileStmt) String() string ``` -------------------------------- ### Define Template Delimiters Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/html Predefined template delimiter configurations for various template engines. ```go var ASPTemplate = [2]string{"<%", "%>"} ``` ```go var EJSTemplate = [2]string{"<%", "%>"} ``` ```go var GoTemplate = [2]string{{"{{", "}}"} ``` ```go var HandlebarsTemplate = [2]string{{"{{", "}}"} ``` ```go var MustacheTemplate = [2]string{{"{{", "}}"} ``` ```go var PHPTemplate = [2]string{""} ``` -------------------------------- ### NewWriter Constructor Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/buffer Returns a new Writer for a given byte slice. ```go func NewWriter(buf []byte) *Writer ``` ```text Output: Lorem ipsum ``` -------------------------------- ### Reader Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/buffer Methods for interacting with the Reader buffer. ```go func (r *Reader) Bytes() []byte ``` ```go func (r *Reader) Len() int ``` ```go func (r *Reader) Read(b []byte) (n int, err error) ``` ```go func (r *Reader) Reset() ``` -------------------------------- ### Args Struct and Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Represents a list of arguments used in expressions. ```go type Args struct { List []Arg } ``` ```go func (n Args) JS(w io.Writer) ``` ```go func (n Args) String() string ``` -------------------------------- ### Parser Limits Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Configuration limits for nested expressions and statements. ```go var NestedExprLimit = 1000 ``` ```go var NestedStmtLimit = 1000 ``` -------------------------------- ### TryStmt methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Methods for writing or stringifying a try statement. ```go func (n TryStmt) JS(w io.Writer) ``` ```go func (n TryStmt) String() string ``` -------------------------------- ### json.NewParser Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/json Initializes a new JSON parser for a given input source. ```APIDOC ## func NewParser(r *parse.Input) *Parser ### Description Returns a new Parser instance initialized with the provided input source. ### Parameters - **r** (*parse.Input) - Required - The input source to be tokenized. ``` -------------------------------- ### Convert Var to string Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/js Returns the string representation of the variable. ```go func (v Var) String() string ``` -------------------------------- ### TokenType string conversion methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Methods to retrieve the byte or string representation of a token type. ```go func (tt TokenType) Bytes() []byte ``` ```go func (tt TokenType) String() string ``` -------------------------------- ### BitmapReader Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2 Methods for reading individual bits from a binary buffer. ```APIDOC ## func NewBitmapReader ### Description Returns a binary bitmap reader. ### Signature `func NewBitmapReader(buf []byte) *BitmapReader` ## func (*BitmapReader) EOF ### Description Returns if we reached the buffer's end-of-file. ### Signature `func (r *BitmapReader) EOF() bool` ## func (*BitmapReader) Pos ### Description Returns the current bit position. ### Signature `func (r *BitmapReader) Pos() uint32` ## func (*BitmapReader) Read ### Description Reads the next bit. ### Signature `func (r *BitmapReader) Read() bool` ``` -------------------------------- ### Writer Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/buffer Methods for managing the state and content of a Writer. ```go func (w *Writer) Bytes() []byte ``` ```go func (w *Writer) Close() error ``` ```go func (w *Writer) Len() int ``` ```go func (w *Writer) Reset() ``` -------------------------------- ### ImportStmt Structure Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Represents an import statement. ```go type ImportStmt struct { List []Alias Default []byte // can be nil Module []byte } ``` ```go func (n ImportStmt) JS(w io.Writer) ``` ```go func (n ImportStmt) String() string ``` -------------------------------- ### Input Buffer Management Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Buffered reader implementation for parsing input streams. ```go type Input struct { // contains filtered or unexported fields } ``` ```go func NewInput(r io.Reader) *Input ``` ```go func NewInputBytes(b []byte) *Input ``` ```go func NewInputString(s string) *Input ``` ```go func (z *Input) Bytes() []byte ``` -------------------------------- ### Define Token Types Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/xml Enumeration of possible XML token types. ```go const ( ErrorToken TokenType = iota // extra token when errors occur CommentToken DOCTYPEToken CDATAToken StartTagToken StartTagPIToken StartTagCloseToken StartTagCloseVoidToken StartTagClosePIToken EndTagToken AttributeToken TextToken ) ``` -------------------------------- ### Template Delimiter Definitions Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/html Predefined template delimiter configurations for various template engines. ```go var ASPTemplate = [2]string{"<%", "%>"} ``` ```go var EJSTemplate = [2]string{"<%", "%>"} ``` ```go var GoTemplate = [2]string{"{{", "}}"} ``` ```go var HandlebarsTemplate = [2]string{"{{", "}}"} ``` ```go var MustacheTemplate = [2]string{"{{", "}}"} ``` ```go var PHPTemplate = [2]string{""} ``` -------------------------------- ### AST Structure and Parsing Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/js Definition of the AST structure and the main Parse function. ```go type AST struct { BlockStmt // module } ``` ```go func Parse(r *parse.Input, o Options) (*AST, error) ``` -------------------------------- ### Token Types Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/html Definitions for various HTML token types. ```go type TokenType uint32 ``` ```go const ( ErrorToken TokenType = iota // extra token when errors occur CommentToken DoctypeToken StartTagToken StartTagCloseToken StartTagVoidToken EndTagToken AttributeToken TextToken SVGToken MathToken XMLToken TemplateToken ) ``` -------------------------------- ### Define identifier token constants Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Token types for identifiers and contextual keywords. ```go const ( IdentifierToken TokenType = 0x1000 + iota AsToken AsyncToken FromToken GetToken ImplementsToken InterfaceToken LetToken MetaToken OfToken PackageToken PrivateToken ProtectedToken PublicToken SetToken StaticToken TargetToken ) ``` -------------------------------- ### BinaryReader Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2 Methods for reading binary data from a buffer, including support for various integer types and io.Reader compliance. ```go func (r *BinaryReader) Close() error ``` ```go func (r *BinaryReader) Err() error ``` ```go func (r *BinaryReader) IBinaryReader() IBinaryReader ``` ```go func (r *BinaryReader) InPageCache(start, end int64) bool ``` ```go func (r *BinaryReader) Len() int64 ``` ```go func (r *BinaryReader) Pos() int64 ``` ```go func (r *BinaryReader) Read(b []byte) (int, error) ``` ```go func (r *BinaryReader) ReadAt(b []byte, off int64) (int, error) ``` ```go func (r *BinaryReader) ReadByte() (byte, error) ``` ```go func (r *BinaryReader) ReadBytes(n int64) []byte ``` ```go func (r *BinaryReader) ReadInt8() int8 ``` ```go func (r *BinaryReader) ReadInt16() int16 ``` ```go func (r *BinaryReader) ReadInt24() int32 ``` ```go func (r *BinaryReader) ReadInt32() int32 ``` ```go func (r *BinaryReader) ReadInt64() int64 ``` ```go func (r *BinaryReader) ReadString(n int64) string ``` ```go func (r *BinaryReader) ReadUint8() uint8 ``` ```go func (r *BinaryReader) ReadUint16() uint16 ``` ```go func (r *BinaryReader) ReadUint24() uint32 ``` ```go func (r *BinaryReader) ReadUint32() uint32 ``` ```go func (r *BinaryReader) ReadUint64() uint64 ``` ```go func (r *BinaryReader) Seek(off int64, whence int) (int64, error) ``` -------------------------------- ### Input Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2 Methods available on the Input struct for navigating and reading from the input stream. ```APIDOC ## func (z *Input) Offset() int Returns the current offset in the input. ## func (z *Input) Peek(pos int) byte Returns the byte at the specified position relative to the current offset. ## func (z *Input) PeekErr(pos int) error Returns an error if the byte at the specified position cannot be read. ## func (z *Input) PeekRune(pos int) (rune, int) Returns the rune and its byte length at the specified position. ## func (z *Input) Pos() int Returns the current position. ## func (z *Input) Reset() Resets the input state. ## func (z *Input) Restore() Restores the input to a previously saved state. ## func (z *Input) Rewind(pos int) Rewinds the input to the specified position. ## func (z *Input) Shift() []byte Shifts the input and returns the consumed byte slice. ## func (z *Input) Skip() Skips the current byte or character. ``` -------------------------------- ### Define standard token constants Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Basic token types including errors, whitespace, comments, and string literals. ```go const ( ErrorToken TokenType = iota // extra token when errors occur WhitespaceToken LineTerminatorToken // \r \n \r\n CommentToken CommentLineTerminatorToken StringToken TemplateToken TemplateStartToken TemplateMiddleToken TemplateEndToken RegExpToken PrivateIdentifierToken ) ``` -------------------------------- ### Lexer peeking methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/buffer Methods to inspect upcoming bytes or runes without advancing the position. ```go func (z *Lexer) Peek(pos int) byte ``` ```go func (z *Lexer) PeekErr(pos int) error ``` ```go func (z *Lexer) PeekRune(pos int) (rune, int) ``` -------------------------------- ### Position Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Returns the line and column number for a specific file offset. ```go func Position(r io.Reader, offset int) (line, col int, context string) ``` -------------------------------- ### StreamLexer Definition and Initialization Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/buffer Defines the StreamLexer structure and constructors for creating instances from an io.Reader. ```go type StreamLexer struct { // contains filtered or unexported fields } ``` ```go func NewStreamLexer(r io.Reader) *StreamLexer ``` ```go func NewStreamLexerSize(r io.Reader, size int) *StreamLexer ``` -------------------------------- ### XML Token Types Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/xml List of all available token types returned by the lexer. ```go ErrorToken TokenType = iota // extra token when errors occur CommentToken CDATAToken StartTagToken StartTagCloseToken StartTagCloseVoidToken StartTagClosePIToken EndTagToken AttributeToken TextToken ``` -------------------------------- ### BindingObject Struct and Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Represents an object binding pattern. ```go type BindingObject struct { List []BindingObjectItem Rest *Var // can be nil } ``` ```go func (n BindingObject) JS(w io.Writer) ``` ```go func (n BindingObject) String() string ``` -------------------------------- ### Parser Next Token Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/json Retrieves the next grammar token from the input. ```go func (p *Parser) Next() (GrammarType, []byte) ``` -------------------------------- ### Define Hash Constants Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/html Perfect hash constants for common HTML tags. ```go const ( Iframe Hash = 0x6 // iframe Math Hash = 0x604 // math Plaintext Hash = 0x2109 // plaintext Script Hash = 0xa06 // script Style Hash = 0x1405 // style Svg Hash = 0x1903 // svg Textarea Hash = 0x2608 // textarea Title Hash = 0xf05 // title Xml Hash = 0x1c03 // xml Xmp Hash = 0x1f03 // xmp ) ``` -------------------------------- ### func NewParser Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/css Initializes a new CSS Parser for parsing input. ```APIDOC ## func NewParser(r *parse.Input, isInline bool) *Parser ### Description Returns a new CSS parser from an input reader. The isInline parameter specifies whether the content is an inline style attribute. ### Parameters - **r** (*parse.Input) - The input source to parse - **isInline** (bool) - Whether the input is an inline style ### Returns - ***Parser** - A pointer to the initialized Parser ``` -------------------------------- ### html.NewLexer Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/html Initializes a new HTML lexer instance using an input source. ```APIDOC ## html.NewLexer(r *parse.Input) ### Description Initializes a new Lexer instance to tokenize HTML content from the provided input. ### Parameters - **r** (*parse.Input) - Required - The input source to be tokenized. ### Returns - **l** (*html.Lexer) - The initialized lexer instance. ``` -------------------------------- ### Comment Structure and Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Represents a comment block or line. ```go type Comment struct { Value []byte } ``` ```go func (n Comment) JS(w io.Writer) ``` ```go func (n Comment) String() string ``` -------------------------------- ### AST Serialization Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/js Methods for converting AST to JavaScript or JSON strings. ```go func (ast AST) JS(w io.Writer) ``` ```go func (ast AST) JSON(w io.Writer) error ``` ```go func (ast AST) JSONString() (string, error) ``` ```go func (ast AST) JSString() string ``` ```go func (ast AST) String() string ``` -------------------------------- ### Parser and State API Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/json Core methods for interacting with the Parser and the State enumeration. ```go func (gt GrammarType) String() string ``` ```go type Parser struct { // contains filtered or unexported fields } ``` ```go func NewParser(r *parse.Input) *Parser ``` ```go {"key":5} ``` ```go func (p *Parser) Err() error ``` ```go func (p *Parser) Next() (GrammarType, []byte) ``` ```go func (p *Parser) State() State ``` ```go type State uint32 ``` ```go const ( ValueState State = iota // extra token when errors occur ObjectKeyState ObjectValueState ArrayState ) ``` ```go func (state State) String() string ``` -------------------------------- ### Convert WithStmt to string Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/js Returns the string representation of the with statement. ```go func (n WithStmt) String() string ``` -------------------------------- ### Define PageSize constant Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Defines the default page size used for input processing. ```go const PageSize = 4096 ``` -------------------------------- ### BitmapReader Operations Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Structures and methods for reading binary bitmaps. ```go type BitmapReader struct { // contains filtered or unexported fields } ``` ```go func NewBitmapReader(buf []byte) *BitmapReader ``` ```go func (r *BitmapReader) EOF() bool ``` ```go func (r *BitmapReader) Pos() uint32 ``` ```go func (r *BitmapReader) Read() bool ``` -------------------------------- ### Writer Close Method Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/buffer Returns the last error. ```go func (w *Writer) Close() error ``` -------------------------------- ### Lexer buffer access methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/buffer Methods to retrieve the underlying buffer, current lexeme, or error status. ```go func (z *Lexer) Bytes() []byte ``` ```go func (z *Lexer) Err() error ``` ```go func (z *Lexer) Lexeme() []byte ``` -------------------------------- ### Input Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Methods available on the Input struct for buffer manipulation and inspection. ```APIDOC ## func (*Input) Err() Err returns the error returned from io.Input or io.EOF when the end has been reached. ## func (*Input) Len() Len returns the length of the underlying buffer. ## func (*Input) Lexeme() Lexeme returns the bytes of the current selection. ## func (*Input) Move(n int) Move advances the position by n. ## func (*Input) MoveRune() MoveRune advances the position by the length of the current rune. ## func (*Input) Offset() Offset returns the character position in the buffer. ## func (*Input) Peek(pos int) byte Peek returns the ith byte relative to the end position. Peek returns 0 when an error has occurred. ## func (*Input) PeekErr(pos int) error PeekErr returns the error at position pos. ## func (*Input) PeekRune(pos int) (rune, int) PeekRune returns the rune and rune length of the ith byte relative to the end position. ## func (*Input) Pos() int Pos returns a mark to which can be rewinded. ## func (*Input) Reset() Reset resets position to the underlying buffer. ## func (*Input) Restore() Restore restores the replaced byte past the end of the buffer by NULL. ## func (*Input) Rewind(pos int) Rewind rewinds the position to the given position. ## func (*Input) Shift() []byte Shift returns the bytes of the current selection and collapses the position to the end of the selection. ## func (*Input) Skip() Skip collapses the position to the end of the selection. ``` -------------------------------- ### Hash Type and Constants Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/html Definitions for perfect hashes used to identify specific HTML tags. ```go type Hash uint32 ``` ```go const ( Iframe Hash = 0x6 // iframe Math Hash = 0x604 // math Plaintext Hash = 0x2109 // plaintext Script Hash = 0xa06 // script Style Hash = 0x1405 // style Svg Hash = 0x1903 // svg Textarea Hash = 0x2608 // textarea Title Hash = 0xf05 // title Xml Hash = 0x1c03 // xml Xmp Hash = 0x1f03 // xmp ) ``` -------------------------------- ### Move Position by Rune Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Advances the position by the length of the current rune. ```go func (z *Input) MoveRune() ``` -------------------------------- ### String representation of TemplatePart Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Returns the string representation of the template part. ```go func (n TemplatePart) String() string ``` -------------------------------- ### html.NewLexer Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/html Initializes a new HTML lexer using an input source. ```APIDOC ## html.NewLexer(r *parse.Input) ### Description Initializes a new Lexer instance to tokenize HTML content from the provided input. ### Parameters - **r** (*parse.Input) - Required - The input source to be tokenized. ``` -------------------------------- ### Write Return Statement to Writer Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Writes the JavaScript representation of a return statement to an io.Writer. ```go func (n ReturnStmt) JS(w io.Writer) ``` -------------------------------- ### BinaryWriter Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Methods for writing various data types to a BinaryWriter buffer. ```go func (w *BinaryWriter) WriteString(v string) ``` ```go func (w *BinaryWriter) WriteUint8(v uint8) ``` ```go func (w *BinaryWriter) WriteUint16(v uint16) ``` ```go func (w *BinaryWriter) WriteUint24(v uint32) ``` ```go func (w *BinaryWriter) WriteUint32(v uint32) ``` ```go func (w *BinaryWriter) WriteUint64(v uint64) ``` -------------------------------- ### Write Parameters to Writer Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Writes the JavaScript representation of parameters to an io.Writer. ```go func (n Params) JS(w io.Writer) ``` -------------------------------- ### BinaryWriter Structure and Methods Source: https://pkg.go.dev/github.com/tdewolff/parse/v2 Structure and methods for writing big-endian binary data to a buffer. ```go type BinaryWriter struct { ByteOrder binary.AppendByteOrder // contains filtered or unexported fields } ``` ```go func NewBinaryWriter(buf []byte) *BinaryWriter ``` ```go func (w *BinaryWriter) Bytes() []byte ``` ```go func (w *BinaryWriter) Len() int64 ``` ```go func (w *BinaryWriter) Write(b []byte) (int, error) ``` ```go func (w *BinaryWriter) WriteByte(v byte) ``` ```go func (w *BinaryWriter) WriteBytes(v []byte) ``` ```go func (w *BinaryWriter) WriteInt8(v int8) ``` ```go func (w *BinaryWriter) WriteInt16(v int16) ``` ```go func (w *BinaryWriter) WriteInt24(v int32) ``` ```go func (w *BinaryWriter) WriteInt32(v int32) ``` ```go func (w *BinaryWriter) WriteInt64(v int64) ``` -------------------------------- ### String representation of Scope Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Returns the string representation of the scope. ```go func (s Scope) String() string ``` -------------------------------- ### Reader Len Method Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/buffer Returns the length of the buffer. ```go func (r *Reader) Len() int ``` -------------------------------- ### Lexer Next Token Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/xml Advances the lexer to the next token. ```go func (l *Lexer) Next() (TokenType, []byte) ``` -------------------------------- ### Input Buffering Source: https://pkg.go.dev/github.com/tdewolff/parse/v2 Methods for creating and managing buffered input streams. ```APIDOC ## func NewInput ### Description Returns a new Input for a given io.Reader. ### Signature `func NewInput(r io.Reader) *Input` ## func NewInputBytes ### Description Returns a new Input for a given byte slice. ### Signature `func NewInputBytes(b []byte) *Input` ## func NewInputString ### Description Returns a new Input for a given string. ### Signature `func NewInputString(s string) *Input` ## func (*Input) Bytes ### Description Returns the underlying buffer. ### Signature `func (z *Input) Bytes() []byte` ``` -------------------------------- ### Indenter Operations Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13 Utilities for managing indentation during writing. ```go type Indenter struct { io.Writer // contains filtered or unexported fields } ``` ```go func NewIndenter(w io.Writer, n int) Indenter ``` ```go func (Indenter) Indent() int ``` ```go func (Indenter) Write(b []byte) (int, error) ``` -------------------------------- ### ImportMetaExpr Structure Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Represents an import meta property. ```go type ImportMetaExpr struct{} ``` ```go func (n ImportMetaExpr) JS(w io.Writer) ``` ```go func (n ImportMetaExpr) String() string ``` -------------------------------- ### Write Property Name to Writer Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Writes the JavaScript representation of a property name to an io.Writer. ```go func (n PropertyName) JS(w io.Writer) ``` -------------------------------- ### js.NewParser Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/js Parses JavaScript input and returns an abstract syntax tree (AST). ```APIDOC ## js.NewParser ### Description Parses a string or input source and returns an abstract syntax tree (AST) representing the JavaScript code. ### Usage ```go ast, err := js.NewParser(parse.NewInputString("if (state == 5) { console.log('In state five'); }")) ``` ``` -------------------------------- ### js.NewParser Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/js Parses JavaScript input and returns an abstract syntax tree (AST). ```APIDOC ## js.NewParser(input) ### Description Parses the provided input and returns an abstract syntax tree (AST) representing the JavaScript code. ### Usage ```go ast, err := js.NewParser(parse.NewInputString("if (state == 5) { console.log('In state five'); }")) ``` ``` -------------------------------- ### Define Hash Constants Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/css Defines perfect hashes for common CSS identifiers. ```go type Hash uint32 const ( Document Hash = 0x8 // document Font_Face Hash = 0x809 // font-face Keyframes Hash = 0x1109 // keyframes Layer Hash = 0x2105 // layer Media Hash = 0x2605 // media Page Hash = 0x2b04 // page Supports Hash = 0x1908 // supports ) ``` -------------------------------- ### Switch Statement Representation Source: https://pkg.go.dev/github.com/tdewolff/parse/v2/js Structure and methods for handling JavaScript switch statements. ```go type SwitchStmt struct { Init IExpr List []CaseClause Scope } ``` ```go func (n SwitchStmt) JS(w io.Writer) ``` ```go func (n SwitchStmt) String() string ``` -------------------------------- ### Retrieve Parser Values Source: https://pkg.go.dev/github.com/tdewolff/parse/v2%40v2.8.13/css Returns a slice of tokens for the last grammar, applicable to at-rules, rulesets, and declarations. ```go func (p *Parser) Values() []Token ```