Implementing a Language in C# - Part 2.5: Source Code
This post is a supplemental in the Implementing a Language in C# series. Click here to view the first post which covers some of the preliminary information on creating a language. You can also view all of the posts in the series by clicking here.
As I began implementing the Parser for GlassScript, I ran into a problem: there is no singular representation of a file's source code. For this reason, I have decided to implement a SourceCode
class. This object's purpose is to give a representation of a file's original text.
The SourceCode
class provides a number of helper methods including GetLine(int line)
and GetLines(int start, int end)
. These methods exist to give a better system of retrieve a specific subset of code for use in something like an ErrorEntry
.
The source code for this change can be viewed at the project's GitHub page.