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

Strange camlp4 behavior in the toplevel. #5090

Closed
vicuna opened this issue Jul 1, 2010 · 11 comments
Closed

Strange camlp4 behavior in the toplevel. #5090

vicuna opened this issue Jul 1, 2010 · 11 comments

Comments

@vicuna
Copy link

vicuna commented Jul 1, 2010

Original bug ID: 5090
Reporter: @diml
Assigned to: @bobzhang
Status: closed (set by @diml on 2016-12-07T17:27:31Z)
Resolution: reopened
Priority: normal
Severity: minor
Version: 3.12.0+beta1 or 3.12.0+rc1
Target version: later
Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues
Tags: patch
Related to: #5142
Monitored by: profjim dario @ygrek @glondu matt @hcarty

Bug description

Camlp4 seems to not recognize correctly phrase in the toplevel with ocaml 3.12. For example:

#load "dynlink.cma";;

#load "camlp4o.cma";;

1;;

(* Nothing happens here *)
2;;

  • : int = 1

File attachments

@vicuna
Copy link
Author

vicuna commented Jul 9, 2010

Comment author: Yoric

Can't remember the detail but there's a workaround in Batteries for this kind of thing. Essentially, when Camlp4 is involved, loading is order dependent.

@vicuna
Copy link
Author

vicuna commented Jul 23, 2010

Comment author: @hcarty

This error still exists in 3.12.0+rc1

It doesn't seem to be related to any work-around in Batteries, as it occurs in a bare toplevel + camlp4 as well as with toplevel + camlp4 + Batteries + extensions.

@vicuna
Copy link
Author

vicuna commented Jul 29, 2010

Comment author: @damiendoligez

Nicolas and I are working on this. It will be fixed before we release 3.12.0.

@vicuna
Copy link
Author

vicuna commented Jul 30, 2010

Comment author: @damiendoligez

To everyone monitoring this issue:

I've made a temporary fix for this problem, but my fix is likely to impact locations (and error reporting) in all camlp4 parsers. I would appreciate if some of you could check out "version/3.12" in revision 10639 and test it, particularly with respect to error reports inside and outside quotations, with the default parsers or your own parsers. I've done some light testing, but I'm not a heavy camlp4 user, so I may have missed some major problem.

If you could do this within a few days, that would be good. Please report here or directly to damien.doligez@inria.fr.

@vicuna
Copy link
Author

vicuna commented Aug 2, 2010

Comment author: @diml

I tried with my projects using camlp4 and it seems to be OK.

@vicuna
Copy link
Author

vicuna commented Apr 7, 2011

Comment author: till

This actually caused #5142. #5142 seems fixed in the SVN branch of 3.12.

@vicuna
Copy link
Author

vicuna commented Dec 6, 2012

Comment author: @bobzhang

This fix is buggy, the token stream will be duplicated when do the backtracking, that's to say it will not work well with TRY

@vicuna
Copy link
Author

vicuna commented Dec 6, 2012

Comment author: @bobzhang

here we only need to make sure 'get_prev_loc' won't peek, I changed stream to store the last junked item, this fix will work well

@vicuna
Copy link
Author

vicuna commented Dec 6, 2012

Comment author: @bobzhang

will anyone take a look at my patch on stream?
I tested on my branch of p4, it works pretty well,

let get_prev_loc strm =
match XStream.get_last strm with
[Some (,{cur_loc=l;}) -> l
|None -> begin
FanLoc.ghost end];

The data type of token stream can also be simplified, since there's no need to keep the previous token any more

@vicuna
Copy link
Author

vicuna commented Jul 7, 2013

Comment author: @bobzhang

@doligez, what do you think my suggestion above, I would commit a cleaner fix next weekend if you agree. Thanks

@vicuna
Copy link
Author

vicuna commented Dec 7, 2016

Comment author: @diml

Camlp4 is now a separate project. Please re-open a ticket on github [1] if you are still interested in seeing the original issue fixed.

[1] https://github.com/ocaml/camlp4/issues

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

1 participant