예제 #1
0
파일: parser.go 프로젝트: postfix/go_parser
// New returns a new Parser object
func New(startState StateFn, lex lexer.Lexer, channelCap int) Parser {
	p := &parser{
		lex:      lex,
		tokens:   queue.New(4), // 4 is just a nice number that seems appropriate
		pos:      0,
		sequence: 0,
		eofToken: nil,
		eof:      false,
		state:    startState,
		chn:      make(chan interface{}, channelCap),
	}
	return p
}
예제 #2
0
파일: lexer.go 프로젝트: fd0/go_lexer
// New returns a new Lexer object
func New(startState StateFn, reader io.Reader, readerBufLen int, channelCap int) Lexer {
	r := bufio.NewReaderSize(reader, readerBufLen)
	l := &lexer{
		reader:   r,
		bufLen:   readerBufLen,
		runes:    queue.New(4), // 4 is just a nice number that seems appropriate
		state:    startState,
		tokens:   make(chan *Token, channelCap),
		line:     1,
		column:   0,
		eofToken: nil,
		eof:      false,
	}
	l.updatePeekBytes()
	return l
}