|
/// Public domain code by Christopher Diggins
/// http://www.cat-language.com
using System;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;
using System.Collections;
using System.Collections.Generic;
namespace Cat
{
class Interpreter
{
#region Output Functions
public void Prompt()
{
if (Executor.IsIncomplete())
{
Console.Write("/ ");
}
else
{
Console.Write(">> ");
}
}
public void Print(string s)
{
Console.WriteLine(s);
}
public void OutputNode(AstNode x)
{
Console.Write(x.node_type.ToString());
Console.Write(" : ");
Console.WriteLine(x.ToString());
}
public void OutputNodeRecursive(AstNode x)
{
OutputNode(x);
for (int i = 0; i < x.children.Count; ++i)
{
AstNode child = x.children[i];
OutputNodeRecursive(child);
}
}
#endregion
public void Welcome()
{
if (Config.gbShowLogo)
{
Print("");
Print("Cat Programming Language Interpreter");
Print("by Christopher Diggins =^..^=");
Print("version 0.9.6 November 4, 2006");
Print("this software is public domain");
Print("http://www.cat-language.com");
Print("");
Print("Type in help to see a list of commands");
Print("Type in @man man to see more information about a command");
Print("");
}
}
public void LaunchSession()
{
Welcome();
if (MainClass.gsInputFileName.Length > 0)
{
try
{
Executor.LoadSession(MainClass.gsInputFileName);
}
catch
{
Console.WriteLine("Unable to load file " + MainClass.gsInputFileName);
}
}
while (true)
{
Prompt();
try
{
string s = Console.ReadLine();
Executor.Execute(s + '\n');
if (Config.gbOutputStack)
{
Executor.OutputStack();
}
}
catch (Exception e)
{
Console.WriteLine("Exception caught: {0}.", e.Message);
}
}
}
}
}
|
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.