Skip to content
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

Camlp4's default lexer fails on negative numbers #4006

Closed
vicuna opened this issue Apr 16, 2006 · 3 comments
Closed

Camlp4's default lexer fails on negative numbers #4006

vicuna opened this issue Apr 16, 2006 · 3 comments

Comments

@vicuna
Copy link

vicuna commented Apr 16, 2006

Original bug ID: 4006
Reporter: Pasinelli
Status: confirmed (set by @damiendoligez on 2012-04-10T15:48:01Z)
Resolution: open
Priority: normal
Severity: feature
Version: 3.09.2
Category: documentation
Monitored by: ertai

Bug description

I put here this message for I wasted hours in understandig why my code did not work. This is due to a lack of information provided in Camlp4's Reference Manual and Tutorial, although these ones are generally speaking very usefull.

The INT and FLOAT statements only work with positive numbers : this might be trivial if you have a look to Camlp4's source code, but it is not "natural" at all.

I have put down a whole session under Solaris 9, running the 3.06 version, but it is reproductible with any version up to 3.09, I guess, for the source code I examined was the one of the 3.09 version.

ocaml
Objective Caml version 3.06

#load "camlp4o.cma";;

    Camlp4 Parsing version 3.06

#load "pa_extend.cmo";;

let gram = Grammar.gcreate (Plexer.gmake ());;

val gram : Grammar.g =

let flottant = Grammar.Entry.create gram "flottant";;

val flottant : '_a Grammar.Entry.e =

let entier = Grammar.Entry.create gram "entier";;

val entier : '_a Grammar.Entry.e =

EXTEND

      flottant :
      [
              [ z = FLOAT -> print_endline z ]
      ]
      ;

      entier :
      [
              [ e = INT -> print_endline e ]
      ]
      ;

END
;;

  • : unit = ()

let apply_flottant s = Grammar.Entry.parse flottant (Stream.of_string s);;

val apply_flottant : string -> unit =

let apply_entier s = Grammar.Entry.parse entier (Stream.of_string s);;

val apply_entier : string -> unit =

apply_flottant "-3.5676876";;

Exception:
Stdpp.Exc_located ((0, 1), Stream.Error "illegal begin of flottant").

apply_entier "-586689";;

Exception:
Stdpp.Exc_located ((0, 1), Stream.Error "illegal begin of entier").

apply_flottant "8.7697";;

8.7697

  • : unit = ()

apply_entier "65765";;

65765

  • : unit = ()

#quit;;

Additional information

When you have -3.5676876 there is two tokens, that's all.
The camlp4 doc needs an update but that's not the topic here.

@vicuna
Copy link
Author

vicuna commented Sep 5, 2006

Comment author: Pasinelli

Before I put the issue here, I sent en e-mail to the OCaml team. I had no answer at all and that is why I decided to create an issue here in order to warn people who had experienced the same trouble.

I am not saying it is a bug; I am not saying it is an error either, just an odd feature that I think would deserve to be documented.

When I posted the message, I saw the "OCaml documentation" item in the list of categories in which to create the issue, so I thought it REALLY was the right place.

Excuse my ignorance in knowing how to interpret english statements.

@vicuna
Copy link
Author

vicuna commented Apr 10, 2012

Comment author: @damiendoligez

We need to make sure that the documentation explains the behaviour clearly and correctly.

@mshinwell
Copy link
Contributor

camlp4 was evicted from the distribution some time ago.

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

No branches or pull requests

2 participants