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: 4330 Reporter: brunodefraine Assigned to: ertai Status: closed (set by ertai on 2008-10-03T15:13:05Z) Resolution: fixed Priority: normal Severity: major Version: 3.10.0 Fixed in version: 3.11+dev Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues
Bug description
When defining a recursive rule for a binary operator, gramlib accepts input that illegally ommits a right operand.
For example, with the following grammar definition:
open Camlp4.PreCast ;
value a = Gram.Entry.mk "a" ;
value a_eoi = Gram.Entry.mk "a_eoi" ;
EXTEND Gram
a: [[ "one" -> 1 | x = a; "plus"; y = a -> x+y ]];
a_eoi: [[ x = a; `EOI -> x ]];
END ;
and the following function:
value parse_string entry s =
try
Gram.parse_string entry (Loc.mk "") s
with [ Loc.Exc_located loc exn ->
begin
print_endline (Loc.to_string loc);
print_endline (Printexc.to_string exn);
failwith "Syntax Error"
end ] ;
The following is correct:
parse_string a_eoi "one plus one" ;
: int = 2
While all of the following inputs should be rejected because they are not legal according to the grammar:
parse_string a_eoi "one plus" ;
: int = 1
parse_string a_eoi "one plus plus" ;
: int = 1
parse_string a_eoi "one plus one plus" ;
: int = 2
parse_string a_eoi "one plus one plus plus" ;
: int = 2
Curiously, you may only repeat the operator twice. If you specify it three times, gramlib complains.
parse_string a_eoi "one plus plus plus" ;
File "", line 1, characters 9-13
Stream.Error("EOI expected after [a] (in [a_eoi])")
Exception: Failure "Syntax Error".
parse_string a_eoi "one plus one plus plus plus" ;
File "", line 1, characters 18-22
Stream.Error("EOI expected after [a] (in [a_eoi])")
Exception: Failure "Syntax Error".
Original bug ID: 4330
Reporter: brunodefraine
Assigned to: ertai
Status: closed (set by ertai on 2008-10-03T15:13:05Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 3.10.0
Fixed in version: 3.11+dev
Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues
Bug description
When defining a recursive rule for a binary operator, gramlib accepts input that illegally ommits a right operand.
For example, with the following grammar definition:
open Camlp4.PreCast ;
value a = Gram.Entry.mk "a" ;
value a_eoi = Gram.Entry.mk "a_eoi" ;
EXTEND Gram
a: [[ "one" -> 1 | x = a; "plus"; y = a -> x+y ]];
a_eoi: [[ x = a; `EOI -> x ]];
END ;
and the following function:
value parse_string entry s =
try
Gram.parse_string entry (Loc.mk "") s
with [ Loc.Exc_located loc exn ->
begin
print_endline (Loc.to_string loc);
print_endline (Printexc.to_string exn);
failwith "Syntax Error"
end ] ;
The following is correct:
parse_string a_eoi "one plus one" ;
While all of the following inputs should be rejected because they are not legal according to the grammar:
parse_string a_eoi "one plus" ;
parse_string a_eoi "one plus plus" ;
parse_string a_eoi "one plus one plus" ;
parse_string a_eoi "one plus one plus plus" ;
Curiously, you may only repeat the operator twice. If you specify it three times, gramlib complains.
parse_string a_eoi "one plus plus plus" ;
File "", line 1, characters 9-13
Stream.Error("EOI expected after [a] (in [a_eoi])")
Exception: Failure "Syntax Error".
parse_string a_eoi "one plus one plus plus plus" ;
File "", line 1, characters 18-22
Stream.Error("EOI expected after [a] (in [a_eoi])")
Exception: Failure "Syntax Error".
Additional information
Tested with Ocaml 3.10.0 on Mac OS X.
File attachments
The text was updated successfully, but these errors were encountered: