|
|
|
Re: Two-step validation question [message #762978 is a reply to message #762918] |
Thu, 08 December 2011 22:39 |
Henrik Lindberg Messages: 2509 Registered: July 2009 |
Senior Member |
|
|
On 2011-08-12 21:13, Jonathan Whitall wrote:
> This is more than cross linking. I'm essentially trying to capture the
> runtime validation errors of program and put the diagnostic messages at
> the appropriate place in the editor.
>
> Imagine I defined a "rock tracker" program using some imaginary grammar
> (with keywords in all-caps):
>
> PUT 8 rocks IN box
> LET n = 6
> ASSERT n rocks IN box
>
> My "step 2" validation would mark the ASSERT part of the model with an
> error because it's expecting 8 rocks in the box, not 6. Now imagine that
> I had a typo on my LET statement:
>
> PUT 8 rocks IN box
> LETT n = 6
> ASSERT n rocks IN box
>
> This would make my "step 1" validation fail, but "step 2" validation
> would still run with a syntactically incorrect model, throwing an
> erroneous error when it hits the assert (such as an "undefined variable
> n").
>
> Or are you saying that afterModelLinked() is only called when the syntax
> check passes?
It is called before validation, but after linking. So if you need to
perform either additional linking, or evaluation (such as computing the
number of rocks in the box), you can do that in afterModelLinked.
E.g. afterModel is linked, you evaluate everything statically and issue
errors as you find asserts that do not hold true.
You would naturally skip an Assert that does not hold a valid expression
(as this problem is caught by other parts of your validation).
You can probably do the same in a check of "heavier kind" - it is only
if you need to performs something between linking and validation that
you would place the logic in afterModelLinked. One reason would be if
you have a large number of files, and values are computed for those
files, and you need the result, but do not want to evaluate everything
for every thing you validate. (There are a number of ways to make those
values available, and a good place to pick them up is in a "custom
linker" that picks up values). (I can elaborate on that if you are
interested).
Regards
- henrik
|
|
|
|
Powered by
FUDForum. Page generated in 0.03178 seconds