Switch the comment syntax from ; to // comments as discussed on Friday. There
is no strong reason to prefer one or the other, but // is nice for consistency
given the rest of the compiler is written in C++.
PiperOrigin-RevId: 204628476
diff --git a/lib/Parser/Lexer.cpp b/lib/Parser/Lexer.cpp
index ffc12c8..91596d3 100644
--- a/lib/Parser/Lexer.cpp
+++ b/lib/Parser/Lexer.cpp
@@ -100,7 +100,11 @@
return formToken(Token::question, tokStart);
- case ';': return lexComment();
+ case '/':
+ if (*curPtr == '/')
+ return lexComment();
+ return emitError(tokStart, "unexpected character");
+
case '@': return lexAtIdentifier(tokStart);
case '#':
LLVM_FALLTHROUGH;
@@ -119,6 +123,10 @@
/// TODO: add a regex for comments here and to the spec.
///
Token Lexer::lexComment() {
+ // Advance over the second '/' in a '//' comment.
+ assert(*curPtr == '/');
+ ++curPtr;
+
while (true) {
switch (*curPtr++) {
case '\n':