Skip to content

Timu5/BasicSharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BasicSharp

Simple BASIC interpreter written in C#. Language syntax is modernize version of BASIC, see example below.

Example

print "Hello World"

let a = 10
print "Variable a: " + a

let b = 20
print "a+b=" + (a+b)

if a = 10 then
    print "True"
else
    print "False"
endif

for i = 1 to 10
    print i
next i

goto mylabel
print "False"

mylabel:
Print "True"

How to use

using System;
using BasicSharp;

namespace MyApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string code = "print \"Hello World\"";
            Interpreter basic = new Interpreter(code);
            basic.printHandler += Console.WriteLine;
            basic.inputHandler += Console.ReadLine; 
            try
            {
                basic.Exec();
            }
            catch (BasicException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.Line);
            }
        }
    }
}

About

BASIC interpreter in C#

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages