~ubuntu-branches/ubuntu/gutsy/icu/gutsy-updates

« back to all changes in this revision

Viewing changes to source/i18n/ucol_tok.h

  • Committer: Package Import Robot
  • Author(s): Jay Berkenbilt
  • Date: 2005-11-19 11:29:31 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20051119112931-vcizkrp10tli4enw
Tags: 3.4-3
Explicitly build with g++ 3.4.  The current ICU fails its test suite
with 4.0 but not with 3.4.  Future versions should work properly with
4.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
*******************************************************************************
3
 
*
4
 
*   Copyright (C) 2001, International Business Machines
5
 
*   Corporation and others.  All Rights Reserved.
6
 
*
7
 
*******************************************************************************
8
 
*   file name:  ucol_tok.h
9
 
*   encoding:   US-ASCII
10
 
*   tab size:   8 (not used)
11
 
*   indentation:4
12
 
*
13
 
*   created 02/22/2001
14
 
*   created by: Vladimir Weinstein
15
 
*
16
 
* This module reads a tailoring rule string and produces a list of 
17
 
* tokens that will be turned into collation elements
18
 
19
 
*/
20
 
 
21
 
#ifndef UCOL_TOKENS_H
22
 
#define UCOL_TOKENS_H
23
 
 
24
 
#include "ucol_imp.h"
25
 
#include "uhash.h"
26
 
#include "unicode/parseerr.h"
27
 
 
28
 
#define UCOL_TOK_UNSET 0xFFFFFFFF
29
 
#define UCOL_TOK_RESET 0xDEADBEEF
30
 
 
31
 
#define UCOL_TOK_POLARITY_NEGATIVE 0
32
 
#define UCOL_TOK_POLARITY_POSITIVE 1
33
 
 
34
 
#define UCOL_TOK_TOP 0x04
35
 
#define UCOL_TOK_VARIABLE_TOP 0x08
36
 
#define UCOL_TOK_BEFORE 0x03
37
 
#define UCOL_TOK_SUCCESS 0x10
38
 
 
39
 
/* this is space for the extra strings that need to be unquoted */
40
 
/* during the parsing of the rules */
41
 
#define UCOL_TOK_EXTRA_RULE_SPACE_SIZE 2048
42
 
typedef struct UColToken UColToken;
43
 
 
44
 
typedef struct  {
45
 
  UColToken* first;
46
 
  UColToken* last;
47
 
  UColToken* reset;
48
 
  UBool indirect;
49
 
  uint32_t baseCE;
50
 
  uint32_t baseContCE;
51
 
  uint32_t nextCE;
52
 
  uint32_t nextContCE;
53
 
  uint32_t previousCE;
54
 
  uint32_t previousContCE;
55
 
  int32_t pos[UCOL_STRENGTH_LIMIT];
56
 
  uint32_t gapsLo[3*UCOL_CE_STRENGTH_LIMIT];
57
 
  uint32_t gapsHi[3*UCOL_CE_STRENGTH_LIMIT];
58
 
  uint32_t numStr[UCOL_CE_STRENGTH_LIMIT];
59
 
  UColToken* fStrToken[UCOL_CE_STRENGTH_LIMIT];
60
 
  UColToken* lStrToken[UCOL_CE_STRENGTH_LIMIT];
61
 
} UColTokListHeader;
62
 
 
63
 
struct UColToken {
64
 
  UChar debugSource;
65
 
  UChar debugExpansion;
66
 
  UChar debugPrefix;
67
 
  uint32_t CEs[128];
68
 
  uint32_t noOfCEs;
69
 
  uint32_t expCEs[128];
70
 
  uint32_t noOfExpCEs;
71
 
  uint32_t source;
72
 
  uint32_t expansion;
73
 
  uint32_t prefix;
74
 
  uint32_t strength;
75
 
  uint32_t toInsert;
76
 
  uint32_t polarity; /* 1 for <, <<, <<<, , ; and -1 for >, >>, >>> */
77
 
  UColTokListHeader *listHeader;
78
 
  UColToken* previous;
79
 
  UColToken* next;
80
 
  UChar *rulesToParse;
81
 
};
82
 
 
83
 
/* 
84
 
 * This is a token that has been parsed
85
 
 * but not yet processed. Used to reduce
86
 
 * the number of arguments in the parser
87
 
 */
88
 
typedef struct {
89
 
  uint32_t strength;
90
 
  uint32_t charsOffset;
91
 
  uint32_t charsLen;
92
 
  uint32_t extensionOffset;
93
 
  uint32_t extensionLen;
94
 
  uint32_t prefixOffset;
95
 
  uint32_t prefixLen;
96
 
  uint16_t flags;
97
 
  uint16_t indirectIndex;
98
 
} UColParsedToken;
99
 
 
100
 
 
101
 
typedef struct {
102
 
  UColParsedToken parsedToken;
103
 
  UChar *source;
104
 
  UChar *end;
105
 
  UChar *current;
106
 
  UChar *sourceCurrent;
107
 
  UChar *extraCurrent;
108
 
  UChar *extraEnd;
109
 
  const InverseTableHeader *invUCA;
110
 
  const UCollator *UCA;
111
 
  UHashtable *tailored;
112
 
  UColOptionSet *opts;
113
 
  uint32_t resultLen;
114
 
  UColTokListHeader *lh;
115
 
  UColToken *varTop;
116
 
} UColTokenParser;
117
 
 
118
 
typedef struct {
119
 
  const UChar *subName;
120
 
  int32_t subLen;
121
 
  UColAttributeValue attrVal;
122
 
} ucolTokSuboption;
123
 
 
124
 
typedef struct {
125
 
   const UChar *optionName;
126
 
   int32_t optionLen;
127
 
   const ucolTokSuboption *subopts;
128
 
   int32_t subSize;
129
 
   UColAttribute attr;
130
 
} ucolTokOption;
131
 
 
132
 
#define ucol_tok_isSpecialChar(ch)              \
133
 
    (((((ch) <= 0x002F) && ((ch) >= 0x0020)) || \
134
 
      (((ch) <= 0x003F) && ((ch) >= 0x003A)) || \
135
 
      (((ch) <= 0x0060) && ((ch) >= 0x005B)) || \
136
 
      (((ch) <= 0x007E) && ((ch) >= 0x007D)) || \
137
 
      (ch) == 0x007B))
138
 
 
139
 
 
140
 
U_CFUNC 
141
 
uint32_t ucol_tok_assembleTokenList(UColTokenParser *src,
142
 
                                    UParseError *parseError, 
143
 
                                    UErrorCode *status);
144
 
 
145
 
U_CFUNC
146
 
void ucol_tok_initTokenList(UColTokenParser *src, const UChar *rules, const uint32_t rulesLength, UCollator *UCA, UErrorCode *status);
147
 
 
148
 
U_CFUNC void ucol_tok_closeTokenList(UColTokenParser *src);
149
 
 
150
 
U_CAPI const UChar* U_EXPORT2 ucol_tok_parseNextToken(UColTokenParser *src, 
151
 
                        UBool startOfRules,
152
 
                        UParseError *parseError,
153
 
                        UErrorCode *status);
154
 
 
155
 
 
156
 
#endif
157
 
 
158
 
 
159
 
 
160
 
 
161