I've got a simple grammar like so:
grammar Test
rule array
'[' letter (',' letter)* ']'
{
def eval
#???
end
}
end
rule letter
[a-zA-Z] 1..1
{
def eval
text_value
end
}
end
end
A sample string in the grammar is "[a,b,c,d]"
I would like the eval method on the array rule to return an array of strings ["a", "b", "c", "d"], but I'm not sure how to do that. I can get the first element by doing:
def eval
[letter.eval]
end
which would return ["a"]. How do I capture the following letter instances in the expression?