srcpos.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright 2007 Jon Loeliger, Freescale Semiconductor, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  17. * USA
  18. */
  19. /*
  20. * Augment the standard YYLTYPE with a filenum index into an
  21. * array of all opened filenames.
  22. */
  23. #if ! defined(YYLTYPE) && ! defined(YYLTYPE_IS_DECLARED)
  24. typedef struct YYLTYPE {
  25. int first_line;
  26. int first_column;
  27. int last_line;
  28. int last_column;
  29. int filenum;
  30. } YYLTYPE;
  31. #define YYLTYPE_IS_DECLARED 1
  32. #define YYLTYPE_IS_TRIVIAL 1
  33. #endif
  34. /* Cater to old parser templates. */
  35. #ifndef YYID
  36. #define YYID(n) (n)
  37. #endif
  38. #define YYLLOC_DEFAULT(Current, Rhs, N) \
  39. do \
  40. if (YYID (N)) \
  41. { \
  42. (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
  43. (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
  44. (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
  45. (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
  46. (Current).filenum = YYRHSLOC (Rhs, N).filenum; \
  47. } \
  48. else \
  49. { \
  50. (Current).first_line = (Current).last_line = \
  51. YYRHSLOC (Rhs, 0).last_line; \
  52. (Current).first_column = (Current).last_column = \
  53. YYRHSLOC (Rhs, 0).last_column; \
  54. (Current).filenum = YYRHSLOC (Rhs, 0).filenum; \
  55. } \
  56. while (YYID (0))
  57. extern void yyerror(char const *);
  58. extern int srcpos_filenum;
  59. extern int push_input_file(const char *filename);
  60. extern int pop_input_file(void);
  61. extern FILE *dtc_open_file(const char *fname);
  62. extern int lookup_file_name(const char *fname, int add_it);
  63. extern const char *srcpos_filename_for_num(int filenum);
  64. const char *srcpos_get_filename(void);