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

Wish: empty_lexbuf in Lexing #8234

Closed
vicuna opened this issue Jul 28, 2003 · 4 comments
Closed

Wish: empty_lexbuf in Lexing #8234

vicuna opened this issue Jul 28, 2003 · 4 comments

Comments

@vicuna
Copy link

vicuna commented Jul 28, 2003

Original bug ID: 1782
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Pascal Zimmer
Version: 3.07
OS: Linux
Submission from: vishnu.inria.fr (138.96.82.1)

In one of my project, I needed to empty the lexing buffer when I encountered an
error in an interactive session (in exactly the same way as OCaml does: stop
interpreting the remaining phrases when there is an error, discard what remains
and wait for new phrases).
After a few searches, I copied the empty_lexbuf function from the file
toploop.ml and it worked perfectly (this was with OCaml 3.04). I just noticed
this function didn't work anymore since 3.05... After checking, the function in
toploop.ml had been modified, and it has changed once more in 3.07beta1 !

Would it be possible to include empty_lexbuf directly in the module Lexing, so
that we do not have to bother with those modifications ? This function seems
quite useful to me in such situations.

Thanks.

@vicuna
Copy link
Author

vicuna commented Aug 11, 2003

Comment author: administrator

Full_Name: Pascal Zimmer
Version: 3.07
OS: Linux
Submission from: vishnu.inria.fr (138.96.82.1)

In one of my project, I needed to empty the lexing buffer when I encountered an
error in an interactive session (in exactly the same way as OCaml does: stop
interpreting the remaining phrases when there is an error, discard what remains
and wait for new phrases).
After a few searches, I copied the empty_lexbuf function from the file
toploop.ml and it worked perfectly (this was with OCaml 3.04). I just noticed
this function didn't work anymore since 3.05... After checking, the function in
toploop.ml had been modified, and it has changed once more in 3.07beta1 !

Would it be possible to include empty_lexbuf directly in the module Lexing, so
that we do not have to bother with those modifications ? This function seems
quite useful to me in such situations.

Thanks.

Hello, We can indeed move empty_lexbuf from toploop.ml to
lexing.ml. However this function looks very top level oriented and
seems to make sense only when the input channel is an interactive one.
Advice ?

--Luc

@vicuna
Copy link
Author

vicuna commented Aug 13, 2003

Comment author: administrator

Hello,

Would it be possible to include empty_lexbuf directly in the module Lexing,
so
that we do not have to bother with those modifications ? This function seems
quite useful to me in such situations.

I have implemented your suggestion, but I renamed the function to
Lexing.flush_input, a name that I find more descriptive.

-- Damien

@vicuna
Copy link
Author

vicuna commented Aug 18, 2003

Comment author: administrator

Full_Name: Pascal Zimmer
Version: 3.07
OS: Linux
Submission from: vishnu.inria.fr (138.96.82.1)

In one of my project, I needed to empty the lexing buffer when I encountered an
error in an interactive session (in exactly the same way as OCaml does: stop
interpreting the remaining phrases when there is an error, discard what remains
and wait for new phrases).
After a few searches, I copied the empty_lexbuf function from the file
toploop.ml and it worked perfectly (this was with OCaml 3.04). I just noticed
this function didn't work anymore since 3.05... After checking, the function in
toploop.ml had been modified, and it has changed once more in 3.07beta1 !

Would it be possible to include empty_lexbuf directly in the module Lexing, so
that we do not have to bother with those modifications ? This function seems
quite useful to me in such situations.

Thanks.

Luc Maranget wrote:

Hello, We can indeed move empty_lexbuf from toploop.ml to
lexing.ml. However this function looks very top level oriented and
seems to make sense only when the input channel is an interactive one.
Advice ?

I agree. My point was that:

  • when you program an interactive intrepreter in OCaml, you will need
    such a function, and since the type Lexing.lexbuf is not fully
    documented, it is really not obvious to write it down without looking
    either at the implementation of Lexing or at another programmer's work,
    like in toploop.ml
  • the implementation of lexbuf has changed three times during the last
    releases; in every case the function would not work anymore, and you
    would have to first find the bug, and secondly remind to look into
    toploop.ml and update the function. This is why I prefer a
    library-provided version.

Damien Doligez wrote:

I have implemented your suggestion, but I renamed the function to
Lexing.flush_input, a name that I find more descriptive.

Fine. Thanks !

Pascal

@vicuna
Copy link
Author

vicuna commented Jul 4, 2004

Comment author: administrator

Wish granted by DD 2003-08-13

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