Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000222OCamlOCaml generalpublic2000-11-17 10:382000-11-26 19:59
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000222: Parser bug? strange requirement for ;;
DescriptionFull_Name: John Max Skaller
Version: 3.00
OS: Linux
Submission from: proxy4.syd.pacific.net.au (203.27.69.94)


The following works:
--------------------------------------------------------------
open List
;;
print_endline "x"
;;
--------------------------
Remove the first ';;' and it fails:
---------------------------
open List

print_endline "x"
;;
-----------------------------
[root@pelican] ~/links/ot>ocamlc t.ml
File "t.ml", line 3, characters 0-13:
Syntax error
---------------------------
The following is OK:
--------------------------------------
open List
let map = map;;
--------------------------------------------------
Notice that no ';;' is required after the 'open'
directive here.

My guess is that the parser, at the top level, will not
accept an expression after an 'open' directive;
but it does accept a let binding. An expression is accepted,
however, if the open directive is elided, this:
--------------------------------------------
let map = List.map in ();;
--------------------------------------------
works fine because there is no preceding 'open'.

In the failing examples shown, the parser actually reports an
error in the expression. However, in some of my production
code, it mysteriously reports an error where the missing
';;' is needed; that is, it reports an error in columns 0-1
of a blank line, where there is no text.

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0002181)
administrator (administrator)
2000-11-26 19:59

> My guess is that the parser, at the top level, will not
> accept an expression after an 'open' directive;
> but it does accept a let binding.

It's simpler than that, actually: the parser doesn't accept a
top-level expression unless preceded by ";;" or "let _ =". If
you're allergic to semicolons, you can use the latter.


> In the failing examples shown, the parser actually reports an
> error in the expression. However, in some of my production
> code, it mysteriously reports an error where the missing
> ';;' is needed; that is, it reports an error in columns 0-1
> of a blank line, where there is no text.

If you can send a piece of code exhibiting this behaviour, we'll be
happy to fix the problem and make it report the error in some sensible
place.

-- Damien

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker