Microsoft Small Basic ships with a custom IDE with syntax colouring and code completion but no debugger:
There’s a good article by Nonki Takahashi on Microsoft Technet on How to debug Small Basic programs manually which boils down to:
- trace with TextWindow.WriteLine
- add conditional debug code with If debug Then …
- promote your app to full VB.Net
Small Basic in Visual Studio
Last year, for fun, I wrote a custom Small Basic compiler with some extensions like functions with parameters and tuples and pattern matching.
I added debugger support recently so you can compile and debug Small Basic apps directly in Visual Studio:
- download and compile the custom Small Basic compiler
- create a project to host your Small Basic file (.sb)
- compile the app with the custom Small Basic Compiler
- in the project properties Debug tab configure Start External Program
The Reflection.Emit library allows you to mark points in the emitted IL code with corresponding points in the source file using the MarkSequencePoint method. There’s a good guide from back in 2005 on Michael Stall’s blog: Debugging Dynamically Generated Code (Reflection.Emit)
Only a few changes to the compiler were required to provide Debugger support. First I augmented the parser, which uses FParsec, to produce line and column information for each statement. For this FParsec provides a handy getPosition function that returns the current position in the input stream. Then in the IL emit step I simply used MarkSequencePoint to annotate each statement.
It would also be nice to add syntax colouring for Small Basic within Visual Studio too. If anyone is interested in working with me on this, please get in touch
I’m also now able to run Small Basic programs on Mac and Linux via Mono but that’s another post…