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