From 843107902515c93e1507fabb1a47db66ef5a167d Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Thu, 21 Jul 2016 22:45:35 +0100 Subject: [PATCH] Enable comments in SQL code --- sql/parser.go | 8 ++++++-- sql/scanner.go | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/sql/parser.go b/sql/parser.go index ccc76b0c..7c6aa6a3 100644 --- a/sql/parser.go +++ b/sql/parser.go @@ -196,8 +196,12 @@ func (p *Parser) unscan() { p.buf.n = 1 } // scanIgnoreWhitespace scans the next non-whitespace token. func (p *Parser) scanIgnoreWhitespace() (tok Token, lit string) { tok, lit = p.scan() - if tok == WS { - tok, lit = p.scan() + for { + if tok == WS { + tok, lit = p.scan() + } else { + break + } } return } diff --git a/sql/scanner.go b/sql/scanner.go index 93d77b0e..3232512d 100644 --- a/sql/scanner.go +++ b/sql/scanner.go @@ -106,6 +106,14 @@ func (s *Scanner) Scan() (tok Token, lit string) { case '-': if chn := s.read(); chn == '>' { return OEDGE, "->" + case '/': + chn := s.next() + switch { + case chn == '*': + return s.scanCommentMultiple(ch) + default: + s.unread() + return s.scanRegexp(ch) } s.unread() if chn := s.read(); chn == '=' {