2 #include "TLexerPush.hh"
4 TLexerPush::TLexerPush()
12 if (tokens.empty()) throw EmptyBuffer();
15 TToken res = tokens.front();
17 if (tokens.size() == 1 && state == CONTROL) state = ACCEPT;
23 TLexerPush::front() const
25 if (tokens.empty()) throw EmptyBuffer();
26 else return tokens.front();
30 TLexerPush::empty() const
32 return tokens.empty();
36 TLexerPush::pending() const
38 return state == ESCAPE;
42 TLexerPush::ambiguous() const
44 return tokens.size() == 1 && state == CONTROL;
48 TLexerPush::push(TChar ch)
53 if (ch == '\\') state = ESCAPE;
54 else tokens.push_back(TToken(ch));
57 tokens.push_back(TToken(TToken::CONTROL, std::string(1, ch)));
58 if (isUnicodeAlpha(ch)) state = CONTROL;
62 if (ch == '\\') state = ESCAPE;
63 else if (isUnicodeAlpha(ch))
65 assert(!tokens.empty());
66 TToken& tok = tokens.back();
67 tok.value.push_back(ch);
69 else if (isUnicodeSpace(ch)) state = IGNORE_SPACE;
72 tokens.push_back(TToken(ch));
77 if (ch == '\\') state = ESCAPE;
78 else if (isUnicodeSpace(ch)) ;
79 else tokens.push_back(TToken(ch));