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

Re: ocamllex - return 2 tokens on eof?

Expand Messages
  • gmwass
    I tried this, but without success. I get many (567) shift/reduce conflicts and many (54) reduce/reduce conflicts, and the same error message comes up. I
    Message 1 of 3 , Feb 28, 2007
    • 0 Attachment
      I tried this, but without success. I get many (567) shift/reduce
      conflicts and many (54) reduce/reduce conflicts, and the same error
      message comes up.

      I defined stmt2 by copying all the rules for stmt and, if the rule
      ends with stmt_end, I remove the stmt_end symbol, and if it does not,
      I remove the rule.

      Probably part of the reason for the many conflicts is that there are
      rules like:

      stmt:
      (* lots of rules *)
      | WHILE LPAREN exp RPAREN stmt

      So I add in new rules like.

      | WHILE LPAREN exp RPAREN stmt2

      I may be able to rewrite the grammar to get rid of the conflicts, but
      I'd rather not risk introducing unintended changes. I would really
      like to do something more like having the lexer return two tokens on
      EOF (as I mentioned in my previous post). Any ideas?

      --Gary

      --- In ocaml_beginners@yahoogroups.com, Mathias Kende <mathias@...> wrote:
      >
      > You may use something like :
      >
      > main:
      > stmtlist EOF
      > |stmtlist stmt2 EOF
      >
      > and just define stmt2 without an ENDTAG token.
      > This is not much to write and should be enough.
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.