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 >
Text File  |  2001-04-07  |  992b  |  57 lines

  1. #
  2. # lists.y
  3. #
  4. # verious lists.
  5. # This file is just example, so don't run directly.
  6. #
  7.  
  8. # list, which minimum number of item is 0
  9. list0 :
  10.           {
  11.             result = []
  12.           }
  13.       | list0 item
  14.           {
  15.             result.push val[1]
  16.           }
  17.  
  18. # list, which minimum number of item is 1
  19. list1 : item
  20.           {
  21.             result = val
  22.           }
  23.       | list1 item
  24.           {
  25.             result.push val[1]
  26.           }
  27.  
  28. # list, separated by comma
  29. clist : item
  30.           {
  31.             result = val
  32.           }
  33.       | clist ',' item
  34.           {
  35.             result.push val[2]
  36.           }
  37.  
  38. # hash like list. see also "hash.y".
  39. hash  : '{' hash_contents '}'
  40.           {
  41.             result = val[1]
  42.           }
  43.       | '{' '}'
  44.           {
  45.             result = {}
  46.           }
  47.  
  48. hash_contents
  49.       : item => item
  50.           {
  51.             result = { val[0] => val[2] }
  52.           }
  53.       | hash_contents ',' item => item
  54.           {
  55.             result[ val[2] ] = val[4]
  56.           }
  57.