Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / hunspell / src / parsers / manparser.cxx
blob25858dad8dc58765b39e14918e51fc9edbc0a49b
1 #include <cstdlib>
2 #include <cstring>
3 #include <cstdio>
4 #include <ctype.h>
6 #include "../hunspell/csutil.hxx"
7 #include "manparser.hxx"
10 #ifndef W32
11 using namespace std;
12 #endif
14 ManParser::ManParser() {
17 ManParser::ManParser(const char * wordchars)
19 init(wordchars);
22 ManParser::ManParser(unsigned short * wordchars, int len)
24 init(wordchars, len);
27 ManParser::~ManParser()
31 char * ManParser::next_token()
33 for (;;) {
34 switch (state)
36 case 1: // command arguments
37 if (line[actual][head] == ' ') state = 2;
38 break;
39 case 0: // dot in begin of line
40 if (line[actual][0] == '.') {
41 state = 1;
42 break;
43 } else {
44 state = 2;
46 // no break
47 case 2: // non word chars
48 if (is_wordchar(line[actual] + head)) {
49 state = 3;
50 token = head;
51 } else if ((line[actual][head] == '\\') &&
52 (line[actual][head + 1] == 'f') &&
53 (line[actual][head + 2] != '\0')) {
54 head += 2;
56 break;
57 case 3: // wordchar
58 if (! is_wordchar(line[actual] + head)) {
59 state = 2;
60 char * t = alloc_token(token, &head);
61 if (t) return t;
63 break;
65 if (next_char(line[actual], &head)) {
66 state = 0;
67 return NULL;