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