示例#1
0
        public Expr CompileStatement(ParseTreeNode parseNode)
        {
            switch (parseNode.Term.Name)
            {
            case "GlobalAssignment":
            case "LocalAssignment":
            case "FunctionCall":
                throw new NotImplementedException();

            case "Label":
                return(CurrentScope.RegisterJumpTarget(parseNode.ChildNodes[0].Token.Text));

            case "Goto":
                return(Expr.Goto(CurrentScope.GetJumpLabel(parseNode.ChildNodes[0].Token.Text)));

            case "Break":
                return(Expr.Break(CurrentScope.GetExitLabel()));

            case "Scope":
                return(CompileBlock(parseNode));

            case "ForLoop_Enumerable":
            case "ForLoop_Iterable":
            case "WhileLoop":
            case "RepeatLoop":
            case "IfStatement":
            case "GlobalFunction":
                throw new NotImplementedException();

            case "LocalFunction":
                return(CompileLocalFunction(parseNode));

            case "ReturnStatement":
                return(Expr.Return(CurrentScope.GetReturnLabel(), GetMultiExpressionValue(parseNode.ChildNodes[0])));

            default:
                throw new LithiumCompilerException("Unrecognized statement terminal '{0}' at {1}", parseNode.Term.Name, parseNode.Span.Location.ToUiString());
            }
        }