Skip to content

Commit c1ce7d0

Browse files
committed
add explicit unknown token error message
1 parent 60c0819 commit c1ce7d0

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/Language/SystemVerilog/Parser/Lex.x

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,8 @@ postProcess stack (Token Id_escaped str pos : ts) =
509509
where
510510
t' = Token Id_escaped str' pos
511511
str' = (++ " ") $ init str
512+
postProcess _ (Token Unknown str pos : _) =
513+
throwError $ show pos ++ ": unknown token '" ++ str ++ "'"
512514
postProcess [] (t : ts) = do
513515
ts' <- postProcess [] ts
514516
return $ t : ts'

test/error/double_backtick.sv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// pattern: Parse error: unexpected token '`'
1+
// pattern: unknown token '`'
2+
// location: double_backtick.sv:4:5
23
module top;
34
``
45
endmodule
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// pattern: Parse error
1+
// pattern: unknown token '`'
2+
// location: stray_escaped_vendor_comment.sv:4:6
23
module top;
34
/``* some awful garbage *``/
45
endmodule

0 commit comments

Comments
 (0)