示例#1
0
文件: lexer.go 项目: defiant00/char
func Lex(input string) *Lexer {
	l := &Lexer{
		input:        input,
		state:        lexIndent,
		indentLevels: data.NewStack(10),
		widths:       data.NewStack(10),
		tokens:       make(chan token.Token, 10),
	}
	l.indentLevels.Push(0)
	go l.run()
	return l
}
示例#2
0
文件: lexer.go 项目: defiant00/char
func (l *Lexer) emit(t token.Type) {
	l.tokens <- token.Token{t, token.Position{l.lineCount(), l.charCount()}, l.current()}
	l.start = l.pos
	l.widths = data.NewStack(10)
}
示例#3
0
文件: lexer.go 项目: defiant00/char
func (l *lexer) emit(t tType) {
	l.tokens <- token{t, l.lineCount(), l.current()}
	l.start = l.pos
	l.widths = data.NewStack(10)
}