Project

General

Profile

Feature #673

Error message: I was expecting...

Added by John Abbott about 9 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
enhancing/improving
Target version:
Start date:
11 Mar 2015
Due date:
% Done:

100%

Estimated time:
1.88 h
Spent time:

Description

The generic error message

ERROR: I was expecting an identifier by found "weights" 

should be improved, e.g. to explain why weights is unsuitable (because it's a keyword).


Related issues

Related to CoCoA-5 - Design #668: Remove keyword "weights"?Closed2015-03-05

Related to CoCoA-5 - Support #530: Interpreter error message: "for" with missing "do"Rejected2014-04-09

History

#1 Updated by John Abbott about 9 years ago

  • Estimated time set to 3.00 h

The relevant source code is Parser.H:156

The following rule may help identify the "type" of a parser token:
  • starts with a letter --> keyword or identifier
  • starts with a digit --> number
  • starts with double quote --> string (literal)
  • otherwise symbol/operator

#2 Updated by John Abbott over 8 years ago

The original report did not contain an example of input which produces the unhelpful error message. I think the following illustrates the problem:

record[for := 1];

Curiously, this input evidently confuses the parser because it produces two very similar error messages -- probably not worth fixing.

#3 Updated by John Abbott over 4 years ago

  • Status changed from New to Resolved
  • Assignee set to John Abbott
  • Target version changed from CoCoA-5.?.? to CoCoA-5.3.0
  • % Done changed from 0 to 60

Not really sure how to do this cleanly, so I have "hacked" the class Token in Lexer.H (near line 243) by adding a new mem fn LexemeClass. The impl is in Lexer.C near line 44. This new mem fn is used only in the ctor for UnexpectedTokenException in Parser.H near line 158.

A quick check suggest that it works acceptably. Here are the tests I tried:

record[for := 1];
record[:= 1];
record[1];
record["1"];
record[  <EOF>

Not yet CVS-ed. I'l try a few more ad hoc tests first.

#4 Updated by John Abbott over 4 years ago

CVS-ed. Also CoCoA-5 tests pass :-)

#5 Updated by John Abbott over 4 years ago

  • Status changed from Resolved to Feedback
  • % Done changed from 60 to 90

I have tried some more tests. Mostly it seems OK, but it is possible to confuse the parser:

record['
record[''
record[<<

Mind you, anyone who types in any of the above is just being a vandal (mmm, me too?)

#6 Updated by Anna Maria Bigatti over 4 years ago

John Abbott wrote:

Mind you, anyone who types in any of the above is just being a vandal (mmm, me too?)

Now called "ethical hacker" ;-)

#7 Updated by John Abbott about 4 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100
  • Estimated time changed from 3.00 h to 1.88 h

Seems OK now. No doubt the school in Vietnam will be an "interesting" proving ground.
Closing.

Also available in: Atom PDF