dceparselex.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc.
  2. See the COPYRIGHT file for more information. */
  3. #ifndef DCEPARSELEX_H
  4. #define DCEPARSELEX_H
  5. #include "config.h"
  6. #include "dcetab.h"
  7. #ifdef WIN32
  8. #define strcasecmp stricmp
  9. #define snprintf _snprintf
  10. #endif
  11. /* For consistency with Java parser */
  12. #ifndef null
  13. #define null NULL
  14. #endif
  15. typedef void* Object;
  16. #define YYSTYPE Object
  17. #define MAX_TOKEN_LENGTH 1024
  18. /*! Specifies DCElexstate. */
  19. typedef struct DCElexstate {
  20. char* input;
  21. char* next; /* next char in uri.query */
  22. NCbytes* yytext;
  23. /*! Specifies the Lasttoken. */
  24. int lasttoken;
  25. char lasttokentext[MAX_TOKEN_LENGTH+1]; /* leave room for trailing null */
  26. NClist* reclaim; /* reclaim SCAN_WORD instances */
  27. } DCElexstate;
  28. /*! Specifies DCEparsestate. */
  29. typedef struct DCEparsestate {
  30. DCEconstraint* constraint;
  31. char errorbuf[1024];
  32. int errorcode;
  33. DCElexstate* lexstate;
  34. } DCEparsestate;
  35. /* Define a generic object carrier; this serves
  36. essentially the same role as the typical bison %union
  37. declaration
  38. */
  39. extern int ceerror(DCEparsestate*,char*);
  40. extern void ce_parse_error(DCEparsestate*,const char *fmt, ...);
  41. /* bison parse entry point */
  42. extern int dceparse(DCEparsestate*);
  43. extern int dceerror(DCEparsestate* state, char* msg);
  44. extern void projections(DCEparsestate* state, Object list0);
  45. extern void selections(DCEparsestate* state, Object list0);
  46. extern Object projectionlist(DCEparsestate* state, Object list0, Object decl);
  47. extern Object projection(DCEparsestate* state, Object segmentlist);
  48. extern Object segmentlist(DCEparsestate* state, Object list0, Object decl);
  49. extern Object segment(DCEparsestate* state, Object name, Object slices0);
  50. extern Object array_indices(DCEparsestate* state, Object list0, Object decl);
  51. extern Object range(DCEparsestate* state, Object, Object, Object);
  52. extern Object selectionlist(DCEparsestate* state, Object list0, Object decl);
  53. extern Object sel_clause(DCEparsestate* state, int selcase, Object path0, Object relop0, Object values);
  54. extern Object selectionpath(DCEparsestate* state, Object list0, Object text);
  55. extern Object arrayelement(DCEparsestate* state, Object name, Object index);
  56. extern Object function(DCEparsestate* state, Object fcnname, Object args);
  57. extern Object arg_list(DCEparsestate* state, Object list0, Object decl);
  58. extern Object value_list(DCEparsestate* state, Object list0, Object decl);
  59. extern Object value(DCEparsestate* state, Object value);
  60. extern Object makeselectiontag(CEsort);
  61. extern Object indexer(DCEparsestate* state, Object name, Object indices);
  62. extern Object indexpath(DCEparsestate* state, Object list0, Object index);
  63. extern Object var(DCEparsestate* state, Object indexpath);
  64. extern Object constant(DCEparsestate* state, Object val, int tag);
  65. extern Object clauselist(DCEparsestate* state, Object list0, Object decl);
  66. extern Object range1(DCEparsestate* state, Object rangenumber);
  67. extern Object rangelist(DCEparsestate* state, Object list0, Object decl);
  68. /* lexer interface */
  69. extern int dcelex(YYSTYPE*, DCEparsestate*);
  70. extern void dcelexinit(char* input, DCElexstate** lexstatep);
  71. extern void dcelexcleanup(DCElexstate** lexstatep);
  72. extern int dcedebug;
  73. #ifdef PARSEDEBUG
  74. extern Object debugobject(Object);
  75. #define checkobject(x) debugobject(x)
  76. #else
  77. #define checkobject(x) (x)
  78. #endif
  79. extern int dapceparse(char* input, DCEconstraint*, char**);
  80. #endif /*DCEPARSELEX_H*/