close Warning: Can't synchronize with repository "(default)" (/var/svn/tolp does not appear to be a Subversion repository.). Look in the Trac log for more information.

Opened 21 years ago

Closed 21 years ago

Last modified 18 years ago

#35 closed defect (later)

PARSER ERROR

Reported by: César Pérez Álvarez Owned by: danirus
Priority: normal Milestone:
Component: Kernel Version: head
Severity: major Keywords:
Cc:

Description

The following sentence

"Serie GetSerie(Text nameInput, Set simulationSet)
{

Set selSim = Select(simulationSet(Set reg)
{

Text nameInputSim = reg->NameInput;
nameInputSim == nameInput

});
If(IsEmpty(selSim), Eval("Serie "+nameInput+";"), selSim[1]->InputSim)

};"

doesn't cause an error when you check it for syntax errors, but it's obviusly that
there is an error in select definition.

Change History (4)

comment:1 Changed 21 years ago by César Pérez Álvarez

If we see the error better, it seems that it is not a syntax error. I think it's related
with de check argumants of the function select.
Following there is a code that we can test:

Struct SimDefinition
(

Text NameInput,
Serie InputSim

);

Serie GetSerie(Text nameInput, Set simulationSet)
{

Set selSim = Select(simulationSet(Set reg)
{

Text nameInputSim = reg->NameInput;
nameInputSim == nameInput

});
If(IsEmpty(selSim), Eval("Serie "+nameInput+";"), selSim[1]->InputSim)

};

Serie Sim0 = CalInd(In(y2003m01d01,y2004m01d01, Mensual), Mensual);

Set SimInfo = SetOfSet
(

SimDefinition(Text "TSP_PIBLogDelta", Sim0)

);

Serie GetSerie("TSP_PIBLogDelta", SimInfo)

comment:2 Changed 21 years ago by danirus

Status: newassigned

comment:3 Changed 21 years ago by danirus

Priority: highestnormal
Resolution: later
Severity: criticalmajor
Status: assignedclosed

This is an important improvement that we should treat in next Tol meeting.
The problem is related with the weak parsing of arguments in Tol functions.

The code:

"Serie GetSerie(Text nameInput, Set simulationSet)
{

Set selSim = Select(simulationSet(Set reg)
{

Text nameInputSim = reg->NameInput;
nameInputSim == nameInput

});
If(IsEmpty(selSim), Eval("Serie "+nameInput+";"), selSim[1]->InputSim)

};"

Generates this Syntactical Tree:

----> [BINARY]#F#

> [TYPE]Serie

|> [FUNCTION]GetSerie |> [TYPE]Text | |> [ARGUMENT]nameInput |> [TYPE]Set |> [ARGUMENT]simulationSet

> [SEPARATOR]{;}

> [BINARY]=
|> [TYPE]Set | |> [ARGUMENT]selSim |> [FUNCTION]Select |> [BINARY](#F#) |> [FUNCTION]simulationSet | |> [TYPE](Set) | |> [ARGUMENT]reg |> [SEPARATOR]{;} |> [BINARY]= | |> [TYPE]Text | | |> [ARGUMENT]nameInputSim | |> [BINARY]-> | |> [ARGUMENT]reg | |> [ARGUMENT]NameInput |> [BINARY]== |> [ARGUMENT]nameInputSim |> [ARGUMENT]nameInput

> [FUNCTION]If

> [FUNCTION]IsEmpty
|> [ARGUMENT](selSim)

> [FUNCTION]Eval

|> [BINARY](+) |> [BINARY]+ | |> [ARGUMENT]"Serie | |> [ARGUMENT]nameInput |> [ARGUMENT]";

> [BINARY]->

> [BINARY]#E#
|> [ARGUMENT]selSim |> [ARGUMENT]#(#1#)#

> [ARGUMENT]InputSim

As we can see, [FUNCTION]Select has only one branch, when should be two because
accept two parameters. If we see now [FUNCTION]If, it has three branches, corresponding
each branch with one of its three parameters.

comment:4 Changed 18 years ago by Víctor de Buen Remiro

bug_file_loc: http://www.tol-project.org
Note: See TracTickets for help on using tickets.