本文整理汇总了C#中System.ParserState.restore方法的典型用法代码示例。如果您正苦于以下问题:C# ParserState.restore方法的具体用法?C# ParserState.restore怎么用?C# ParserState.restore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ParserState
的用法示例。
在下文中一共展示了ParserState.restore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: parseParlist
LuaAST parseParlist() {
ParserState ps = new ParserState(this);
LuaAST rst = new LuaAST();
rst.Name = "parlist";
do
{
LuaAST namelist = parseNamelist();
if (namelist == null) break;
rst.Components.Add("namelist", namelist);
if (peek().Type == LuaTokenType.OP_comma) {
m_pos++;
if (peek().Type != LuaTokenType.OP_ellipsis) error("'...' expected");
rst.Token = peek();
m_pos++;
}
rst.start = ps.pos;
rst.end = m_pos;
return rst;
} while (false);
ps.restore();
if (peek().Type == LuaTokenType.OP_ellipsis)
{
rst.Token = peek();
m_pos++;
rst.start = ps.pos;
rst.end = m_pos;
return rst;
}
ps.restore();
return null;
}
示例2: parseVar
LuaAST parseVar() {
ParserState ps = new ParserState(this);
do
{
LuaAST prefix = parsePrefix();
if (prefix == null) break;
LuaAST suffix = parseSuffix();
LuaAST rst = new LuaAST();
rst.Name = "var";
rst.Components.Add("prefix", prefix);
while (suffix != null) {
rst.ComponentGroup.Add(suffix);
suffix = parseSuffix();
}
if (rst.ComponentGroup.Count == 0 || !rst.ComponentGroup[rst.ComponentGroup.Count - 1].Components.ContainsKey("index")) break; //error("index expected");
rst.start = ps.pos;
rst.end = m_pos;
return rst;
} while (false);
ps.restore();
do
{
LuaAST name = parseName();
if (name != null) return name;
} while (false);
ps.restore();
return null;
}
示例3: parseFunction
LuaAST parseFunction() {
ParserState ps = new ParserState(this);
do
{
if (peek().Type != LuaTokenType.KW_function) break;
m_pos++;
LuaAST body = parseFuncbody();
if (body == null) error("function body expected");
LuaAST rst = new LuaAST();
rst.Name = "function";
rst.Components.Add("funcbody", body);
rst.start = ps.pos;
rst.end = m_pos;
return rst;
} while (false);
ps.restore();
return null;
}
示例4: parseFunction
private Decl.Function parseFunction()
{
ParserState ps = new ParserState(this);
Decl.Function rst = new Decl.Function();
if (peek().Type == DeclTokenType.Comment)
{
rst.Desc = peek().Data;
m_pos++;
}
if (peek().Type == DeclTokenType.KW_Static)
{
rst.isStatic = true;
m_pos++;
}
if (peek().Type != DeclTokenType.Identifier)
{
ps.restore();
return null;
}
string id1 = peek().Data;
m_pos++;
if (peek().Type == DeclTokenType.Identifier)
{
rst.type = id1;
rst.name = peek().Data;
m_pos++;
}
else
{
rst.name = id1;
}
if (peek().Type != DeclTokenType.OP_LParen)
{
ps.restore();
return null;
}
m_pos++;
Decl.Variable var = parseVariable();
if (var != null)
{
rst.parameters.Add(var);
while (peek().Type == DeclTokenType.OP_Comma)
{
m_pos++;
Decl.Variable moreVar = parseVariable();
if (moreVar == null)
{
throw new System.Exception("Line " + peek().Line + ": variable expected");
}
rst.parameters.Add(moreVar);
}
}
if (peek().Type != DeclTokenType.OP_RParen)
{
throw new System.Exception("')' expected");
}
m_pos++;
return rst;
}
示例5: parseCall
LuaAST parseCall()
{
ParserState ps = new ParserState(this);
LuaAST rst = new LuaAST();
rst.Name = "call";
do
{
LuaAST args = parseArgs();
if (args == null) break;
rst.Components.Add("args", args);
rst.start = ps.pos;
rst.end = m_pos;
return rst;
} while (false);
ps.restore();
do
{
if (peek().Type != LuaTokenType.OP_colon) break;
m_pos++;
LuaAST name = parseName();
if (name == null) error("name expected");
rst.Components.Add("name", name);
LuaAST args = parseArgs();
if (args == null) error("args expected");
rst.Components.Add("args", args);
rst.start = ps.pos;
rst.end = m_pos;
return rst;
} while (false);
ps.restore();
return null;
}
示例6: parseFunctioncall
LuaAST parseFunctioncall() {
ParserState ps = new ParserState(this);
do
{
LuaAST prefix = parsePrefix();
if (prefix == null) break;
LuaAST rst = new LuaAST();
rst.Components.Add("prefix", prefix);
LuaAST suffix = parseSuffix();
while (suffix!=null) {
rst.ComponentGroup.Add(suffix);
suffix = parseSuffix();
}
if (rst.ComponentGroup.Count == 0) break;
LuaAST last = rst.ComponentGroup[rst.ComponentGroup.Count-1];
if (!last.Components.ContainsKey("call")) break;
rst.start = ps.pos;
rst.end = m_pos;
return rst;
} while (false);
ps.restore();
return null;
}
示例7: parseUnop
LuaAST parseUnop() {
ParserState ps = new ParserState(this);
switch (peek().Type)
{
case LuaTokenType.OP_sub:
case LuaTokenType.OP_hash:
case LuaTokenType.KW_not:
LuaAST rst = new LuaAST();
rst.Token = peek();
m_pos++;
rst.start = ps.pos;
rst.end = m_pos;
return rst;
}
ps.restore();
return null;
}
示例8: parseExp
LuaAST parseExp() {
ParserState ps = new ParserState(this);
do
{
LuaAST unop = parseUnop();
if (unop == null) break;
LuaAST exp = parseExp();
if (exp == null) error("expression expected");
LuaAST rst = new LuaAST();
rst.Name = "unopExp";
rst.Components.Add("unop", unop);
rst.Components.Add("exp", exp);
rst.start = ps.pos;
rst.end = m_pos;
return rst;
} while (false);
ps.restore();
do{
LuaAST value = parseValue();
if(value == null) break;
LuaAST rst =new LuaAST();
rst.Name = "biopExp";
rst.Components.Add("value",value);
LuaAST biop = parseBiop();
if(biop != null){
LuaAST exp = parseExp();
if(exp == null) error("expression expected");
rst.Components.Add("biop",biop);
rst.Components.Add("exp",exp);
}
rst.start = ps.pos;
rst.end = m_pos;
return rst;
}while(false);
ps.restore();
return null;
}
示例9: parseBiop
LuaAST parseBiop() {
ParserState ps = new ParserState(this);
switch (peek().Type)
{
case LuaTokenType.OP_add:
case LuaTokenType.OP_sub:
case LuaTokenType.OP_mul:
case LuaTokenType.OP_div:
case LuaTokenType.OP_pow:
case LuaTokenType.OP_mod:
case LuaTokenType.OP_doubleDot:
case LuaTokenType.OP_lt:
case LuaTokenType.OP_le:
case LuaTokenType.OP_gt:
case LuaTokenType.OP_ge:
case LuaTokenType.OP_eq:
case LuaTokenType.OP_ne:
case LuaTokenType.KW_and:
case LuaTokenType.KW_or:
LuaAST rst = new LuaAST();
rst.Token = peek();
m_pos++;
rst.start = ps.pos;
rst.end = m_pos;
return rst;
}
ps.restore();
return null;
}
示例10: parseChunk
LuaAST parseChunk() {
ParserState ps = new ParserState(this);
int i = 0;
LuaAST rst = new LuaAST();
rst.start = m_pos;
rst.Name = "chunk";
while(true)
{
ParserState statState = new ParserState(this);
try
{
LuaAST stat = parseStat();
if (stat == null) {
LuaAST laststat = parseLaststat();
if (laststat != null)
{
rst.Components.Add("laststat", laststat);
if (peek().Type == LuaTokenType.OP_semicolon)
{
m_pos++;
}
}
break;
}
rst.ComponentGroup.Add(stat);
if (peek().Type == LuaTokenType.OP_semicolon)
{
m_pos++;
}
}
catch (Exception e) {
if (errMsg == null) errMsg = e.Message;
statState.restore();
int line = peek().line;
while (peek().Type != LuaTokenType.EOF && peek().line <= line) {
m_pos++;
}
if (peek().Type == LuaTokenType.EOF)
{
break;
}
}
}
rst.end = m_pos;
return rst;
ps.restore();
return null;
}
示例11: parseFieldsep
LuaAST parseFieldsep() {
ParserState ps = new ParserState(this);
switch (peek().Type) {
case LuaTokenType.OP_comma:
case LuaTokenType.OP_semicolon:
LuaAST rst = new LuaAST();
rst.Token = peek();
m_pos++;
rst.start = ps.pos;
rst.end = m_pos;
return rst;
}
ps.restore();
return null;
}
示例12: parseFieldlist
LuaAST parseFieldlist() {
ParserState ps = new ParserState(this);
do
{
LuaAST field = parseField();
if (field == null) break;
LuaAST rst = new LuaAST();
rst.Name = "fieldlist";
rst.ComponentGroup.Add(field);
LuaAST fieldsep = parseFieldsep();
while (fieldsep != null) {
field = parseField();
if (field == null) { break; }
rst.ComponentGroup.Add(field);
fieldsep = parseFieldsep();
}
rst.start = ps.pos;
rst.end = m_pos;
return rst;
} while (false);
ps.restore();
return null;
}
示例13: parseTableconstructor
LuaAST parseTableconstructor() {
ParserState ps = new ParserState(this);
do
{
if (peek().Type != LuaTokenType.OP_lbrace) break;
m_pos++;
LuaAST rst = new LuaAST();
rst.Name = "tableconstructor";
LuaAST fieldlist = parseFieldlist();
if (fieldlist != null) {
rst.Components.Add("fieldlist", fieldlist);
}
if (peek().Type != LuaTokenType.OP_rbrace) error("'}' expected");
m_pos++;
rst.start = ps.pos;
rst.end = m_pos;
return rst;
} while (false);
ps.restore();
return null;
}
示例14: parseNamelist
LuaAST parseNamelist() {
ParserState ps = new ParserState(this);
do
{
LuaAST name = parseName();
if (name == null) break;
LuaAST rst = new LuaAST();
rst.Name = "namelist";
rst.ComponentGroup.Add(name);
while (peek().Type == LuaTokenType.OP_comma)
{
ParserState nps = new ParserState(this);
m_pos++;
name = parseName();
if (name == null)
{
nps.restore();
break;
}
rst.ComponentGroup.Add(name);
}
rst.start = ps.pos;
rst.end = m_pos;
return rst;
} while (false);
ps.restore();
return null;
}
示例15: parseName
LuaAST parseName() {
ParserState ps = new ParserState(this);
if (peek().Type == LuaTokenType.Identifier) {
LuaAST rst = new LuaAST();
rst.Name = "Name";
rst.Token = peek();
m_pos++;
rst.start = ps.pos;
rst.end = m_pos;
return rst;
}
ps.restore();
return null;
}