doc.go (1104B)
1 // Copyright 2012 The Gorilla Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 /* 6 Package gorilla/css/scanner generates tokens for a CSS3 input. 7 8 It follows the CSS3 specification located at: 9 10 http://www.w3.org/TR/css3-syntax/ 11 12 To use it, create a new scanner for a given CSS string and call Next() until 13 the token returned has type TokenEOF or TokenError: 14 15 s := scanner.New(myCSS) 16 for { 17 token := s.Next() 18 if token.Type == scanner.TokenEOF || token.Type == scanner.TokenError { 19 break 20 } 21 // Do something with the token... 22 } 23 24 Following the CSS3 specification, an error can only occur when the scanner 25 finds an unclosed quote or unclosed comment. In these cases the text becomes 26 "untokenizable". Everything else is tokenizable and it is up to a parser 27 to make sense of the token stream (or ignore nonsensical token sequences). 28 29 Note: the scanner doesn't perform lexical analysis or, in other words, it 30 doesn't care about the token context. It is intended to be used by a 31 lexer or parser. 32 */ 33 package scanner