Phillip,
This is because the rule format for Array I implemented is the following...
@array = thing1, thing2, ....
your example
@dogs = [ "dollar", "mack" ];
My method doesn't support the brackets yet. Its hard when you're making it from scratch and it looks like perl not to auto-assume that it would auto perform therse things but you would have to tell it how to do them...
I removed the brackets and ran with the following...
@dogs = "dollar", "mack";
and it now runs but gives me gumby output see below:
$VAR1 = [
[
'=',
undef
]
];
ok so mistake on my part =P replace the 'array' rule with this..
array : arrayname EQUAL arraelement(s?) { [ @item[1,3] ] }
now we add both lines back in...
@dogs = "dollar", "mack";
%myHash = {animals => @dogs, age = 5, names=> "fluffy"};
gives the following output =)
<code>
$VAR1 = [
[
[
'array',
'dogs'
],
[
[
'arrayelement',
[
'identifier',
'dollar'
]
],
[
'arrayelement',
[
'identifier',
'mack'
]
]
]
],
[
'hash',
'myHash',
[
[
'hashelement',
'animals',
[
'array',
'dogs'
]
],
[
'hashelement',
'age',
[
'literal',
'5'
]
],
[
'hashelement',
'names',
[
'identifier',
'fluffy'
]
]
]
]
];
A few things to note .... =)
- The reference to '@dogs' in the myHash is just stored as text that is told to be of 'array' in the hash. It would be your job to search the tree so see if you had a valid array called 'dogs' in the tree to get data from, it doesn't auto put the dogs array inside the hash or make any kewl little pointers or anything.
- I mentioned in my last note that you could pretty much use any combination or literal, itentifier, array or hash, but you can't actually have hashes embedded i.e. hashes of hashes. This is an easy change...just see what I did to the 'array' and 'variable' types.
- You can easily make is so that you array rule did accomodate brackets too....think along the line of adding something like..
array : arrayname EQUAL arrayelement(s?) { [ @item[1,3] ] }
: arrayname EQUAL '[' arrayelement(s?) ']' { [ @item[1,4] ] }
Regards Paul =)
p.s. I'm using v5.8.4