You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the example below, test t2 fails, not by failing the assertion, but with an ordinary false return value. The example is constructed as a model of a mistaken declaration, such as a typo. Even though B, the return value of b, is not convertible to A, the action executes anyway but the return value does not substitute for the default node in the parse tree.
This behavior is, at best, confusing. What should never happen is that all of the following occur:
The action runs.
The return value is ignored.
There's no error generated.
It would be best if there were a compilation error so that such a grammar can never be parsed. There are other possible actions. One would be to not run the action at all, preferably with a warning somewhere. Another would be to generate a run-time error upon detection of the inconsistency, by default terminating the program (thus it wouldn't matter whether before or after the action runs).
module action_03
import Message ;
import ParseTree ;
syntax A
= a: "1"
| b: "2"
| c: "3" ;
syntax B = b: "4" ;
anno str A @ msg ;
anno str B @ msg ;
bool executed ;
A a()
{
executed = true;
A x = (A)`1` ;
x@msg = "action \"a\" executed" ;
return x ;
}
B b()
{
executed = true;
B x = (B)`4` ;
x@msg = "action \"b\" executed" ;
return x ;
}
void c()
{
executed = true ;
}
test bool t1()
{
executed = false ;
Tree t = parse( #A, "1" ) ;
assert executed ;
return t@msg ? ;
}
test bool t2()
{
executed = false ;
Tree t = parse( #A, "2" ) ;
assert executed ;
return t@msg ? ;
}
test bool t3()
{
executed = false ;
Tree t = parse( #A, "3" ) ;
assert executed ;
return ! t@msg ? ;
}
test bool t4()
{
executed = false ;
Tree t = parse( #B, "4" ) ;
assert executed ;
return t@msg ? ;
}
Version is 0.10.0.201807232201 under Eclipse Photon.
The text was updated successfully, but these errors were encountered:
In the example below, test
t2
fails, not by failing the assertion, but with an ordinary false return value. The example is constructed as a model of a mistaken declaration, such as a typo. Even thoughB
, the return value ofb
, is not convertible toA
, the action executes anyway but the return value does not substitute for the default node in the parse tree.This behavior is, at best, confusing. What should never happen is that all of the following occur:
It would be best if there were a compilation error so that such a grammar can never be parsed. There are other possible actions. One would be to not run the action at all, preferably with a warning somewhere. Another would be to generate a run-time error upon detection of the inconsistency, by default terminating the program (thus it wouldn't matter whether before or after the action runs).
Version is 0.10.0.201807232201 under Eclipse Photon.
The text was updated successfully, but these errors were encountered: