Example #1
0
        public static LinkedListNode<Lexeme> TryParse(LinkedListNode<Lexeme> lexemes, out Node resultNode)
        {
            resultNode = null;
            var nextLexeme = StructDecl.TryParse(lexemes, out StructDecl structDecl);
            if (structDecl != null)
            {
                resultNode = structDecl;
                return nextLexeme;
            }

            nextLexeme = FnDecl.TryParse(lexemes, out FnDecl fn);
            if (fn != null)
            {
                resultNode = fn;
                return nextLexeme;
            }

            nextLexeme = Stmt.TryParseStruct(lexemes, out Stmt stmt);
            if (stmt != null)
            {
                resultNode = stmt;
                return nextLexeme;
            }

            return lexemes;
        }