Exemple #1
0
 public void visit_continue(ContinueStmt continue_stmt)
 {
     if (!in_loop)
     {
         throw new RuntimeException("Cannot continue from a non-loop");
     }
 }
        public void Visit(ContinueStmt continueStmt, object[] args)
        {
            //在编译时已经检查过break的合法性
            ASTNode node = null;

            do
            {
                int id = kernel.RuntimeData.InstructionStack.Peek();

                if (id == InstructionStack.CLOSE_LOCAL_SCOPE_FLAG)
                {
                    kernel.RuntimeData.ScopeStack.Close();
                }
                else
                {
                    node = root.NodeMap[id];
                }

                if (!(node is LoopStmt))
                {
                    kernel.RuntimeData.InstructionStack.Pop();
                }

            } while (!(node is LoopStmt));

            kernel.Next();
        }
Exemple #3
0
        public void Visit(ContinueStmt continueStmt, object[] args)
        {
            //在编译时已经检查过break的合法性
            ASTNode node = null;

            do
            {
                int id = kernel.RuntimeData.InstructionStack.Peek();

                if (id == InstructionStack.CLOSE_LOCAL_SCOPE_FLAG)
                {
                    kernel.RuntimeData.ScopeStack.Close();
                }
                else
                {
                    node = root.NodeMap[id];
                }

                if (!(node is LoopStmt))
                {
                    kernel.RuntimeData.InstructionStack.Pop();
                }
            } while (!(node is LoopStmt));

            kernel.Next();
        }
Exemple #4
0
 public override void Visit(ContinueStmt continueStmt, object[] args)
 {
     if (loopStack.Count == 0)
     {
         kernel.IssueError(ErrorType.ContinueNotInLoop, continueStmt.Location);
     }
     base.Visit(continueStmt, args);
 }
 public override void Visit(ContinueStmt continueStmt, object[] args)
 {
     if (loopStack.Count == 0)
     {
         kernel.IssueError(ErrorType.ContinueNotInLoop, continueStmt.Location);
     }
     base.Visit(continueStmt, args);
 }
Exemple #6
0
        public virtual bool VisitContinueStmt(ContinueStmt stmt)
        {
            if (!VisitStmt(stmt))
            {
                return(false);
            }

            return(true);
        }
Exemple #7
0
 public bool VisitContinueStmt(ContinueStmt stmt)
 {
     throw new NotImplementedException();
 }
 public void visit_continue(ContinueStmt continue_stmt)
 {
     // Throw a new continue exception for the loop/function to catch
     throw new ContinueException();
 }
 public void Visit(ContinueStmt continueStmt, object[] args)
 {
     throw new NotImplementedException();
 }
Exemple #10
0
        private void visitMainContent(ASTNode parent, List <Statement> content)
        {
            bool endWithBr = false;

            while (reader.Read())
            {
                reader.MoveToContent();
                Location location = new Location(file, reader.LineNumber, reader.LinePosition);
                switch (reader.NodeType)
                {
                case XmlNodeType.Text:
                    string   text  = reader.Value;
                    string[] lines = text.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string line in lines)
                    {
                        string trimed = line.Trim();
                        if (trimed.Length == 0)
                        {
                            continue;
                        }

                        if (endWithBr && content.Count > 0 && content[content.Count - 1] is DialogStmt)
                        {
                            DialogStmt dialog = content[content.Count - 1] as DialogStmt;
                            dialog.Text += Environment.NewLine + trimed;
                        }
                        else
                        {
                            DialogStmt dialog = new DialogStmt();
                            dialog.Parent   = parent;
                            dialog.Location = location;

                            dialog.Text = trimed;
                            content.Add(dialog);
                        }
                        endWithBr = false;
                    }
                    break;

                case XmlNodeType.Element:
                    Statement statement = null;
                    switch (dic[reader.Name])
                    {
                    case "br":
                        endWithBr = true;
                        continue;

                    case "expr":
                        statement = new ExpressionStmt();
                        break;

                    case "return":
                        statement = new ReturnStmt();
                        break;

                    case "include":
                        statement = new IncludeStmt();
                        break;

                    case "actor":
                        statement = new ActorStmt();
                        break;

                    case "bg":
                        statement = new BackgroundStmt();
                        break;

                    case "echo":
                        statement = new EchoStmt();
                        break;

                    case "select":
                        statement = new SelectStmt();
                        break;

                    case "selectWithValue":
                        statement = new SelectStmt();
                        break;

                    case "if":
                        statement = new IfStmt();
                        break;

                    case "else":
                        return;

                    case "elseif":
                        return;

                    case "switch":
                        statement = new SwitchStmt();
                        break;

                    case "break":
                        statement = new BreakStmt();
                        break;

                    case "continue":
                        statement = new ContinueStmt();
                        break;

                    case "loop":
                        statement = new LoopStmt();
                        break;

                    case "music":
                        statement = new MusicStmt();
                        break;

                    case "musicStop":
                        statement = new MusicStopStmt();
                        break;

                    case "musicVol":
                        statement = new MusicVolStmt();
                        break;

                    default:
                        statement = new FunctionCallStmt();
                        break;
                    }
                    statement.Parent   = parent;
                    statement.Location = location;
                    statement.Accept(this);
                    content.Add(statement);
                    break;

                case XmlNodeType.EndElement:
                    //reader.Read();  //MainContent结束
                    return;
                }
            }
        }
Exemple #11
0
 public void Visit(ContinueStmt continueStmt, object[] args)
 {
     //FINISH: 检查合法性!
 }
 public virtual void Visit(ContinueStmt continueStmt, object[] args)
 {
 }