1 | /**************************************************************************
|
---|
2 | *
|
---|
3 | * GSDLQueryLex.h -- Lexical analyser for a simple query language, for GSDL
|
---|
4 | * Copyright (C) 2000 Rodger McNab
|
---|
5 | *
|
---|
6 | * This program is free software; you can redistribute it and/or modify
|
---|
7 | * it under the terms of the GNU General Public License as published by
|
---|
8 | * the Free Software Foundation; either version 2 of the License, or
|
---|
9 | * (at your option) any later version.
|
---|
10 | *
|
---|
11 | * This program is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | * GNU General Public License for more details.
|
---|
15 | *
|
---|
16 | * You should have received a copy of the GNU General Public License
|
---|
17 | * along with this program; if not, write to the Free Software
|
---|
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
19 | *
|
---|
20 | **************************************************************************/
|
---|
21 |
|
---|
22 | #ifndef GSDLQUERYLEX_H
|
---|
23 | #define GSDLQUERYLEX_H
|
---|
24 |
|
---|
25 | #include "UCArray.h"
|
---|
26 |
|
---|
27 |
|
---|
28 | // note: white space is ignored
|
---|
29 | enum LexType {NoTypeE, OpenBracketE, CloseBracketE, TermE, AndOpE, OrOpE,
|
---|
30 | NotOpE, NearOpE, QuoteE, IntegerE, TermWeightE, StemMethodE,
|
---|
31 | RangeE, AtE, TagE, OpenSquareBracketE, CloseSquareBracketE};
|
---|
32 |
|
---|
33 | struct LexEl {
|
---|
34 | LexType lexType;
|
---|
35 | UCArray text;
|
---|
36 | int num; // for IntegerE
|
---|
37 |
|
---|
38 | void Clear () {
|
---|
39 | lexType = NoTypeE;
|
---|
40 | UCArrayClear (text);
|
---|
41 | num = 0;
|
---|
42 | }
|
---|
43 | LexEl () { Clear (); }
|
---|
44 | };
|
---|
45 |
|
---|
46 |
|
---|
47 | // returns true if another lexical element could be parsed.
|
---|
48 | bool ParseLexEl (UCArray::const_iterator &here,
|
---|
49 | UCArray::const_iterator end,
|
---|
50 | LexEl &el);
|
---|
51 |
|
---|
52 |
|
---|
53 | #endif
|
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|
60 |
|
---|
61 |
|
---|
62 |
|
---|
63 |
|
---|