Skip to content

Interaction between coercions and arrays causes syntax error. #100

Closed

Description

@flaviut
EAssgn. Exp ::= Exp  "="  Exp1;
EArrCall. Exp1 ::= Exp1 "[" [Exp2] "]";

separator Exp2 ",";

ENumber. Exp2 ::= Integer;
coercions Exp 2;

fails with ocamlyacc: e - the symbolexp_list' is undefined`.

Adding separator Exp ","; causes a failure in PrintCalc.ml:

let rec prtExp (i:int) (e:exp) : doc = match e with
       EAssgn (exp0, exp) -> prPrec i 0 (concatD [prtExp 0 exp0 ; render "=" ; prtExp 1 exp])
  |    EArrCall (exp, exps) -> prPrec i 1 (concatD [prtExp 1 exp ; render "[" ; prtExpListBNFC 2 exps ; render "]"])
  |    ENumber n -> prPrec i 2 (concatD [prtInt 0 n])

and prtExpListBNFC _ es : doc = match es with
    []    -> (concatD [])
    []    -> (concatD [])                (* deleting this line allows compilation *)
  | [x]   -> (concatD [prtExp 2 x])
  | [x]   -> (concatD [prtExp 0 x])
  | x::xs -> (concatD [prtExp 2 x ; render "," ; prtExpListBNFC 2 xs])
  | x::xs -> (concatD [prtExp 0 x ; render "," ; prtExpListBNFC 0 xs])

Metadata

Metadata

Assignees

No one assigned

    Labels

    OCamlbugprinter

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions