1. Isn't this wrong?
- Posted by useless Jul 25, 2010
- 1142 views
This runs fine using Eu 3.1:
atom retry retry = 0 with trace trace(1) while 1 do if retry then end if end while
but fails using 4.0:
<0025>:: a name is expected here atom retry
Hmm. Ok, i rename it to retry2, and this runs fine on Eu v4a3 and v4b2:
atom retry2 retry2 = 0 with trace trace(1) while 1 do if retry2 then end if end while
Ok, that is interesting, what with that dangling "if" there, it runs with no errors using 3 Eu interpreters. Well, ok. So i add a few lines...
sequence TheWebPage TheWebPage = "" atom retry2 retry2 = 0 with trace trace(1) while 1 do if match(upper("<title>404 - Page Not Found</title>"),upper(TheWebPage)) then TheWebPage = "404" exit end if retry2 then end if end while
Eu v4a2 says:
Syntax error - expected to see =, +=, -=, *=, /= or &=\\ if retry2 then end\\ ^\\
implying i should start a expression of some sort between "then" and "end", starting with a boolean or math of some sort? Suddenly, the line that ran fine before needs an assigment in it?
Eu v4b2 says:
<0076>:: expected to see an assignment after 'retry2', such as =, +=, -=, *=, /= or &= if retry2 then end ^
but again, pointing to between "then" and "end". Even tho retry2 has been assigned. And why does an assignment after an "if" ? Plus, " if retry2 then end" ran with no errors before i added the code about TheWebPage.
So i changed the line to:
if retry2 = 1 then end
and it replied
Syntax error - expected to see possibly 'end', not 'then' if retry2 = 1 then end ^
So what the heck, remove the "then"....
it complained about the dangling "if"....
removed the dangling "if"....
it complained about the "end" in "end while"....
removed that "end"....
And for jollies, change the "retry2 +" to "retry2 +=" and this runs just fine:
include wildcard.e -- for upper() sequence TheWebPage TheWebPage = "" atom retry2 retry2 = 0 with trace trace(1) while 1 do if match(upper("<title>404 - Page Not Found</title>"),upper(TheWebPage)) then TheWebPage = "404" exit end if retry2 += 1 end while
And retry2 is incremented each pass thru.
But you do get different results if you comment out the ifthen about TheWebPage.
And even if you say <cr><cr> between "end" and "while" doesn't break the token's meaning, if that "end<cr><cr>while" go together as far as the interpreter sees it, i have a dangling "if" preceeding the "retry2 += 1".
useless
2. Re: Isn't this wrong?
- Posted by DerekParnell (admin) Jul 25, 2010
- 1082 views
This runs fine using Eu 3.1:
atom retry
but fails using 4.0:
<0025>:: a name is expected here atom retry
The word retry is a reserved word in Eu 4. It can be used inside loops to repeat the current iteration.
Hmm. Ok, i rename it to retry2, and this runs fine on Eu v4a3 and v4b2:
atom retry2 retry2 = 0 with trace trace(1) while 1 do if retry2 then end if end while
Ok, that is interesting, what with that dangling "if" there, it runs with no errors using 3 Eu interpreters. Well, ok. So i add a few lines...
The 'dangling' if is not really dangling. The IF statement must end with the two words 'end' and 'if' and they do not have to be on the same line.
eg.
-- First statement if 1 then ? 1 end if -- Second statement if 1 then ? 1 end if
Both statements above are identical as far as Eu is concerned.
sequence TheWebPage TheWebPage = "" atom retry2 retry2 = 0 with trace trace(1) while 1 do if match(upper("<title>404 - Page Not Found</title>"),upper(TheWebPage)) then TheWebPage = "404" exit end if retry2 then end if end while
Eu v4a2 says:
Syntax error - expected to see =, +=, -=, *=, /= or &=\\ if retry2 then end\\ ^\\
implying i should start a expression of some sort between "then" and "end", starting with a boolean or math of some sort? Suddenly, the line that ran fine before needs an assigment in it?
Eu v4b2 says:
<0076>:: expected to see an assignment after 'retry2', such as =, +=, -=, *=, /= or &= if retry2 then end ^
but again, pointing to between "then" and "end". Even tho retry2 has been assigned. And why does an assignment after an "if" ? Plus, " if retry2 then end" ran with no errors before i added the code about TheWebPage.
Ok, the error pointer could be improved. Currently the scanner has gotten to the end of the word 'then' and the parser has by now realized that an assignment is required so the error message is correct "expecting to see an assignment" and the '^' pointer is showing you where the scanner is up to. It is sort of saying, "Hey I got 'then' but was expecting some sort of assignment there instead".
Now it was expecting an assignment because the previous IF statement actually uses the 'if' preceding the 'retry2' word as marking the end of the IF statement. Thus 'retry2' is the start of a new statement and the only type of statements that start with a variable are assignment statements.
It seems that you have mistakenly thought that the IF statement was completed by the 'end' word alone, but that is not the case. Look at it laid out differently ...
sequence TheWebPage TheWebPage = "" atom retry2 retry2 = 0 with trace trace(1) while 1 do if match(upper("<title>404 - Page Not Found</title>"),upper(TheWebPage)) then TheWebPage = "404" exit end if retry2 then end if end while
Now is the syntax error obvious?
...
it complained about the dangling "if"....
Just to restate, statements such as IF, WHILE, FOR etc are terminated by a two word combination, and those words do not have to be on the same line. The terminator is 'end' followed by 'if', while', 'for' etc that may or may not be on the same line.
3. Re: Isn't this wrong?
- Posted by useless Jul 25, 2010
- 1129 views
That's what i get, i spose, for programming in several languages at 2am.
useless
4. Re: Isn't this wrong?
- Posted by CoJaBo Jul 25, 2010
- 1108 views
That's what i get, i spose, for programming in several languages at 2am.
useless
Ah, the dangling IF at 2 in the morning..
I've been there before o_O
The error when you use a reserved keyword really ought to be improved-
"a name is expected here" is patent nonsense, because it worked before and to the reader there is clearly a name there, even though newer versions of Eu think it is some other type of token.
How about having the interpreter state what it thinks is there, like PHP does?
"expected a name, not a RETRY statement", just printing out whatever type of token Eu thinks it has there.
That should inspire the user to think, hey, theres a retry statement now, I cant use that as a name anymore.
5. Re: Isn't this wrong?
- Posted by DerekParnell (admin) Jul 25, 2010
- 1159 views
The error when you use a reserved keyword really ought to be improved- ...
How about this ...
<0025>:: 'retry' is a reserved word and cannot be used as an identifier name
6. Re: Isn't this wrong?
- Posted by useless Jul 25, 2010
- 1073 views
The error when you use a reserved keyword really ought to be improved- ...
How about this ...
<0025>:: 'retry' is a reserved word and cannot be used as an identifier name
I guess you haveto balance the programmer having some knowledge of the language vs the size of the error reporting string table. Or the time of day, surplus of blood in the caffine stream, etc.. I had also spent a couple minutes trying to figure out why "$+" wasn't working for string concatenation. And i figured "end" was fine, where Eu was reading "end if" across multiple text lines.
I once added 8k of error diagnostics to a cpu with only 64k of address space, but i was able to page it out during runtime. Sometimes it's just worth it to hit a couple keys and instantly have the cheatsheet.
useless
7. Re: Isn't this wrong?
- Posted by JoKeR Jul 26, 2010
- 1013 views
That's what i get, i spose, for programming in several languages at 2am.
useless
Isn't most programming done at 2am?