blob: 83ba2b1a583b95498abb593a16ab05c007198748 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#ifndef PARSER_HPP
#define PARSER_HPP
/* Based on Paul Williams's parser,
http://www.vt100.net/emu/dec_ansi_parser */
#include <wchar.h>
#include <list>
#include <string.h>
#include "parsertransition.h"
#include "parseraction.h"
#include "parserstate.h"
#include "parserstatefamily.h"
#ifndef __STDC_ISO_10646__
#error "Must have __STDC_ISO_10646__"
#endif
namespace Parser {
static const StateFamily family;
class Parser {
private:
State const *state;
public:
Parser() : state( &family.s_Ground ) {}
Parser( const Parser &other );
Parser & operator=( const Parser & );
~Parser() {}
std::list<Action *> input( wchar_t ch );
bool operator==( const Parser &x ) const
{
return state == x.state;
}
bool is_grounded( void ) const { return state == &family.s_Ground; }
};
static const size_t BUF_SIZE = 8;
class UTF8Parser {
private:
Parser parser;
char buf[ BUF_SIZE ];
size_t buf_len;
public:
UTF8Parser();
std::list<Action *> input( char c );
bool operator==( const UTF8Parser &x ) const
{
return parser == x.parser;
}
bool is_grounded( void ) const { return parser.is_grounded(); }
};
}
#endif
|