On 02/06/2009, at 12:29 PM, mmmmbeeeeer wrote:
> I expected the SyntaxNode generated for 'requirement' to have method
> 'constraint' if a constraint was present in the parsed text. Whilst it
> has a linked SyntaxNode for the constraint '12 credit points from' it
> doesn't add the constraint method.
>
> I'm assuming that this is related to the constraint being optional;
> can anyone shed any light on this?
Your diagnosis is right, and I'd classify this as a known problem.
In fact it caught me out again yesterday.
The easiest fix is to add an tag name to the optional node:
rule requirement
c:constraint? set_of_units (' and ' requirement)?
end
and then you can check "c.text_value.empty?" to see if anything was
matched, if necessary.
My expected behaviour would be that the constaint method would always
be added, and would return nil if the optional rule wasn't matched.
Clifford Heath.