YSTest
PreAlpha_b400_20130424
The YSLib Test Project
首页
相关页面
模块
命名空间
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
Lexical.h
浏览该文件的文档.
1
/*
2
Copyright (C) by Franksoft 2012.
3
4
This file is part of the YSLib project, and may only be used,
5
modified, and distributed under the terms of the YSLib project
6
license, LICENSE.TXT. By continuing to use, modify, or distribute
7
this file you indicate that you have read the license and
8
understand and accept it fully.
9
*/
10
32
#ifndef NPL_INC_LEXICAL_H_
33
#define NPL_INC_LEXICAL_H_
34
35
#include "
YSLib/Adaptor/ycont.h
"
36
#include <cctype>
// for std::isgraph;
37
38
YSL_BEGIN_NAMESPACE
(NPL)
39
40
41
42
using ystdex::
byte
;
43
using YSLib::list;
44
using YSLib::
string
;
46
72
class
YF_API
LexicalAnalyzer
73
{
74
public
:
79
static
yconstexpr
size_t
MaxEscapeLength = 8;
80
81
private
:
87
size_t
esc
;
92
char
escs[MaxEscapeLength];
97
char
ld
;
101
string
cbuf
;
105
list<size_t>
qlist
;
106
107
public
:
108
LexicalAnalyzer();
109
110
DefGetter
(
const
ynothrow
,
const
string
&, Buffer, cbuf)
111
DefGetter
(const
ynothrow
, const list<
size_t
>&, Quotes, qlist)
112
113
private:
114
void
115
HandleEscape();
116
117
void
118
PushEscape();
119
120
public:
121
/*
122
\brief 解析单个字符并添加至字符解析结果。
123
*/
124
void
125
ParseByte(byte);
126
131
list<
string
>
132
Literalize() const;
133
};
134
135
142
YF_API
char
143
CheckLiteral
(const
string
&);
144
150
YF_API
string
151
Deliteralize
(const
string
&);
152
158
YF_API
string
159
MakeEscape
(const
string
&);
160
161
166
yconstfn
bool
167
IsGraphicalDelimeter
(
char
c)
168
{
169
// return std::ispunct(c);
170
return
c ==
'('
|| c ==
')'
|| c ==
':'
|| c ==
','
|| c ==
';'
171
|| c ==
'#'
|| c ==
'%'
|| c ==
'!'
;
172
}
173
178
yconstfn
bool
179
IsDelimeter
(
char
c)
180
{
181
return
byte
(c) < 0x80 && (!std::isgraph(c) ||
IsGraphicalDelimeter
(c));
182
}
183
184
189
YF_API
list<string>
190
Decompose
(
const
string
&);
191
197
YF_API
list<string>
198
Tokenize
(
const
list<string>&);
199
200
YSL_END_NAMESPACE
(NPL)
201
202
#endif
203
YFramework
include
NPL
Lexical.h
生成于 2013年 四月 24日 星期三 18:41:27 , 为 YSTest使用
1.8.2