home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fns101.zip / Add-Ons / Fnorb / src / bisonmodule.h < prev    next >
C/C++ Source or Header  |  1999-06-28  |  1KB  |  44 lines

  1. #ifndef __BISON_MODULE_H
  2. #define __BISON_MODULE_H
  3.  
  4. #include "Python.h"
  5.  
  6. /* Exceptions defined in 'bisonmodule.c'. */
  7. extern PyObject* Py_YYERROR;
  8. extern PyObject* Py_YYABORT;
  9.  
  10. /* The Python instance that implements the semantic actions. */
  11. PyObject* py_parser;
  12.  
  13. /* Shorthand. */
  14. #define CALL_METHOD PyObject_CallMethod
  15.  
  16. #define CALL_0(m)          CALL_METHOD(py_parser, (m), NULL)
  17. #define CALL_1(m, a)           CALL_METHOD(py_parser, (m), "O", (a))
  18. #define CALL_2(m, a, b)          CALL_METHOD(py_parser, (m), "OO", (a), (b))
  19. #define CALL_3(m, a, b, c)    CALL_METHOD(py_parser, (m), "OOO", (a), (b), (c))
  20. #define CALL_4(m, a, b, c, d) CALL_METHOD(py_parser, (m), "OOOO", \
  21.                       (a), (b), (c), (d))
  22. #define CHECK_EXCEPTION \
  23. if (PyErr_Occurred() != NULL) \
  24. { \
  25.     if (PyErr_ExceptionMatches(Py_YYERROR)) \
  26.     { \
  27.         PyErr_Clear(); \
  28.         yynerrs++; \
  29.         YYERROR; \
  30.     } \
  31.     else if (PyErr_ExceptionMatches(Py_YYABORT)) \
  32.     { \
  33.         PyErr_Clear(); \
  34.         YYABORT; \
  35.     } \
  36.     else \
  37.     { \
  38.         PyErr_Print(); \
  39.         YYABORT; \
  40.     } \
  41. }
  42.  
  43. #endif /* # ifndef __BISON_MODULE_H */
  44.