Bug #378
Ungraceful behaviour: Source inside For loop
Description
The following input produces an unexpected effect:
For I:=1 To 10 Do Source "file.cocoa5"; EndFor;
Change the parser so that Source
is recognized (& correctly parsed) even in forbidden contexts, but produces an "illegal context" error.
History
#1 Updated by Anna Maria Bigatti about 10 years ago
- Target version set to CoCoA-5.1.0 Easter14
#2 Updated by John Abbott about 10 years ago
- Target version changed from CoCoA-5.1.0 Easter14 to CoCoA-5.1.1 Seoul14
#3 Updated by Anna Maria Bigatti almost 10 years ago
A few more details: I ran this line
For I:=1 To 10 Do Source "hp.cpkg5"; EndFor;
and received
--> ERROR: Invalid start of expression --> For I:=1 To 10 Do Source "hp.cpkg5"; EndFor; --> ^^^^^^ --> WARNING: Package $hp has been redefined (...) --> ERROR: Invalid start of expression --> For I:=1 To 10 Do Source "hp.cpkg5"; EndFor; --> ^^^^^^
This shows that
Source "hp.cpkg5"
has been executed once (after quitting the For
statement)#4 Updated by Anna Maria Bigatti almost 10 years ago
From Alexandru Costantinescu (who used source
in loops in cocoa-4)
I am using a data base of Hilbert functions, which are grouped in 2 types of files, each depending on 3 parameters. (...) As I keep changing the range of the running parameter, it was convenient to call the files inside the loop. The files are also rather large, so I don't want to load all of them from the beginning.
#5 Updated by Anna Maria Bigatti almost 10 years ago
- Status changed from New to In Progress
- Assignee set to Anna Maria Bigatti
- % Done changed from 0 to 50
- Estimated time set to 2.00 h
I found where (I looked for TT_FOR
, in Parse.C
) to give a proper error (if we decide to disable it) or to enable source
in loops (I enabled it)
intrusive_ptr<Statement> Parser::parseFunBodyStatement() {
So I did it: it works at top level, even inside loops, but not in functions. See first check in
intrusive_ptr<SourceStatement> Parser::parseSourceStatement(const Token &tokSource) {
(easy to fix if we make any other choice)
So I think that's all.....
[Good job Giovanni Lagorio!!]
#6 Updated by Anna Maria Bigatti almost 10 years ago
- Status changed from In Progress to Closed
- % Done changed from 50 to 100