本文整理汇总了C#中LexState类的典型用法代码示例。如果您正苦于以下问题:C# LexState类的具体用法?C# LexState怎么用?C# LexState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LexState类属于命名空间,在下文中一共展示了LexState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: match
/// <summary>
/// Finds the object that best matches the phrase
/// </summary>
/// <param name="phrase">The words to match</param>
/// <param name="index">The first word in phrase to match</param>
/// <param name="score">The score for the best match: 0 if no match[out]</param>
/// <param name="numWordsMatch">The number of words that match [out]</param>
/// <param name="bestMatch">The object that best matches [out]</param>
/// <param name="seen">Set of objects already examined</param>
public void match(Lexer lexer, ref double score,
ref int numWordsMatch,
ref object bestMatch,
ref LexState lexerState, Dictionary<object,object> seen)
{
// Skip if we've already seen this object
if (seen.ContainsKey(this))
return;
// Add ourself to prevent cycles
seen[this] = this;
// edge.match(lexer, ref score, ref numWordsMatch, ref bestMatch, ref lexerState, seen);
#if true
/// We only check to see if the gate matches the phrase
if (null != edge.gate)
edge.gate.match(lexer, ref score, ref numWordsMatch,
ref bestMatch, ref lexerState, seen);
// Should only match if no door, or door is open
if (null != edge.sink && (null == edge.gate || isOpen(edge.gate)))
{
// we only want match -- matchInContext checks the stuff from the parents..
edge.sink.match(lexer, ref score, ref numWordsMatch,
ref bestMatch, ref lexerState, seen);
}
#endif
}
示例2: LuaXLexError
public static void LuaXLexError(LexState ls, CharPtr msg, int token)
{
CharPtr buff = new char[MAXSRC];
LuaOChunkID(buff, GetStr(ls.source), MAXSRC);
msg = LuaOPushFString(ls.L, "%s:%d: %s", buff, ls.linenumber, msg);
if (token != 0)
LuaOPushFString(ls.L, "%s near " + LUA_QS, msg, TextToken(ls, token));
LuaDThrow(ls.L, LUA_ERRSYNTAX);
}
示例3: matchInContext
/// <summary>
/// Finds the object that best directly matches the phrase.
///
/// This naively finds the single best match. Future is to return a list
/// </summary>
/// <param name="lexer">The text being matched</param>
/// <param name="numWordsMatch">The number of words that match [out]</param>
/// <returns>The object that matches; null on error</returns>
object matchInContext(ZObject addressedTo, Lexer lexer, out int numWordsMatch,
ref LexState lexerState)
{
// A table of already examined objects
var seen = new Dictionary<object,object>();
// The score board for the search
var score = 0.0; // The score for the best match: 0 if no match
numWordsMatch = 1; // The number of words that match: Minimum of 1
object bestMatch = null;// The object that best matches
matchInContext(addressedTo, lexer, ref score, ref numWordsMatch,
ref bestMatch, ref lexerState, seen);
// Return the best match
return bestMatch;
}
示例4: primaryexp
private static void primaryexp(LexState ls, expdesc v)
{
/* primaryexp .
prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */
FuncState fs = ls.fs;
prefixexp(ls, v);
for (;;) {
switch (ls.t.token) {
case '.': { /* field */
field(ls, v);
break;
}
case '[': { /* `[' exp1 `]' */
expdesc key = new expdesc();
LuaKExp2AnyReg(fs, v);
yindex(ls, key);
LuaKIndexed(fs, v, key);
break;
}
case ':': { /* `:' NAME funcargs */
expdesc key = new expdesc();
LuaXNext(ls);
checkname(ls, key);
LuaKSelf(fs, v, key);
funcargs(ls, v);
break;
}
case '(': case (int)RESERVED.TK_STRING: case '{': { /* funcargs */
LuaKExp2NextReg(fs, v);
funcargs(ls, v);
break;
}
default: return;
}
}
}
示例5: parlist
/* }====================================================================== */
private static void parlist(LexState ls)
{
/* parlist . [ param { `,' param } ] */
FuncState fs = ls.fs;
Proto f = fs.f;
int nparams = 0;
f.is_vararg = 0;
if (ls.t.token != ')') { /* is `parlist' not empty? */
do {
switch (ls.t.token) {
case (int)RESERVED.TK_NAME: { /* param . NAME */
new_localvar(ls, str_checkname(ls), nparams++);
break;
}
case (int)RESERVED.TK_DOTS: { /* param . `...' */
LuaXNext(ls);
#if LUA_COMPAT_VARARG
/* use `arg' as default name */
new_localvarliteral(ls, "arg", nparams++);
f.is_vararg = VARARG_HASARG | VARARG_NEEDSARG;
#endif
f.is_vararg |= VARARG_ISVARARG;
break;
}
default: LuaXSyntaxError(ls, "<name> or " + LUA_QL("...") + " expected"); break;
}
} while ((f.is_vararg==0) && (testnext(ls, ',')!=0));
}
adjustlocalvars(ls, nparams);
f.numparams = CastByte(fs.nactvar - (f.is_vararg & VARARG_HASARG));
LuaKReserveRegs(fs, fs.nactvar); /* reserve register for parameters */
}
示例6: new_localvar
private static void new_localvar(LexState ls, TString name, int n)
{
FuncState fs = ls.fs;
luaY_checklimit(fs, fs.nactvar+n+1, LUAI_MAXVARS, "local variables");
fs.actvar[fs.nactvar+n] = (ushort)registerlocalvar(ls, name);
}
示例7: localstat
private static void localstat(LexState ls)
{
/* stat . LOCAL NAME {`,' NAME} [`=' explist1] */
int nvars = 0;
int nexps;
expdesc e = new expdesc();
do {
new_localvar(ls, str_checkname(ls), nvars++);
} while (testnext(ls, ',') != 0);
if (testnext(ls, '=') != 0)
nexps = explist1(ls, e);
else {
e.k = expkind.VVOID;
nexps = 0;
}
adjust_assign(ls, nvars, nexps, e);
adjustlocalvars(ls, nvars);
}
示例8: listfield
private static void listfield(LexState ls, ConsControl cc)
{
expr(ls, cc.v);
luaY_checklimit(ls.fs, cc.na, MAXINT, "items in a constructor");
cc.na++;
cc.tostore++;
}
示例9: ifstat
private static void ifstat(LexState ls, int line)
{
/* ifstat . IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */
FuncState fs = ls.fs;
int flist;
int escapelist = NO_JUMP;
flist = test_then_block(ls); /* IF cond THEN block */
while (ls.t.token == (int)RESERVED.TK_ELSEIF) {
LuaKConcat(fs, ref escapelist, LuaKJump(fs));
LuaKPatchToHere(fs, flist);
flist = test_then_block(ls); /* ELSEIF cond THEN block */
}
if (ls.t.token == (int)RESERVED.TK_ELSE) {
LuaKConcat(fs, ref escapelist, LuaKJump(fs));
LuaKPatchToHere(fs, flist);
LuaXNext(ls); /* skip ELSE (after patch, for correct line info) */
block(ls); /* `else' part */
}
else
LuaKConcat(fs, ref escapelist, flist);
LuaKPatchToHere(fs, escapelist);
check_match(ls, (int)RESERVED.TK_END, (int)RESERVED.TK_IF, line);
}
示例10: expr
private static void expr(LexState ls, expdesc v)
{
subexpr(ls, v, 0);
}
示例11: explist1
private static int explist1(LexState ls, expdesc v)
{
/* explist1 . expr { `,' expr } */
int n = 1; /* at least one expression */
expr(ls, v);
while (testnext(ls, ',') != 0) {
LuaKExp2NextReg(ls.fs, v);
expr(ls, v);
n++;
}
return n;
}
示例12: exp1
private static int exp1(LexState ls)
{
expdesc e = new expdesc();
int k;
expr(ls, e);
k = (int)e.k;
LuaKExp2NextReg(ls.fs, e);
return k;
}
示例13: error_expected
private static void error_expected(LexState ls, int token)
{
LuaXSyntaxError(ls,
LuaOPushFString(ls.L, LUA_QS + " expected", LuaXTokenToString(ls, token)));
}
示例14: enterlevel
private static void enterlevel(LexState ls)
{
if (++ls.L.nCcalls > LUAI_MAXCCALLS)
LuaXLexError(ls, "chunk has too many syntax levels", 0);
}
示例15: funcname
private static int funcname(LexState ls, expdesc v)
{
/* funcname . NAME {field} [`:' NAME] */
int needself = 0;
singlevar(ls, v);
while (ls.t.token == '.')
field(ls, v);
if (ls.t.token == ':') {
needself = 1;
field(ls, v);
}
return needself;
}