/Parser/parser.h

http://unladen-swallow.googlecode.com/ · C++ Header · 42 lines · 32 code · 8 blank · 2 comment · 0 complexity · d0e470bc4ce9dbe6117c6b124c677127 MD5 · raw file

  1. #ifndef Py_PARSER_H
  2. #define Py_PARSER_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /* Parser interface */
  7. #define MAXSTACK 1500
  8. typedef struct {
  9. int s_state; /* State in current DFA */
  10. dfa *s_dfa; /* Current DFA */
  11. struct _node *s_parent; /* Where to add next node */
  12. } stackentry;
  13. typedef struct {
  14. stackentry *s_top; /* Top entry */
  15. stackentry s_base[MAXSTACK];/* Array of stack entries */
  16. /* NB The stack grows down */
  17. } stack;
  18. typedef struct {
  19. stack p_stack; /* Stack of parser states */
  20. grammar *p_grammar; /* Grammar to use */
  21. node *p_tree; /* Top of parse tree */
  22. #ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
  23. unsigned long p_flags; /* see co_flags in Include/code.h */
  24. #endif
  25. } parser_state;
  26. parser_state *PyParser_New(grammar *g, int start);
  27. void PyParser_Delete(parser_state *ps);
  28. int PyParser_AddToken(parser_state *ps, int type, char *str, int lineno, int col_offset,
  29. int *expected_ret);
  30. void PyGrammar_AddAccelerators(grammar *g);
  31. #ifdef __cplusplus
  32. }
  33. #endif
  34. #endif /* !Py_PARSER_H */