Example #1
0
        private static void ReadFunc(ScriptInfo SI, XmlElement funcElem)
        {
            string       name    = string.Empty;
            MemberAccess access  = MemberAccess.Public;
            string       returns = string.Empty;
            string       summary = string.Empty;
            string       self    = string.Empty;
            string       example = string.Empty;

            List <FuncParamInfo> parameters = new List <FuncParamInfo>();

            name   = funcElem.GetAttribute("name");
            access = (MemberAccess)Enum.Parse(typeof(MemberAccess), funcElem.GetAttribute("access"));
            foreach (XmlNode curNode in funcElem)
            {
                if (!(curNode is XmlElement))
                {
                    continue;
                }

                XmlElement curElem = (XmlElement)curNode;

                if (curElem.Name == "summary")
                {
                    summary = curElem.InnerText;
                }
                else if (curElem.Name == "returns")
                {
                    returns = curElem.InnerText;
                }
                else if (curElem.Name == "self")
                {
                    self = curElem.InnerText;
                }
                else if (curElem.Name == "example")
                {
                    example = curElem.InnerText;
                }
                else if (curElem.Name == "param")
                {
                    string isOut     = curElem.GetAttribute("out");
                    string isOpt     = curElem.GetAttribute("opt");
                    bool   isOutBool = String.IsNullOrEmpty(isOut) ? false : Boolean.Parse(isOut);
                    bool   isOptBool = String.IsNullOrEmpty(isOpt) ? false : Boolean.Parse(isOpt);

                    parameters.Add(new FuncParamInfo(curElem.GetAttribute("name"), curElem.InnerText, isOutBool, isOptBool));
                }
                else
                {
                    throw new XmlException("Unknown ScriptInfo func node '" + curElem.Name + "'");
                }
            }

            FuncInfo funcInfo = new FuncInfo(SI.SF, name, access, summary, returns, self, example, null);

            foreach (FuncParamInfo param in parameters)
            {
                funcInfo.AddParam(param);
            }
            SI.AddFunction(funcInfo);
        }
Example #2
0
        public static ScriptInfo ReadFromFile(ScriptFile SF, string fileFullPath, out bool successfully)
        {
            ScriptInfo SI = new ScriptInfo(SF);

            SI.CreateTime = DateTime.Now;

            XmlDocument doc = new XmlDocument();

            doc.Load(fileFullPath);

            successfully = true;

            foreach (XmlNode curNode in doc.DocumentElement.ChildNodes)
            {
                if (!(curNode is XmlElement))
                {
                    continue;
                }

                XmlElement curElem = (XmlElement)curNode;

                if (curElem.Name == "settings")
                {
                    SI.IsGlobal = Boolean.Parse(curElem.GetAttribute("global"));

                    string successfullyStr = curElem.GetAttribute("successfully");
                    successfully = (String.IsNullOrEmpty(successfullyStr) || successfullyStr == "True");

                    string isCompiledStr = curElem.GetAttribute("compiled");
                    SI.IsCompiled = String.IsNullOrEmpty(isCompiledStr) ? false : Boolean.Parse(isCompiledStr);

                    foreach (XmlNode settingNode in curElem.ChildNodes)
                    {
                        if (!(settingNode is XmlElement))
                        {
                            continue;
                        }

                        XmlElement settingElem = (XmlElement)settingNode;

                        if (settingElem.Name == "name")
                        {
                            SI.Name = settingElem.InnerText;
                        }
                        else
                        {
                            throw new XmlException("Unknown ScriptInfo settings node '" + settingElem.Name + "'");
                        }
                    }
                }
                else if (curElem.Name == "content")
                {
                    foreach (XmlNode contentNode in curElem.ChildNodes)
                    {
                        if (!(contentNode is XmlElement))
                        {
                            continue;
                        }

                        XmlElement contentElem = (XmlElement)contentNode;

                        IReferenceInfo refInfo;
                        switch (contentElem.Name)
                        {
                        case "include":
                            ReadInclude(SI, contentElem);
                            break;

                        case "using":
                            ReadUsing(SI, contentElem);
                            break;

                        case "const":
                            ReadConst(SI, contentElem);
                            break;

                        case "func":
                            ReadFunc(SI, contentElem);
                            break;

                        case "usingRef":
                            refInfo = UsingRefInfo.FromXML(contentElem, SI);
                            if (refInfo != null)
                            {
                                SI.References.Add(refInfo);
                            }

                            break;

                        case "constRef":
                            refInfo = ConstRefInfo.FromXML(contentElem, SI);
                            if (refInfo != null)
                            {
                                SI.References.Add(refInfo);
                            }

                            break;

                        case "funcRef":
                            refInfo = FuncRefInfo.FromXML(contentElem, SI);
                            if (refInfo != null)
                            {
                                SI.References.Add(refInfo);
                            }

                            break;

                        case "error":
                            Error error = Error.FromXML(contentElem, SF);
                            if (error != null)
                            {
                                SF.Errors.Add(error);
                            }

                            break;

                        default:
                            throw new XmlException("Unknown ScriptInfo content node '" + contentElem.Name + "'");
                        }
                    }
                }
                else
                {
                    throw new XmlException("Unknown ScriptInfo node '" + curElem.Name + "'");
                }
            }
            return(SI);
        }
