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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
#ifndef XIFT_INCLUDED_XIFT
#define XIFT_INCLUDED_XIFT
#include "exporter.hpp"
#include "tag.hpp"
#include <stdio.h>
enum XiftError {
xift_ok = 0,
xift_wrong_char,
xift_attr_sep,
xift_something_after_close,
xift_close_selfclose,
xift_unwanted_close
};
const char *xift_error_message(XiftError error);
class Xift: public XiftTags {
public:
Xift(XiftExporter &exporter);
void Put(char c);
void Put(const char *str);
void Put(FILE *file);
void PutFile(const char *path);
bool End();
bool IsError();
int ErrorPosition();
int ErrorLine();
int ErrorColumn();
XiftError GetError();
private:
int error_pos;
int error_line;
int error_column;
XiftError error;
XiftExporter &exporter;
XiftTags opened;
enum State {
state_error = 0,
reading_text,
opening_tag,
reading_name,
waiting_attr,
reading_attr_name,
waiting_attr_sep,
waiting_attr_value,
reading_attr_value,
closing_tag
} state;
char value_quota;
bool is_closing;
bool is_self_closing;
void ReadText(char c);
void OpenTag(char c);
void ReadName(char c);
void WaitAttr(char c);
void ReadAttrName(char c);
void WaitAttrSep(char c);
void WaitAttrValue(char c);
void ReadAttrValue(char c);
void CloseTag(char c);
void CompleteCurrent();
void CloseCurrent();
void CloseTop();
void CloseName(const char *name);
void SelfcloseCurrent();
void PutCurrent();
static bool AllowedInTokenStart(char c);
static bool AllowedInToken(char c);
static bool IsWhitespace(char c);
};
#endif
|