Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong Position when error occured #89

Open
PizzaPablo666 opened this issue May 13, 2020 · 2 comments
Open

Wrong Position when error occured #89

PizzaPablo666 opened this issue May 13, 2020 · 2 comments

Comments

@PizzaPablo666
Copy link
Member

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.

@PizzaPablo666
Copy link
Member Author

PizzaPablo666 commented May 13, 2020

The code is from PIO : https://inf.ethz.ch/personal/wirth/Oberon/PIO.pdf ,page 36 , with some changes as you can see.
I guess It is showing the position of the error from the whole file, not the line.

@dcwbrown
Copy link
Contributor

That's right, pos is the value you would pass to Oberon's Files.Set(VAR r: Rider; f: File; pos: INT32).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants