BNFC / bnfc

BNF Converter
http://bnfc.digitalgrammars.com/
586 stars 165 forks source link

comment rule only support "\n", not support "\r\n" #376

Closed hangingman closed 3 years ago

hangingman commented 3 years ago

This rule generates

comment "#" ;

$ bnfc -m -cpp_stl sample.cf

following flex file

<INITIAL>"#"[^\n]* /* skip */; /* BNFC: comment "#" */

This is not working when I tried to read windows text file. I wish comment rule was customizable to use CRLF file.

andreasabel commented 3 years ago

Maybe this would work for all end-of-line conventions:

<INITIAL>"#"[^\r\n]* /* skip */; /* BNFC: comment "#" */
andreasabel commented 3 years ago
<INITIAL>"#"[^\n]* /* skip */; /* BNFC: comment "#" */

This is not working when I tried to read windows text file.

What is going wrong, actually? In theory, this should lex # followed by arbitrary characters, including CR, stopping at LF. If the line ending is CR/LF (rather than LF on *nix), this should also work.

hangingman commented 3 years ago

@andreasabel Sorry, the issue comment was my misunderstanding (maybe mixed up other issue...) I have double-checked my EBNF generated executable on my home, CRLF is skipped and text parsed nicely.

So I will close this issue. Thanks

andreasabel commented 3 years ago

@hangingman Ok, good, that confirms my analysis!
While investigating, I found a problem in the Ocaml backend with CR characters, which I fixed (1ee2889). Good.