From 9b36fa51b9416607f51d30ef202e6f0c9feccfb1 Mon Sep 17 00:00:00 2001 From: Anton Zavodchikov Date: Sun, 31 Mar 2024 14:50:52 -0700 Subject: [PATCH] feat(comments): improve comment versatility This commit enhances the versatility of comments in the codebase, providing clearer and more informative documentation for developers via ability to include direct urls. --- src/cmd/compile/internal/syntax/scanner.go | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/cmd/compile/internal/syntax/scanner.go b/src/cmd/compile/internal/syntax/scanner.go index 807d8383866..24ca4f50eab 100644 --- a/src/cmd/compile/internal/syntax/scanner.go +++ b/src/cmd/compile/internal/syntax/scanner.go @@ -101,6 +101,29 @@ redo: s.line, s.col = s.pos() s.blank = s.line > startLine || startCol == colbase s.start() + + if isLetter(s.ch) { + s.nextch() + // accelerate common case (7bit ASCII) + for isLetter(s.ch) || isDecimal(s.ch) { + s.nextch() + } + + // protocol case (ex. http:// or https://) + if s.ch == ':' { + s.nextch() + if s.ch == '/' { + s.nextch() + if s.ch == '/' { + s.nextch() + s.lineComment() + goto redo + } + } + } + s.rewind() + } + if isLetter(s.ch) || s.ch >= utf8.RuneSelf && s.atIdentChar(true) { s.nextch() s.ident()