// LexMultiLineComment lexer func LexMultiLineComment(lexer *lex.Lexer) lex.StateFn { lexer.Step(2, lex.Ignore) for { if strings.HasPrefix(lexer.InputToEnd(), RightBracket) { lexer.Emit(TComment) return LexBegin(lexer) } lexer.Next() if lexer.IsEOF() { panic("EndOfFile") } } }
// LexSingleLineComment lexer func LexSingleLineComment(lexer *lex.Lexer) lex.StateFn { lexer.Step(2, lex.Ignore) if strings.HasPrefix(lexer.InputToEnd(), LeftBracket) { return LexMultiLineComment(lexer) } for { if strings.HasPrefix(lexer.InputToEnd(), string(lex.NewLine)) { lexer.Emit(TComment) return LexBegin(lexer) } lexer.Next() if lexer.IsEOF() { lexer.Emit(TComment) lexer.Emit(lex.TEOF) lexer.Shutdown() return nil } } }