예제 #1
0
        public void OutputTree(ITree tree, int start = 0)
        {
            for (int i = start; i < tree.ChildCount; i++)
            {
                ITree child = tree.GetChild(i);
                switch (child.ToString())
                {
                case "IF":
                    Cmd_LineNum(child.Line);
                    ParseIf(child);
                    break;

                case "OPERATION":
                {
                    Cmd_LineNum(child.Line);
                    OutputCmd(BurikoCommands.Operation);
                    OperationHandler operationHandler = new OperationHandler();
                    operationHandler.ParseOperation(child);
                    break;
                }

                case "VARDECL":
                    ParseVarDecl(child);
                    break;

                case "ASSIGN":
                    ParseAssignment(child);
                    break;

                default:
                    Debug.LogError("Unhandled type " + child.ToString());
                    break;
                }
            }
        }
예제 #2
0
        public void Output()
        {
            BinaryWriter output = BGItoMG.Instance.Output;

            switch (Type)
            {
            case BurikoValueType.Int:
            {
                int num = (!tree.Text.StartsWith("0x")) ? int.Parse(tree.Text) : int.Parse(tree.Text.Substring(2), NumberStyles.HexNumber);
                output.Write((short)Type);
                output.Write(num);
                break;
            }

            case BurikoValueType.Unary:
            {
                int num = (!tree.Text.StartsWith("0x")) ? int.Parse(tree.Text) : int.Parse(tree.Text.Substring(2), NumberStyles.HexNumber);
                output.Write((short)2);
                output.Write(-num);
                break;
            }

            case BurikoValueType.String:
            {
                string text = tree.Text;
                output.Write((short)Type);
                output.Write(text.Substring(1, text.Length - 2).Replace("\\\"", "\""));
                break;
            }

            case BurikoValueType.Bool:
                output.Write((short)Type);
                output.Write(GetBool());
                break;

            case BurikoValueType.Null:
                output.Write((short)Type);
                break;

            case BurikoValueType.Math:
                OutputMath(output);
                break;

            case BurikoValueType.Operation:
            {
                output.Write((short)Type);
                OperationHandler operationHandler = new OperationHandler();
                operationHandler.ParseOperation(tree);
                break;
            }

            case BurikoValueType.Variable:
                OutputVar(output);
                break;

            default:
                throw new Exception("Unhandled Variable Type " + Type);
            }
        }