Loading ...
Sorry, an error occurred while loading the content.

Typing problem with 'a

Expand Messages
  • hmf@inescporto.pt
    Hello, I have the following error message when compiling: This expression has type (Lexing.lexbuf - Pred_parser.token) - Lexing.lexbuf -
    Message 1 of 3 , Aug 8, 2008
    View Source
    • 0 Attachment
      Hello,

      I have the following error message when compiling:

      This expression has type
      (Lexing.lexbuf -> Pred_parser.token) -> Lexing.lexbuf ->
      Parse_utils.source_pos Pred.expr
      but is here used with type
      (Lexing.lexbuf -> Prop_parser.token) -> Lexing.lexbuf ->
      'a

      The code is:

      let parse_pred file_name line_off bol_off str =
      parse "Parsing error of first order predicate logic formula."
      Pred_parser.statement file_name line_off bol_off str
      ^^^^^^^^^^^^^^^^^^^^^

      where "parse" returns a generic type 'a

      The type reported by the system is correct. I don't understand
      why the general type 'a of "parse" is not bound to the expected
      type "Parse_utils.source_pos Pred.expr". In addition to this a
      few lines before this I also have:

      let parse_prop file_name line_off bol_off str =
      parse "Parsing error of propositional formula." Prop_parser.statement
      file_name line_off bol_off str

      which compiles and executes correctly.

      Note that both Prop_parser.statement and
      Pred_parser.statement are generated by Menhir using
      a common lexical analyser.

      Any ideas on how to diagnose this?

      TIA,
      Hugo F.
    • Richard Jones
      ... (1) Post a minimal example to the menhir mailing list. (2) Try adding type declarations to some of the values in the code (with what you think is the
      Message 2 of 3 , Aug 8, 2008
      View Source
      • 0 Attachment
        On Fri, Aug 08, 2008 at 10:44:48AM +0100, hmf@... wrote:
        > Any ideas on how to diagnose this?

        (1) Post a minimal example to the menhir mailing list.

        (2) Try adding type declarations to some of the values in the code
        (with what you think is the correct type), ie. change:

        ... v ...

        to:

        ... (v : type) ...

        Rich.

        --
        Richard Jones
        Red Hat
      • hmf@inescporto.pt
        Hello, ... I have been unable to make a minimal example because it involves parsers and lexical analyser. Anyway, after a lot of experimenting and testing it
        Message 3 of 3 , Aug 9, 2008
        View Source
        • 0 Attachment
          Hello,

          Richard Jones wrote:
          > On Fri, Aug 08, 2008 at 10:44:48AM +0100, hmf@... wrote:
          >> Any ideas on how to diagnose this?
          >
          > (1) Post a minimal example to the menhir mailing list.
          >

          I have been unable to make a minimal example because it involves
          parsers and lexical analyser. Anyway, after a lot of experimenting
          and testing it seems that the error is because I had to share tokens
          between two parsers and the code was not being correctly compiled.
          I have been wrestling with ocamlbuild and menhir to do this but have
          failed miserably. I have therefore sent an (very simple) example to the
          senior's/expert's list with a very simple example.

          > (2) Try adding type declarations to some of the values in the code
          > (with what you think is the correct type), ie. change:
          >
          > ... v ...
          >
          > to:
          >
          > ... (v : type) ...
          >

          Yes, I had already tried this but as I said the returned type
          that was reported was correct. It just was not able to bind 'a
          with the type.

          Thanks for the suggestions.

          regards,
          Hugo F.


          > Rich.
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.