Click here to Skip to main content
15,881,898 members
Articles / Programming Languages / C#

Cat - A Statically Typed Programming Language Interpreter in C#

Rate me:
Please Sign up or sign in to vote.
5.00/5 (14 votes)
4 Nov 2006MIT14 min read 70.6K   530   45  
This article contains the public domain implementation of an interpreter for a statically typed stack-based programming language in C# called Cat. The accompanying article is a high-level description of how the various modules work, a brief description of the language, and links to related work.
/// Public domain code by Christopher Diggins
/// http://www.cat-language.com

using System;
using System.Collections.Generic;

namespace Cat
{
    public class MainClass
    {
        public static string gsInputFileName = "";
        
        static void Main(string[] a)
        {
            if (a.Length > 0)
            {
                gsInputFileName = a[0];
            }
            try
            {
                if (Config.gbUnitTesting)
                {
                    Primitives.RegisterAtomicPrograms();
                    Tests.RunCoreTests();
                    Primitives.RegisterStdPrograms();
                    Tests.RunLibraryTests();
                    Tests.RunKnownIssuesTests();
                    Tests.OutputTestCoverage();
                    Scope.Global().Clear();
                }
                Primitives.RegisterAtomicPrograms();
                Primitives.RegisterStdPrograms();
                Interpreter cat = new Interpreter();
                cat.LaunchSession();
            }
            catch (Exception e)
            {
                Console.WriteLine("Untrapped exception occurred: {0}", e.Message);
                Console.WriteLine("Press any key to exit ...");
                Console.Read();
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Software Developer Ara 3D
Canada Canada
I am the designer of the Plato programming language and I am the founder of Ara 3D. I can be reached via email at cdiggins@gmail.com

Comments and Discussions