Skip to content

Wrong Position when error occured #89

Description

@PizzaPablo666
MODULE Postfix;
  IMPORT Texts, Oberon;
  VAR ch: CHAR;
	W: Texts.Writer; R: Texts.Reader;

PROCEDURE expression;
  VAR addop: CHAR;

PROCEDURE term;
  VAR mulop: CHAR;

PROCEDURE factor;
BEGIN
  IF ch = "(" THEN
	Texts.Read(R, ch);  expression;
	WHILE ch # ")" DO Texts.Read(R, ch) END
  ELSIF ch = "[" THEN
	Texts.Read(R, ch);    expression;
	WHILE ch # "]" DO Texts.Read(R, ch) END
  ELSE
	WHILE (ch < "a") OR (ch > "z") DO Texts.Read(R,ch) END ;
	Texts.Write(W,ch)
  END;
  Texts.Read(R, ch)
END factor;

BEGIN (*term*) factor;
  WHILE (ch = "*") OR (ch = "/") DO
	mulop := ch; Texts.Read(R, ch); factor; Texts.Write(W, mulop)
  END
END term;

BEGIN (*expression*) term;
  WHILE (ch = "+") OR (ch = "-") DO
	addop := ch; Texts.Read(R, ch); term; Texts.Write(W, addop)
  END
END expression;

PROCEDURE Parse;
BEGIN Texts.OpenReader(R, Oberon.Par.text, Oberon.Par.pos); Texts.Read(R, ch);
  WHILE ch # "~" DO
	expression; Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf);
	Texts.Read(R, ch)
  END
END Parse;

BEGIN Texts.OpenWriter(W);
  factor;
END Postfix.

In the last Procedure "main" in penultimate line of the code when I try to call factor which is local procedure of term procedure and can't be called, I have an error message:

Postfix.Mod  Compiling Postfix.

  48:   factor;
             ^
    pos  1046  err 0  undeclared identifier

Module compilation failed.

Correct line, but wrong position in the error message.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions