[855] | 1 | /**************************************************************************
|
---|
| 2 | *
|
---|
| 3 | * QueryLex.h -- Lexical analyser for a simple query language
|
---|
| 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 | * $Id: QueryLex.h 855 2000-01-14 02:17:52Z sjboddie $
|
---|
| 21 | *
|
---|
| 22 | **************************************************************************/
|
---|
| 23 |
|
---|
| 24 | #ifndef QUERYLEX_H
|
---|
| 25 | #define QUERYLEX_H
|
---|
| 26 |
|
---|
| 27 | #include "UCArray.h"
|
---|
| 28 |
|
---|
| 29 |
|
---|
| 30 | // note: white space is ignored
|
---|
| 31 | enum LexType {NoTypeE, OpenBracketE, CloseBracketE, TermE, AndOpE, OrOpE,
|
---|
| 32 | NotOpE, QuoteE, IntegerE, TermWeightE, StemMethodE,
|
---|
| 33 | RangeE, AtE, TagE};
|
---|
| 34 |
|
---|
| 35 | struct LexEl {
|
---|
| 36 | LexType lexType;
|
---|
| 37 | UCArray text;
|
---|
| 38 | int num; // for IntegerE
|
---|
| 39 |
|
---|
| 40 | void Clear () {
|
---|
| 41 | lexType = NoTypeE;
|
---|
| 42 | UCArrayClear (text);
|
---|
| 43 | num = 0;
|
---|
| 44 | }
|
---|
| 45 | LexEl () { Clear (); }
|
---|
| 46 | };
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | // returns true if another lexical element could be parsed.
|
---|
| 50 | bool ParseLexEl (UCArray::const_iterator &here,
|
---|
| 51 | UCArray::const_iterator end,
|
---|
| 52 | LexEl &el);
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 | #endif
|
---|