]> git.lyx.org Git - features.git/blob - src/3rdparty/hunspell/1.3.3/src/parsers/textparser.hxx
add stripped down hunspell 1.3.3
[features.git] / src / 3rdparty / hunspell / 1.3.3 / src / parsers / textparser.hxx
1 /*
2  * parser classes for MySpell
3  *
4  * implemented: text, HTML, TeX
5  *
6  * Copyright (C) 2002, Laszlo Nemeth
7  *
8  */
9
10 #ifndef _TEXTPARSER_HXX_
11 #define _TEXTPARSER_HXX_
12
13 // set sum of actual and previous lines
14 #define MAXPREVLINE 4
15
16 #ifndef MAXLNLEN
17 #define MAXLNLEN        8192
18 #endif
19
20 /*
21  * Base Text Parser
22  *
23  */
24
25 class TextParser
26 {
27
28 protected:
29   int                 wordcharacters[256]; // for detection of the word boundaries
30   char                line[MAXPREVLINE][MAXLNLEN]; // parsed and previous lines
31   char                urlline[MAXLNLEN]; // mask for url detection
32   int                 checkurl;
33   int                 actual; // actual line
34   int                 head;   // head position
35   int                 token;  // begin of token
36   int                 state;  // state of automata
37   int                 utf8;   // UTF-8 character encoding
38   int                 next_char(char * line, int * pos);
39   unsigned short *    wordchars_utf16;
40   int                 wclen;
41
42 public:
43  
44   TextParser();
45   TextParser(unsigned short * wordchars, int len);
46   TextParser(const char * wc);
47   void                init(const char *);
48   void                init(unsigned short * wordchars, int len);
49   virtual ~TextParser();
50
51   void                put_line(char * line);
52   char *              get_line();
53   char *              get_prevline(int n);
54   virtual char *      next_token();
55   virtual int         change_token(const char * word);
56   void                set_url_checking(int check);
57
58   int                 get_tokenpos();
59   int                 is_wordchar(char * w);
60   inline int          is_utf8() { return utf8; }
61   const char *        get_latin1(char * s);
62   char *              next_char();
63   int                 tokenize_urls();
64   void                check_urls();
65   int                 get_url(int token_pos, int * head);
66   char *              alloc_token(int token, int * head);
67 };
68
69 #endif
70