home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
ruby164.zip
/
rbemx164.zip
/
ruby
/
share
/
doc
/
racc-1.3.9
/
sample
/
lists.y
< prev
next >
Wrap
Text File
|
2001-04-07
|
992b
|
57 lines
#
# lists.y
#
# verious lists.
# This file is just example, so don't run directly.
#
# list, which minimum number of item is 0
list0 :
{
result = []
}
| list0 item
{
result.push val[1]
}
# list, which minimum number of item is 1
list1 : item
{
result = val
}
| list1 item
{
result.push val[1]
}
# list, separated by comma
clist : item
{
result = val
}
| clist ',' item
{
result.push val[2]
}
# hash like list. see also "hash.y".
hash : '{' hash_contents '}'
{
result = val[1]
}
| '{' '}'
{
result = {}
}
hash_contents
: item => item
{
result = { val[0] => val[2] }
}
| hash_contents ',' item => item
{
result[ val[2] ] = val[4]
}