nasm-parser-struct.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * NASM-compatible parser struct header file
  3. *
  4. * Copyright (C) 2002-2007 Peter Johnson
  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 OTHER CONTRIBUTORS ``AS IS''
  16. * AND 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 OTHER CONTRIBUTORS BE
  19. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. * POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #ifndef YASM_NASM_PARSER_STRUCT_H
  28. #define YASM_NASM_PARSER_STRUCT_H
  29. typedef union {
  30. unsigned int int_info;
  31. char *str_val;
  32. yasm_intnum *intn;
  33. yasm_floatnum *flt;
  34. yasm_bytecode *bc;
  35. uintptr_t arch_data;
  36. struct {
  37. char *contents;
  38. size_t len;
  39. } str;
  40. } nasm_yystype;
  41. typedef struct yasm_parser_nasm {
  42. int tasm;
  43. int masm;
  44. /*@only@*/ yasm_object *object;
  45. /* last "base" label for local (.) labels */
  46. /*@null@*/ char *locallabel_base;
  47. size_t locallabel_base_len;
  48. /*@dependent@*/ yasm_preproc *preproc;
  49. /*@dependent@*/ yasm_errwarns *errwarns;
  50. /*@dependent@*/ yasm_linemap *linemap;
  51. /*@null@*/ yasm_bytecode *prev_bc;
  52. int save_input;
  53. yasm_scanner s;
  54. int state;
  55. int token; /* enum tokentype or any character */
  56. nasm_yystype tokval;
  57. char tokch; /* first character of token */
  58. /* one token of lookahead; used sparingly */
  59. int peek_token; /* NONE if none */
  60. nasm_yystype peek_tokval;
  61. char peek_tokch;
  62. /* Starting point of the absolute section. NULL if not in an absolute
  63. * section.
  64. */
  65. /*@null@*/ yasm_expr *absstart;
  66. /* Current location inside an absolute section (including the start).
  67. * NULL if not in an absolute section.
  68. */
  69. /*@null@*/ yasm_expr *abspos;
  70. } yasm_parser_nasm;
  71. #endif