API's that Suck

January 29, 2011

Foundry – Goal: Build a compiler that will print “Hello World”

Filed under: Uncategorized — Grauenwolf @ 8:52 pm

The goal is to create a CLR compiler for Foundry, my research project for this year.

Source File

Program Test1
    References
    mscorlib
    End References
End Program
Imports 
    System

End Imports
Function Main 
    Let message = “Hello World”
    Console.WriteLine(message)
End Function

Tasks

  1. File level parser. This needs to understand import statements and function blocks, but not the contents of functions.
  2. Level 1 symbol table. Requires reflecting over core assemblies
  3. Parsing let-style variable statements. This will require an abstract syntax tree with nodes that can later be annotated with type information.
  4. Level 3 symbol table for storing locals. (Level 2 is for class-level symbols, which donof’t apply to free functions. Levels 4+ are for nested structures)
  5. Parsing simple function calls.
  6. Emitting a free function as IL code.

Abstract Syntax for File-Level Parser

<Import> <Identifier>

<Function> <Identifier “Main”>

<Function-Body>

<End Function>

The file-level parser doesn’t concern itself with the contents of functions. This allows us some degree of error recovery, as one bad function will not prevent us from parsing the remainder of the file.

Proposed object model (using XML notation because I don’t feel like drawing diagrams tonight)

<File>

    <Imports><Import Namespace=”xxx”></Imports>

    <Free-functions>

        <Function Name=”Main” />

    </Free-functions>

</File>

Deadline: My self-imposed deadline is March 12, which allows for weekly milestones.

Advertisements

2 Comments »

  1. You really like the BASIC syntax, don’t you?

    Comment by Matt — January 30, 2011 @ 11:37 am

    • It is more that I don’t like the C style syntax. I don’t want to get inot a situation where one missing brace can completely change the meaning of the code.

      Comment by grauenwolf — January 30, 2011 @ 4:38 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: