jhjourdan / C11parser

A correct C89/C90/C99/C11/C18 parser written using Menhir and OCaml
Other
192 stars 17 forks source link

after a single line comment, we are at the beginning of a line #18

Closed let-def closed 5 years ago

let-def commented 5 years ago

This is a minor bug: the lexer misses the fact that after a single line comment, we are at the beginning of a line. Therefore # directives are missed after a single line comment.

One could argue that a proper preprocessor would have removed comments, and therefore either you have comments or you have line directives... But the lexer already tries to handle some of these situations, so this is a "best effort" attempt.

Here is a sample file that fails with "Lexer error" without the patch:

// Test
# 3 "test.c"
int test;
jhjourdan commented 5 years ago

Thanks !