Exemplo n.º 1
0
        public static bool TryParse(string content, int start, int length, out KirinNode result)
        {
            result = null;
            if (content != "I took a break")
            {
                return(false);
            }

            result = new KirinDebugger(start, length);
            return(true);
        }
Exemplo n.º 2
0
        private static KirinNode ParseLine(FiMReport report, string content, int start, int length)
        {
            string subContent = content.Substring(start, length - 1);             // Remove punctuation

            if (KirinPostScript.TryParse(subContent, start, length, out KirinNode node))
            {
                return(node);
            }

            if (KirinProgramStart.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinProgramEnd.TryParse(subContent, start, length, out node))
            {
                return(node);
            }

#if DEBUG
            if (KirinClassStart.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinClassEnd.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinClassConstructorStart.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinClassConstructorEnd.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
#endif

            if (KirinFunctionStart.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinFunctionEnd.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            ;

            if (KirinForInLoop.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinForToLoop.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinWhileLoop.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinSwitchStart.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinSwitchCase.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinSwitchCaseDefault.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinLoopEnd.TryParse(subContent, start, length, out node))
            {
                return(node);
            }

            if (KirinIfStatementStart.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinElseIfStatement.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinIfStatementEnd.TryParse(subContent, start, length, out node))
            {
                return(node);
            }

            if (KirinPrint.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinInput.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinFunctionCall.TryParse(subContent, report, start, length, out node))
            {
                return(node);
            }
            if (KirinVariableDeclaration.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinListModify.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinVariableModify.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinUnary.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinReturn.TryParse(subContent, start, length, out node))
            {
                return(node);
            }
            if (KirinDebugger.TryParse(subContent, start, length, out node))
            {
                return(node);
            }

#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                System.Diagnostics.Debugger.Break();
            }
            else
            {
                Console.WriteLine("Unhandled node: " + subContent);
            }
#endif

            return(new KirinNode(start, length));
        }