Skip to content

Conversation

@scjung
Copy link
Contributor

@scjung scjung commented Mar 31, 2023

This PR fixes ocamllex to accept line-directives ended with CR/LF.

Use case: I'm building a tokenizer from CPPO-preprocessed source. On Windows, CPPO (v1.6.9) converts all LF to CF/LF. Because of that, ocamllex syntax errors occur on every line-directives generated by CPPO.

Looking at lex/lexer.mll and history, It seems that all CRs are ignored except for those at the end of line-directives.

@scjung scjung force-pushed the ocamllex-crlf-line-directive branch from a001cf1 to 1767878 Compare March 31, 2023 08:28
Copy link
Contributor

@nojb nojb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR looks reasonable to me. I left a suggestion.

@hhugo
Copy link
Contributor

hhugo commented Mar 31, 2023

The change looks good to me. I think you should also open an issue on cppo. I think cppo should just preserve existing line ending

@nojb
Copy link
Contributor

nojb commented Mar 31, 2023

Also, a Changes entry is in order.

@scjung scjung force-pushed the ocamllex-crlf-line-directive branch from 1767878 to 17e716d Compare March 31, 2023 12:17
@scjung scjung force-pushed the ocamllex-crlf-line-directive branch 2 times, most recently from 13b7e08 to ea592c2 Compare April 3, 2023 01:08
@damiendoligez
Copy link
Member

CI fails because checking out crlf_line_directive.mll changes your CR-CR-LF line into a CR-LF in the test file and check-labelled-interfaces.sh then sees a diff that shouldn't be there. You probably need to declare the file binary in .gitattributes.

Copy link
Member

@damiendoligez damiendoligez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Fix the CI problem and we can merge.

| "#" [' ' '\t']* (['0'-'9']+ as num) [' ' '\t']*
('\"' ([^ '\010' '\013' '\"']* as name) '\"')?
[^ '\010' '\013']* '\010'
[^ '\010' '\013']* '\013'* '\010'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also do it this way:

Suggested change
[^ '\010' '\013']* '\013'* '\010'
[^ '\010' ]* '\010'

@gasche
Copy link
Member

gasche commented Apr 7, 2023

The CI is configured to complain about cr/lf at the end of files, and git does not handle it well either. The simplest route to merge this PR would be to simply remove test. @scjung, could you do this?

@gasche gasche linked an issue Apr 7, 2023 that may be closed by this pull request
@gasche gasche added the submitter-action-needed This PR is waiting for an action of its submitter. label Apr 7, 2023
@gasche gasche assigned damiendoligez and unassigned scjung Apr 7, 2023
@gasche gasche added the merge-me label Apr 7, 2023
@hhugo
Copy link
Contributor

hhugo commented Apr 7, 2023

The change looks good to me. I think you should also open an issue on cppo. I think cppo should just preserve existing line ending

Has this been reported on the cppo project ?

@scjung scjung force-pushed the ocamllex-crlf-line-directive branch from ea592c2 to f891fd9 Compare April 26, 2023 08:57
@scjung
Copy link
Contributor Author

scjung commented Apr 26, 2023

The CI is configured to complain about cr/lf at the end of files, and git does not handle it well either. The simplest route to merge this PR would be to simply remove test. @scjung, could you do this?

Sorry for late reply. I removed the test.

@gasche gasche merged commit 8c10133 into ocaml:trunk Apr 26, 2023
ncik-roberts pushed a commit to ncik-roberts/ocaml that referenced this pull request Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-me submitter-action-needed This PR is waiting for an action of its submitter.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ocamllex should accept #line-directive ended with CR/LF

5 participants