当前位置: 首页>>代码示例>>C#>>正文


C# LexState类代码示例

本文整理汇总了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
 }
开发者ID:randym32,项目名称:InteractiveText-CS,代码行数:34,代码来源:ZEdge.cs

示例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);
 }
开发者ID:arkanoid1,项目名称:FakePacketSender,代码行数:9,代码来源:llex.cs

示例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;
   }
开发者ID:randym32,项目名称:InteractiveText-CS,代码行数:24,代码来源:InStory-interp.cs

示例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;
     }
       }
 }
开发者ID:niuniuzhu,项目名称:KopiLua,代码行数:36,代码来源:lparser.cs

示例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 */
 }
开发者ID:niuniuzhu,项目名称:KopiLua,代码行数:33,代码来源:lparser.cs

示例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);
 }
开发者ID:niuniuzhu,项目名称:KopiLua,代码行数:6,代码来源:lparser.cs

示例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);
 }
开发者ID:niuniuzhu,项目名称:KopiLua,代码行数:18,代码来源:lparser.cs

示例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++;
 }
开发者ID:niuniuzhu,项目名称:KopiLua,代码行数:7,代码来源:lparser.cs

示例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);
 }
开发者ID:niuniuzhu,项目名称:KopiLua,代码行数:23,代码来源:lparser.cs

示例10: expr

 private static void expr(LexState ls, expdesc v)
 {
     subexpr(ls, v, 0);
 }
开发者ID:niuniuzhu,项目名称:KopiLua,代码行数:4,代码来源:lparser.cs

示例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;
 }
开发者ID:niuniuzhu,项目名称:KopiLua,代码行数:12,代码来源:lparser.cs

示例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;
 }
开发者ID:niuniuzhu,项目名称:KopiLua,代码行数:9,代码来源:lparser.cs

示例13: error_expected

 private static void error_expected(LexState ls, int token)
 {
     LuaXSyntaxError(ls,
       LuaOPushFString(ls.L, LUA_QS + " expected", LuaXTokenToString(ls, token)));
 }
开发者ID:niuniuzhu,项目名称:KopiLua,代码行数:5,代码来源:lparser.cs

示例14: enterlevel

 private static void enterlevel(LexState ls)
 {
     if (++ls.L.nCcalls > LUAI_MAXCCALLS)
     LuaXLexError(ls, "chunk has too many syntax levels", 0);
 }
开发者ID:niuniuzhu,项目名称:KopiLua,代码行数:5,代码来源:lparser.cs

示例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;
 }
开发者ID:niuniuzhu,项目名称:KopiLua,代码行数:13,代码来源:lparser.cs


注:本文中的LexState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。