[metaas-dev] ElseIf
David Holroyd
dave at badgers-in-foil.co.uk
Fri Dec 14 23:25:40 UTC 2007
On Mon, Dec 10, 2007 at 07:53:14PM -0500, Matthew J Tretter wrote:
> Hey David,
> Sorry I didn't write back sooner. Here's the error I'm getting:
>
> Exception in thread "main" uk.co.badgersinfoil.metaas.SyntaxException:
> Unsupported statement node type: CONDITION in "(b)"
> at
> uk.co.badgersinfoil.metaas.impl.StatementBuilder.build(StatementBuilder.java:57)
> at
> uk.co.badgersinfoil.metaas.impl.ASTStatementList.getStatementList(ASTStatementList.java:254)
>
>
> It happens when I try to call getStatementList() on the else if
> StatementContainer in the following code:
>
> if (a) {
> doSomething();
> } else if (b) {
> doSomethingElse();
> }
>
> I'm getting to the elseif statement via
> ASIfStatement.getElse().getStatementList(). Any thoughts?
Right. So the API I created there is just broken.
getElse() is declared as returning an ASBlock, but it should, of course,
return an instance of one of the Statement interfaces (in your example,
it needs to return another ASIfStatement).
There's certainly utility in having a method that automatically adds an
'else { }' to the 'if' when none exists yet, but it can't be the only
option here.
I'll have a think about how to deprecate this getElse() method so that
apps already using it don't break when this issue is fixed.
ta,
dave
--
http://david.holroyd.me.uk/
More information about the metaas-dev
mailing list