rpc_scan.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* @(#)rpc_scan.h 1.3 90/08/29 */
  2. /*
  3. * Copyright (c) 2010, Oracle America, Inc.
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above
  11. * copyright notice, this list of conditions and the following
  12. * disclaimer in the documentation and/or other materials
  13. * provided with the distribution.
  14. * * Neither the name of the "Oracle America, Inc." nor the names of its
  15. * contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  21. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  22. * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  23. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  25. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  27. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  28. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. *
  31. * rpc_scan.h, Definitions for the RPCL scanner
  32. */
  33. /*
  34. * kinds of tokens
  35. */
  36. enum tok_kind {
  37. TOK_IDENT,
  38. TOK_CHARCONST,
  39. TOK_STRCONST,
  40. TOK_LPAREN,
  41. TOK_RPAREN,
  42. TOK_LBRACE,
  43. TOK_RBRACE,
  44. TOK_LBRACKET,
  45. TOK_RBRACKET,
  46. TOK_LANGLE,
  47. TOK_RANGLE,
  48. TOK_STAR,
  49. TOK_COMMA,
  50. TOK_EQUAL,
  51. TOK_COLON,
  52. TOK_SEMICOLON,
  53. TOK_CONST,
  54. TOK_STRUCT,
  55. TOK_UNION,
  56. TOK_SWITCH,
  57. TOK_CASE,
  58. TOK_DEFAULT,
  59. TOK_ENUM,
  60. TOK_TYPEDEF,
  61. TOK_INT,
  62. TOK_SHORT,
  63. TOK_LONG,
  64. TOK_HYPER,
  65. TOK_UNSIGNED,
  66. TOK_FLOAT,
  67. TOK_DOUBLE,
  68. TOK_OPAQUE,
  69. TOK_CHAR,
  70. TOK_STRING,
  71. TOK_BOOL,
  72. TOK_VOID,
  73. TOK_PROGRAM,
  74. TOK_VERSION,
  75. TOK_EOF
  76. };
  77. typedef enum tok_kind tok_kind;
  78. /*
  79. * a token
  80. */
  81. struct token {
  82. tok_kind kind;
  83. const char *str;
  84. };
  85. typedef struct token token;
  86. /*
  87. * routine interface
  88. */
  89. void scan(tok_kind expect, token *tokp);
  90. void scan2(tok_kind expect1, tok_kind expect2, token *tokp);
  91. void scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3, token *tokp);
  92. void scan_num(token *tokp);
  93. void peek(token *tokp);
  94. int peekscan(tok_kind expect, token *tokp);
  95. void get_token(token *tokp);
  96. void expected1(tok_kind exp1) __attribute__ ((noreturn));
  97. void expected2(tok_kind exp1, tok_kind exp2) __attribute__ ((noreturn));
  98. void expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3)
  99. __attribute__ ((noreturn));