Documentation
¶
Index ¶
- Variables
- func TokenIsBlockStart(t token.Token) bool
- func TokenIsDashndashdigitIdent(t token.Token) bool
- func TokenIsInteger(t token.Token) bool
- func TokenIsNDimension(t token.Token) bool
- func TokenIsNdashdigitDimension(t token.Token) bool
- func TokenIsNdashdigitIdent(t token.Token) bool
- func TokenIsSignedInteger(t token.Token) bool
- func TokenIsSignlessInteger(t token.Token) bool
- type Parser
- func (p *Parser) ConsumeBlock(k *tokenizer.Tokenizer, start token.Token) item.Block
- func (p *Parser) ConsumeComponentValue(k *tokenizer.Tokenizer) item.ComponentValue
- func (p *Parser) ConsumeFunction(k *tokenizer.Tokenizer, name token.Token) item.Function
- func (p *Parser) Errors() []error
- func (p *Parser) Tokenizer() *tokenizer.Tokenizer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrUnexpectedEOF = fmt.Errorf("unexpected end of file")
)
Functions ¶
func TokenIsBlockStart ¶
TokenIsBlockStart returns true for a <(-token>, <{-token> or <[-token>.
func TokenIsDashndashdigitIdent ¶
TokenIsDashndashdigitIdent returns true for a token that is a <dashndashdigit-ident>: an <ident-token> whose value is an ASCII case-insensitive match for "-n-*", where "*" is a series of one or more digits.
func TokenIsInteger ¶
TokenIsInteger returns true for a token that is an <integer>: a <number-token> with its type flag set to "integer".
func TokenIsNDimension ¶
TokenIsNDimension returns true for a token that is a <n-dimension>: a <dimension-token> with its type flag set to "integer", and a unit that is an ASCII case-insensitive match for "n".
func TokenIsNdashdigitDimension ¶
TokenIsNdashdigitDimension returns true for a token that is a <ndashdigit-dimension>: a <dimension-token> with its type flag set to "integer", and a unit that is an ASCII case-insensitive match for "n-*", where "*" is a series of one or more digits.
func TokenIsNdashdigitIdent ¶
TokenIsNdashdigitIdent returns true for a token that is a <ndashdigit-ident>: an <ident-token> whose value is an ASCII case-insensitive match for "n-*", where "*" is a series of one or more digits.
func TokenIsSignedInteger ¶
TokenIsSignedInteger returns true for a token that is a <signed-integer>: a <number-token> with its type flag set to "integer", and whose representation starts with "+" or "-".
func TokenIsSignlessInteger ¶
TokenIsSignlessInteger returns true for a token that is a <signless-integer>: a <number-token> with its type flag set to "integer", and whose representation starts with a digit.
Types ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Example ¶
package main import ( "fmt" "strings" "github.com/tawesoft/golib/v2/css/internal/parser" "github.com/tawesoft/golib/v2/css/tokenizer/token" ) func main() { str := `rgb(128, 64, 64)` p := parser.New(strings.NewReader(str)) k := p.Tokenizer() for { cv := p.ConsumeComponentValue(k) if cv.IsPreservedToken(token.EOF()) { break } fmt.Println(cv) } /* if len(t.Errors()) > 0 { fmt.Printf("%v\n", t.Errors()) } */ }
Output: <ComponentValue/Function{Name: "rgb", Value: [<ComponentValue:<number-token>{type: "integer", value: 128.000000, repr: "128"}> <ComponentValue:<comma-token>> <ComponentValue:<whitespace-token>> <ComponentValue:<number-token>{type: "integer", value: 64.000000, repr: "64"}> <ComponentValue:<comma-token>> <ComponentValue:<whitespace-token>> <ComponentValue:<number-token>{type: "integer", value: 64.000000, repr: "64"}>]}>
func (*Parser) ConsumeBlock ¶
ConsumeBlock consumes a simple block. Note that this algorithm assumes that the current input token has already been checked to be an <{-token>, <[-token>, or <(-token>.
func (*Parser) ConsumeComponentValue ¶
func (p *Parser) ConsumeComponentValue(k *tokenizer.Tokenizer) item.ComponentValue
func (*Parser) ConsumeFunction ¶
ConsumeFunction consumes a function. Note: This algorithm assumes that the current input token has already been checked to be a <function-token>.