a99  V32.6
allegro Windows Hauptprogramm
 Alle Klassen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
parser.hpp
gehe zur Dokumentation dieser Datei
1 #ifndef PARSER_HPP
2 #define PARSER_HPP
3 /* Module Name: @(#)api_origin_search_parser.h 7.4
4  Version: 7/3/97
5  Author: John Hough
6 
7  Crossnet Systems Ltd.
8  Unit 3, The Paddock,
9  Hambridge Road,
10  Newbury,
11  Berkshire, RG14 5TQ
12 
13  Date of Issue:
14 
15  QA Acceptance:
16  Date of Acceptance:
17 
18  Description: Query to DbvRPNStructure generator header file.
19 */
20 
21 
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <ctype.h>
26 /* Definitions */
27 #define MAXVAL 100
28 
29 class IndexArray{// Eingerichtet als Klasse braucht man sich um das
30  // Loeschen der Elemente nicht zu kuemmern
31 public:
32  IndexArray(size_t size){Term=(char*) new char[size];}
33  ~IndexArray(){ delete [] Term;}
34  char* Term;
35 };
36 
37 typedef enum Querytype {
38  QT_Unknown = -1,
39  QT_Author = 1,
40  QT_Title = 2,
42 
43  } Querytype;
44 
45 #define MAXOPERATOR 4
46 
47 
48 /* Query type - value seperators */
49 #define QUERY_TYPE_VAL_SEP ":"
50 #define QUERY_TYPE_VAL_SEP_CHAR ':'
51 
52 /* Query type seperators */
53 #define QUERY_TYPE_SEP ","
54 
55 #define OPERATOR_AND "and"
56 #define OPERATOR_OR "or"
57 #define OPERATOR_ANDNOT "not"
58 #define OPENING_BRACKET "("
59 #define CLOSING_BRACKET ")"
60 
61 
62 #define TOKEN_SEP " "
63 
64 /* Complex term seperator must be single character */
65 #define COMPLEX_SEP '/'
66 
67 /* Attributes */
68 
69 /*****************************************************/
70 #ifndef bool
71 #define bool int
72 #define TRUE 1
73 #define FALSE 0
74 #endif
75 
76 
77 class Parser{
78 public:
79 /* Function prototypes */
80  Parser (char*);
81  ~Parser();
82  char* form_rpn_query();
83  char* Parser::GetArgument(int string_pos);
84  char postfix_str[256];
85  char *infix_str;
86  char *query;
87 
88 private:
89  IndexArray *index_array[MAXVAL];
90  int postfix_str_pos;
91  int infix_str_pos;
92  int infix_str_len;
93  int index_num;
94  int buf;
95  int vsl_infix_to_vsl_postfix();
96  void check_query_for_sep(char* query);
97  int querytypes_to_lower_case(char *query);
98  int query_val_to_vsl_infix(char *input_string, char *vsl_string, IndexArray *index_array[]);
99  bool operator_check(char *token_obtained);
100  int operator_process(char *token_obtained, char *vsl_string, char *input_string_copy);
101  int operand_process(char *token_obtained, char *vsl_string, char *input_string_copy, int *insert_pos, IndexArray *index_array[]);
102  int complex_operand_check_and_process(char *token_obtained, char *input_string_copy);
103  int remove_leading(char *string, char char_to_remove);
104  void api_get_token_from_string(char *token_obtained, char *token_delimiter, char *string);
105  int nextis(char chgiven);
106  int next(void);
107  int expression(void);
108  int term(void);
109  int factor(void);
110 };
111 #endif