Example #3
0
 public void CheckSemantic(MoveInfo treeInfo, ScriptInfo scriptInfo, CheckingInfo checkingInfo)
 {
     // funkcia by sa teoreticky nikdy nemala zavolaƄ!
     throw new InvalidOperationException("WTF?!");
 }
Example #4
0
 public virtual void Compile(MoveInfo treeInfo, ScriptInfo scriptInfo, CompilingInfo compilingInfo)
 {
     throw new InvalidOperationException("WTF?!");
 }
Example #5
0
        public static BaseTree Parse(List <IElement> sourceTokens, ScriptFile sf, ScriptInfo scriptInfo)
        {
            BaseTree tree = new BaseTree(sourceTokens);

            tree._sf = sf;

            MoveInfo parser = new MoveInfo(tree, SearchTree.ChildrenBlock, 0, sf);

            ParsingInfo parsingInfo = new ParsingInfo(sf);

            // parse all groups
            MoveInfo groupInfo = new MoveInfo(tree, SearchTree.ContentTree, 0, sf);
            IElement cur       = groupInfo.Find(SearchDirection.LeftToRight, SearchVisibility.Visible);

            while (cur != null)
            {
                Group.Check(groupInfo, parsingInfo, scriptInfo);
                cur = groupInfo.FindNextBlack(SearchDirection.LeftToRight);
            }

            // parse delegate call [[delegate]]
            MoveInfo delegateInfo = new MoveInfo(tree, SearchTree.ContentTree, 0, sf);

            cur = delegateInfo.Find(SearchDirection.LeftToRight, SearchVisibility.Visible);
            while (cur != null)
            {
                DelegateCallGroup.Check(delegateInfo, parsingInfo, scriptInfo);
                cur = delegateInfo.FindNextBlack(SearchDirection.LeftToRight);
            }

            // create parse tree
            MoveInfo contentInfo = new MoveInfo(parser);

            cur = contentInfo.Current;
            while (cur != null)
            {
                if (!cur.Visible)
                {
                    XMLBlock.Check(contentInfo, parsingInfo, scriptInfo);

                    cur = contentInfo.Move(SearchDirection.LeftToRight);
                }
                else
                {
                    if (DevCode.Check(contentInfo, parsingInfo, scriptInfo) ||
                        PreProcessorInclude.Check(contentInfo, parsingInfo, scriptInfo) ||
                        PreProcessorRegion.Check(contentInfo, parsingInfo, scriptInfo) ||
                        AccessModifier.Check(contentInfo, parsingInfo, scriptInfo) ||
                        SealedModifier.Check(contentInfo, parsingInfo, scriptInfo) ||
                        UsingDef.Check(contentInfo, parsingInfo, scriptInfo) ||
                        OverwriteConstDef.Check(contentInfo, parsingInfo, scriptInfo) ||
                        FuncDef.Check(contentInfo, parsingInfo, scriptInfo) ||
                        ConstDef.Check(contentInfo, parsingInfo, scriptInfo)
                        )
                    {
                        cur = contentInfo.Move(SearchDirection.LeftToRight);
                    }
                    else
                    {
                        throw new SyntaxException("Unknown token", contentInfo.GetErrorInfo());
                    }
                }
            }

            tree.IncludeDefList        = parsingInfo.IncludeDefList;
            tree.FuncDefList           = parsingInfo.FuncDefList;
            tree.ConstDefList          = parsingInfo.ConstDefList;
            tree.UsingDefList          = parsingInfo.UsingDefList;
            tree.OverwriteConstDefList = parsingInfo.OverwriteConstDefList;

            return(tree);
        }