|
package main
|
|
import (
"fmt"
"github.com/sunwei/gobyexample/modules/lexer"
"github.com/sunwei/gobyexample/modules/lexer/action"
)
|
Action example
|
func main() {
|
|
lex, err := action.New(
"<p><!-- HTML comment -->abc</p>\n{{.Content}}")
if err != nil {
fmt.Println(err)
return
}
|
lexer iterate
|
var tokens []lexer.Token
for {
|
reach end, analyzing done
|
token := lex.Next()
tokens = append(tokens, token)
|
|
if token.Type() == action.TokenEOF {
break
}
}
|
output tokens detail
|
for i, t := range tokens {
fmt.Println(i + 1)
fmt.Println(t.Value())
}
|
|
return
}
|