reasonml / reasonml/reason

Use lookahead token to decide which error message to use

Open
#588 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Error messages
Dominant language
OCaml
Stars
10.3k
Forks
438
PR merge metrics
No merged PRs in 30d

Description

Today when we use menhir's compile_errors option to generate error messages table in ocaml, the only input is the error state. It generates something like:

let message = 
fun s-> 
  match s with
  | 0 -> 
    "syntax error blah blah blah"
  ...

But sometimes for the same state, we want to have different error messages for different lookahead token. I'm thinking maybe we can use lookahead token as another input to error messages. So the generated ocaml error table file would look like this:

let message = 
fun s token -> 
  match (s, token) with
    | (0, MINUSGREATER) ->
      "Doesn't expect '->' here! Maybe you mean '=>' ?" 
    | (0, DIV) -> 
      ...
    | (0, _) ->
     ...

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the compile_errors implementation that generates the OCaml error-message table; no file or test is named in the issue. Review how the current state-only message function is produced and how lookahead tokens are represented. Done means generated messages can distinguish tokens for the same error state while retaining a fallback for other tokens.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.