/usr.bin/csup/parse.y

https://bitbucket.org/freebsd/freebsd-head/ · Happy · 91 lines · 76 code · 15 blank · 0 comment · 0 complexity · 1ff7d79cf0f92f43d0fc3e79dc844dcd MD5 · raw file

  1. %{
  2. /*-
  3. * Copyright (c) 2003-2004, Maxime Henrion <mux@FreeBSD.org>
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  16. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  19. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  21. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  22. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  23. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  24. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  25. * SUCH DAMAGE.
  26. *
  27. * $FreeBSD$
  28. */
  29. #include <sys/types.h>
  30. #include "config.h"
  31. #include "token.h"
  32. %}
  33. %union {
  34. char *str;
  35. int i;
  36. }
  37. %token DEFAULT
  38. %token <i> NAME
  39. %token <i> BOOLEAN
  40. %token EQUAL
  41. %token <str> STRING
  42. %%
  43. config_file
  44. : config_list
  45. |
  46. ;
  47. config_list
  48. : config
  49. | config_list config
  50. ;
  51. config
  52. : default_line
  53. | collection
  54. ;
  55. default_line
  56. : DEFAULT options
  57. { coll_setdef(); }
  58. ;
  59. collection
  60. : STRING options
  61. { coll_add($1); }
  62. ;
  63. options
  64. :
  65. | options option
  66. ;
  67. option
  68. : BOOLEAN
  69. { coll_setopt($1, NULL); }
  70. | value
  71. ;
  72. value
  73. : NAME EQUAL STRING
  74. { coll_setopt($1, $3); }
  75. ;
  76. %%