Skip to content

nit: printing repl prompter is not correct in kaleidoscope example #167707

@popescun

Description

@popescun

In main loop the prompter ready> is shown on any print, like:

$ ./a.out
ready> def foo(x y) x+foo(y, 4.0);
ready> Parsed a function definition.
ready> def foo(x y) x+y y;
ready> Parsed a function definition.
ready>Parsed a top-level expr
ready>

Instead it should be shown like stated in the documentation:

$ ./a.out
ready> def foo(x y) x+foo(y, 4.0);
Parsed a function definition.
ready> def foo(x y) x+y y;
Parsed a function definition.
Parsed a top-level expr
ready>

It seems, it should be printed only after ; and before getting next token:

static void MainLoop() {
  while (true) {
    switch (CurTok) {
    ...
    case ';': // ignore top-level semicolons.
      fprintf(stderr, "ready> ");
      getNextToken();
      break;
    ...
    default:
      HandleTopLevelExpression();
      break;
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions