parse.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*************************************************************************
  2. * Copyright (c) 2011 AT&T Intellectual Property
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * https://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors: Details at https://graphviz.org
  9. *************************************************************************/
  10. #pragma once
  11. #include <cgraph/list.h>
  12. #include <stdlib.h>
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. typedef enum { Begin =
  17. 0, End, BeginG, EndG, Node, Edge, Eof, Error } case_t;
  18. typedef struct {
  19. int gstart;
  20. char *guard;
  21. int astart;
  22. char *action;
  23. } case_info;
  24. static inline void free_case_info(case_info c) {
  25. free(c.guard);
  26. free(c.action);
  27. }
  28. DEFINE_LIST_WITH_DTOR(case_infos, case_info, free_case_info)
  29. typedef struct {
  30. int l_beging;
  31. char *begg_stmt;
  32. case_infos_t node_stmts;
  33. case_infos_t edge_stmts;
  34. } parse_block;
  35. DEFINE_LIST(parse_blocks, parse_block)
  36. typedef struct {
  37. char *source;
  38. int l_begin, l_end, l_endg;
  39. char *begin_stmt;
  40. parse_blocks_t blocks;
  41. char *endg_stmt;
  42. char *end_stmt;
  43. } parse_prog;
  44. extern parse_prog *parseProg(char *, int);
  45. extern void freeParseProg (parse_prog *);
  46. #ifdef __cplusplus
  47. }
  48. #endif