1 | /* Copyright 2009, UCAR/Unidata and OPeNDAP, Inc. |
---|
2 | See the COPYRIGHT file for more information. */ |
---|
3 | |
---|
4 | #ifndef DAPPARSELEX_H |
---|
5 | #define DAPPARSELEX_H 1 |
---|
6 | |
---|
7 | #include "ocinternal.h" |
---|
8 | #include "ocdebug.h" |
---|
9 | #ifdef USE_DAP |
---|
10 | /* To avoid "make distclean" wiping out dap.tab.h */ |
---|
11 | #include "daptab.h" |
---|
12 | #else |
---|
13 | #include "daptab.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #ifdef WIN32 |
---|
17 | #define strcasecmp stricmp |
---|
18 | #define snprintf _snprintf |
---|
19 | #endif |
---|
20 | |
---|
21 | /* For consistency with Java parser */ |
---|
22 | #define null NULL |
---|
23 | |
---|
24 | typedef void* Object; |
---|
25 | |
---|
26 | #define YYSTYPE Object |
---|
27 | |
---|
28 | #define MAX_TOKEN_LENGTH 1024 |
---|
29 | |
---|
30 | /*! Specifies the Lexstate. */ |
---|
31 | typedef struct DAPlexstate { |
---|
32 | char* input; |
---|
33 | char* next; /* next char in uri.query*/ |
---|
34 | OCbytes* yytext; |
---|
35 | int lineno; |
---|
36 | /*! Specifies the Lasttoken. */ |
---|
37 | int lasttoken; |
---|
38 | char lasttokentext[MAX_TOKEN_LENGTH+1]; |
---|
39 | char* wordchars1; |
---|
40 | char* wordcharsn; |
---|
41 | char* worddelims; |
---|
42 | OClist* reclaim; /* reclaim WORD_WORD instances */ |
---|
43 | } DAPlexstate; |
---|
44 | |
---|
45 | /*! Specifies the DAPparsestate. */ |
---|
46 | typedef struct DAPparsestate { |
---|
47 | struct OCnode* root; |
---|
48 | DAPlexstate* lexstate; |
---|
49 | OClist* ocnodes; |
---|
50 | struct OCstate* conn; |
---|
51 | /* For error returns from the server */ |
---|
52 | int svcerror; /* 1 => we had an error from the server */ |
---|
53 | char* code; |
---|
54 | char* message; |
---|
55 | char* progtype; |
---|
56 | char* progname; |
---|
57 | /* State for constraint expressions */ |
---|
58 | struct CEstate* cestate; |
---|
59 | } DAPparsestate; |
---|
60 | |
---|
61 | extern int daperror(DAPparsestate* state, const char* msg); |
---|
62 | extern void dap_parse_error(DAPparsestate*,const char *fmt, ...); |
---|
63 | /* bison parse entry point */ |
---|
64 | extern int dapparse(DAPparsestate*); |
---|
65 | |
---|
66 | extern Object dap_datasetbody(DAPparsestate*,Object decls, Object name); |
---|
67 | extern Object dap_declarations(DAPparsestate*,Object decls, Object decl); |
---|
68 | extern Object dap_arraydecls(DAPparsestate*,Object arraydecls, Object arraydecl); |
---|
69 | extern Object dap_arraydecl(DAPparsestate*,Object name, Object size); |
---|
70 | |
---|
71 | extern void dap_dassetup(DAPparsestate*); |
---|
72 | extern Object dap_attributebody(DAPparsestate*,Object attrlist); |
---|
73 | extern Object dap_attrlist(DAPparsestate*,Object attrlist, Object attrtuple); |
---|
74 | extern Object dap_attribute(DAPparsestate*,Object name, Object value, Object etype); |
---|
75 | extern Object dap_attrset(DAPparsestate*,Object name, Object attributes); |
---|
76 | extern Object dap_attrvalue(DAPparsestate*,Object valuelist, Object value, Object etype); |
---|
77 | |
---|
78 | extern Object dap_makebase(DAPparsestate*,Object name, Object etype, Object dimensions); |
---|
79 | extern Object dap_makestructure(DAPparsestate*,Object name, Object dimensions, Object fields); |
---|
80 | extern Object dap_makesequence(DAPparsestate*,Object name, Object members); |
---|
81 | extern Object dap_makegrid(DAPparsestate*,Object name, Object arraydecl, Object mapdecls); |
---|
82 | |
---|
83 | extern void dap_errorbody(DAPparsestate*, Object, Object, Object, Object); |
---|
84 | extern void dap_unrecognizedresponse(DAPparsestate*); |
---|
85 | |
---|
86 | extern void dap_tagparse(DAPparsestate*,int); |
---|
87 | |
---|
88 | /* Lexer entry points */ |
---|
89 | extern int daplex(YYSTYPE*, DAPparsestate*); |
---|
90 | extern void daplexinit(char* input, DAPlexstate** lexstatep); |
---|
91 | extern void daplexcleanup(DAPlexstate** lexstatep); |
---|
92 | extern void dapsetwordchars(DAPlexstate* lexstate, int kind); |
---|
93 | extern char* dapdecode(DAPlexstate*,char*); |
---|
94 | |
---|
95 | #endif /*DAPPARSELEX_H*/ |
---|