|
42 | 42 | tkContinueCmd = "continue", |
43 | 43 | tkIdentVar, tkIdentVarSafe, |
44 | 44 | tkStatic, tkEcho = "echo", |
45 | | - tkComment, tkDoc, tkNil = "nil", |
| 45 | + tkComment, tkDoc, tkHtmlComment, tkNil = "nil", |
46 | 46 | tkUnknown |
47 | 47 |
|
48 | 48 | TokenTuple* = tuple |
@@ -351,7 +351,25 @@ proc nextToken*(lex: var Lexer): TokenTuple = |
351 | 351 | lex.advance() |
352 | 352 | result = initToken(lex, tkGt, line, col, pos, wsno) |
353 | 353 | of '<': |
354 | | - if lex.peek() == '=': |
| 354 | + if lex.peek() == '!' and lex.peek(2) == '-' and lex.peek(3) == '-': |
| 355 | + # HTML comment <!-- ... --> |
| 356 | + lex.advance() # < |
| 357 | + lex.advance() # ! |
| 358 | + lex.advance() # - |
| 359 | + lex.advance() # - |
| 360 | + lex.strbuf.setLen(0) |
| 361 | + while true: |
| 362 | + if lex.current == '-' and lex.peek() == '-' and lex.peek(2) == '>': |
| 363 | + lex.advance() # - |
| 364 | + lex.advance() # - |
| 365 | + lex.advance() # > |
| 366 | + break |
| 367 | + if lex.current == '\0': |
| 368 | + lex.error("EOF reached before closing --> for HTML comment") |
| 369 | + lex.strbuf.add(lex.current) |
| 370 | + lex.advance() |
| 371 | + result = initToken(lex, tkHtmlComment, move lex.strbuf, line, col, pos, wsno) |
| 372 | + elif lex.peek() == '=': |
355 | 373 | lex.advance() |
356 | 374 | lex.advance() |
357 | 375 | result = initToken(lex, tkLte, "<=", line, col, pos, wsno) |
|
0 commit comments