Beispiel #1
0
        public XmlElement ToXML(XmlDocument doc, XmlElement elem, ScriptInfo si)
        {
            MoveInfo treeInfo = new MoveInfo(this, SearchTree.ChildrenTree, 0, si.SF);
            IElement curElem  = treeInfo.Current;

            while (curElem != null)
            {
                if (curElem is Path)
                {
                    XmlElement pathElem = doc.CreateElement("path");
                    ((Path)curElem).ToXML(doc, pathElem, si);
                    elem.AppendChild(pathElem);
                }
                else if (curElem is Token &&
                         !treeInfo.IsIn <Path>(true)) // ignore path tokens
                {
                    XmlElement tokenElem = doc.CreateElement("token");
                    ((Token)curElem).ToXML(doc, tokenElem, si);
                    elem.AppendChild(tokenElem);
                }

                curElem = treeInfo.Move(SearchDirection.LeftToRight);
            }
            return(elem);
        }
Beispiel #2
0
        public override void CheckSemantic(MoveInfo treeInfo, ScriptInfo scriptInfo, CheckingInfo checkingInfo)
        {
            if (!treeInfo.IsIn <IterationStatement>() && !treeInfo.IsIn <SwitchStatement>())
            {
                throw new SyntaxException("Keyword 'break' cannot use here!", treeInfo.GetErrorInfo());
            }

            // unreachable code
            MoveInfo blockInfo = new MoveInfo(treeInfo.CurrentBlock, SearchTree.ContentBlock, treeInfo.CurrentIndex, treeInfo);
            IElement nextTry   = blockInfo.FindNextBlack(SearchDirection.LeftToRight);

            if (nextTry != null && nextTry is Statement)
            {
                scriptInfo.SF.Errors.Add(
                    new WarningError("Unreachable code detected",
                                     blockInfo.GetErrorInfo(nextTry)));
            }
        }