New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect/unwanted behavior on invalid string inputs (Mantis 4885) #68

Open
damiendoligez opened this Issue Jan 9, 2015 · 0 comments

Comments

Projects
None yet
1 participant
@damiendoligez
Member

damiendoligez commented Jan 9, 2015

Transferred from http://caml.inria.fr/mantis/view.php?id=4885
Feel free to reopen the Mantis PR if you need to modify the OCaml lexer to deal with this.

There are two unwanted behaviors on the treatment of string literals in camlp4.

(1) Incomplete decimal/hexadecimal character escapes cause unspecified errors.

$ echo '"\0"' | camlp4o -impl /dev/stdin
Warning: File "/dev/stdin", line 1, characters 1-3: Illegal backslash escape in string or character (0)
Parse error: 
$

(2) Other unharmful character escapes which are undefined in Caml syntax was useful for camlp4 extensions until 3.09, but now it produces a warning even when these are handled later by syntax extensions. Several useful syntax extensions depend on 3.09 behavior. To achieve both compatibility and safety, such checking is better to be implemented in parser (or output) instead of in lexer. The attached patch (against 3.12.0+dev5) implements the string constant validity checking in the parser stage, as well as fixing problem (1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment