YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
SContext.h
浏览该文件的文档.
1 /*
2  © 2012-2014 FrankHB.
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 
28 #ifndef NPL_INC_SContext_h_
29 #define NPL_INC_SContext_h_ 1
30 
31 #include "YModules.h"
32 #include YFM_NPL_Lexical
33 #include YFM_YSLib_Core_ValueNode
34 #include YFM_YSLib_Service_TextFile
35 
36 namespace NPL
37 {
38 
40 
41 using YSLib::TextFile;
42 using YSLib::ValueNode;
44 
45 using TokenList = list<string>;
46 using TLIter = TokenList::iterator;
47 using TLCIter = TokenList::const_iterator;
48 
49 
55 {
56 private:
58 
59 public:
60  Session(const string&);
62  Session(const TextFile&);
63  DefGetter(const, TokenList, TokenList, Tokenize(llex.Literalize()))
64 };
65 
66 
71 namespace SContext
72 {
73 
85 
97 Reduce(ValueNode& node, TLCIter b, TLCIter e);
98 
99 
105 YF_API void
106 Analyze(ValueNode&, const TokenList&);
107 YF_API void
108 Analyze(ValueNode&, const Session&);
109 YF_API void
110 Analyze(ValueNode&, const string&);
111 template<typename _type>
112 ValueNode
113 Analyze(const _type& arg)
114 {
115  ValueNode root;
116 
117  Analyze(root, arg);
118 
119  return root;
120 }
122 
123 } // namespace SContext;
124 
125 } // namespace NPL;
126 
127 #endif
128 
会话:分析指定 NPL 代码。
Definition: SContext.h:54
TokenList::const_iterator TLCIter
Definition: SContext.h:47
YF_API list< string > Tokenize(const list< string > &)
记号化:提取字符串列表中的记号。
Definition: Lexical.cpp:252
YF_API TLCIter Reduce(ValueNode &node, TLCIter b, TLCIter e)
遍历规约记号列表,取抽象语法树储存至指定值类型节点。
Definition: SContext.cpp:77
文本文件类。
Definition: TextFile.h:56
YF_API TLCIter Validate(TLCIter b, TLCIter e)
遍历记号列表,验证基本合法性:圆括号是否对应。
Definition: SContext.cpp:60
#define YF_API
Definition: Platform.h:64
词法分析器。
Definition: Lexical.h:70
YF_API void Analyze(ValueNode &, const TokenList &)
分析指定源,取抽象语法树储存至指定值类型节点。
Definition: SContext.cpp:96
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:180
值类型节点。
Definition: ValueNode.h:45
TokenList::iterator TLIter
Definition: SContext.h:46
list< string > TokenList
Definition: SContext.h:45
LexicalAnalyzer llex
Definition: SContext.h:57