コード例 #1
0
ファイル: FileParser.cs プロジェクト: xiexin36/intellua
        private void parseVariables()
        {
            {
                LuaTokenizer    lt     = new LuaTokenizer(m_source.RawText, 0);
                List <LuaToken> tokens = new List <LuaToken>();
                while (true)
                {
                    LuaToken t = lt.getToken();
                    tokens.Add(t);
                    if (t.Type == LuaTokenType.EOF)
                    {
                        break;
                    }
                }
                //System.Diagnostics.Debug.Print("=========");
                LuaParser lp = new LuaParser(tokens);

                LuaAST chunk = lp.parse();
                //chunk.print(0);
                LuaASTWalker walker = new LuaASTWalker();
                if (lp.errMsg != null)
                {
                    msg = lp.errMsg;
                }

                walker.walk(chunk, result);
            }

/*
 *
 *          int pos = 0;
 *          Byte[] str = m_source.RawText;
 *
 *          for (; pos < str.Length; pos++)
 *          {
 *              char c = Convert.ToChar(str[pos]);
 *
 *              //search for assignment operator
 *
 *              if (!Parser.isCode(m_source, pos))
 *              {
 *                  continue;
 *              }
 *
 *              if (c != '=') continue;
 *              if (pos > 0)
 *              {
 *                  if (Convert.ToChar(str[pos - 1]) == '=') continue;
 *              }
 *              if (pos < str.Length - 1)
 *              {
 *                  if (Convert.ToChar(str[pos + 1]) == '=') continue;
 *              }
 *              MemberChain v = MemberChain.ParseBackward(m_source, pos - 1);
 *              if (v.Elements.Count > 1 || v.Elements.Count == 0) continue;
 *
 *              string varName = v.getLastElement();
 *              Variable var = result.Variables.getVariable(varName);
 *              //                if (var != null) continue;
 *
 *              MemberChain elem = MemberChain.ParseFoward(m_source, pos + 1);
 *              if (elem == null) continue;
 *              Type t = elem.getType(result);
 *              if (t == null) continue;
 *              //if (t.displa == "") continue;
 *              //System.Diagnostics.Debug.Print(varName + " added");
 *
 *              var = new Variable(varName);
 *              var.IsStatic = false;
 *              var.Type = t;
 *              var.StartPos = v.StartPos;
 *              var.EndPos = elem.EndPos;
 *              result.Variables.add(var);
 *          }*/
        }
コード例 #2
0
ファイル: FileParser.cs プロジェクト: juntalis/intellua
        private void parseVariables()
        {
            {
                LuaTokenizer lt = new LuaTokenizer(m_source.RawText, 0);
                List<LuaToken> tokens = new List<LuaToken>();
                while (true)
                {
                    LuaToken t = lt.getToken();
                    tokens.Add(t);
                    if (t.Type == LuaTokenType.EOF) break;
                }
                //System.Diagnostics.Debug.Print("=========");
                LuaParser lp = new LuaParser(tokens);

                LuaAST chunk = lp.parse();
                //chunk.print(0);
                LuaASTWalker walker = new LuaASTWalker();
                if (lp.errMsg != null)
                {
                    msg = lp.errMsg;
                }

                walker.walk(chunk, result);
                
                
                
            }

/*

            int pos = 0;
            Byte[] str = m_source.RawText;

            for (; pos < str.Length; pos++)
            {
                char c = Convert.ToChar(str[pos]);

                //search for assignment operator

                if (!Parser.isCode(m_source, pos))
                {
                    continue;
                }

                if (c != '=') continue;
                if (pos > 0)
                {
                    if (Convert.ToChar(str[pos - 1]) == '=') continue;
                }
                if (pos < str.Length - 1)
                {
                    if (Convert.ToChar(str[pos + 1]) == '=') continue;
                }
                MemberChain v = MemberChain.ParseBackward(m_source, pos - 1);
                if (v.Elements.Count > 1 || v.Elements.Count == 0) continue;

                string varName = v.getLastElement();
                Variable var = result.Variables.getVariable(varName);
                //                if (var != null) continue;

                MemberChain elem = MemberChain.ParseFoward(m_source, pos + 1);
                if (elem == null) continue;
                Type t = elem.getType(result);
                if (t == null) continue;
                //if (t.displa == "") continue;
                //System.Diagnostics.Debug.Print(varName + " added");

                var = new Variable(varName);
                var.IsStatic = false;
                var.Type = t;
                var.StartPos = v.StartPos;
                var.EndPos = elem.EndPos;
                result.Variables.add(var);
            }*/
        }