You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 2522 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Hi everybody.
I have noticed a strange behavior in the pa_ocamllex library of CamlP4.
I was using CamlP4 as preprocessor in a .ml file to have a simple
parser. Today I needed to add a new parameter to the parsing rule and I
got this error:
Failure: this is not a constructor, it cannot be applied in a pattern
Preprocessing error
To solve the problem I changed the file into a .mll file to parse it
with ocamllex and everything worked.
Thus I have compared the source code as result of the preprocessor and
ocamllex in both cases and I found that the pa_ocamllex understands the
two arguments as one argument.
pa_ocamllex let x = 'x';;
(* no arguments )
pa_ocamllex rule foo = parse | x { Yep } | ['\000'-'\255'] { Nope };;
( just one argument )
pa_ocamllex rule fee fuz = parse | x { Yep(fuz) } | ['\000'-'\255'] { Nope };;
( two arguments *)
pa_ocamllex rule bar bee buz = parse | x { Yep(bee) } | [ '\000'-'\255' ] { Nope(buz) };;
The first rule has no parameters and it is compiled correctly.
The second one, with one argument, is working fine too.
The third one gives the problem: it is understood as a function named
bar with arguments (bee buz as ...) and (lexbuf as ..).
I am working with Ocaml 3.07+2 and CamlP4 3.07+2 on Linux.
Thanks for your attention
Luca Pascali
The text was updated successfully, but these errors were encountered:
Original bug ID: 2522
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Hi everybody.
I have noticed a strange behavior in the pa_ocamllex library of CamlP4.
I was using CamlP4 as preprocessor in a .ml file to have a simple
parser. Today I needed to add a new parameter to the parsing rule and I
got this error:
Failure: this is not a constructor, it cannot be applied in a pattern
Preprocessing error
To solve the problem I changed the file into a .mll file to parse it
with ocamllex and everything worked.
Thus I have compared the source code as result of the preprocessor and
ocamllex in both cases and I found that the pa_ocamllex understands the
two arguments as one argument.
Here is a sample code that reproduces the error
#use "topfind";;
#camlp4o;;
#load "pa_ocamllex.cma";;
pa_ocamllex let x = 'x';;
(* no arguments )
pa_ocamllex rule foo = parse | x {
Yep } | ['\000'-'\255'] {
Nope };;( just one argument )
pa_ocamllex rule fee fuz = parse | x {
Yep(fuz) } | ['\000'-'\255'] {
Nope };;( two arguments *)
pa_ocamllex rule bar bee buz = parse | x {
Yep(bee) } | [ '\000'-'\255' ] {
Nope(buz) };;The first rule has no parameters and it is compiled correctly.
The second one, with one argument, is working fine too.
The third one gives the problem: it is understood as a function named
bar with arguments (bee buz as ...) and (lexbuf as ..).
I am working with Ocaml 3.07+2 and CamlP4 3.07+2 on Linux.
Thanks for your attention
Luca Pascali
The text was updated successfully, but these errors were encountered: