Saturday 23 July 2011

Lexing and parsing

So, I manually constructed a working lexer. It wasn't that tough. Now when I'm constructing a working parser, it's getting a little tougher, although on the plus side, the parallelisable design is going to be sweet. Consider the following:

vector(identifier) var;

versus

vector(identifier) { }

Owch. This gets even hairer if I start passing, say, a lambda to my metafunction. Now, I believe that this is resolvable, but, well, it would be difficult. As such, I've decided that pretty much the only unambiguous way to make this work is going to be to introduce a "function" keyword.

function vector(identifier) {} // I'm a function!
vector(identifier) var; // I'm a variable!


Earlier decision points will make it much easier to parallelise, as well. I also decided to, well, flat out ditch type literals, and for the same reason I will probably not bother with initializer lists either- or certainly not to begin with. I will now do

t = []{ 
    type t;     
    // some more stuff
    return t;

}();



The previous system will be, quite simply, not in the language. Hopefully once the parser is completed, I can begin working on the semantic analyzer and get back to posting about something that isn't either grammar or theory.

Ultimately, the grammar can be fine-tuned later. What I need to do is get cracking and finish a parser that can do more than just parse namespaces, which it currently can but that's not terrifically impressive, and then I can get cracking on semantic analysis.

No comments:

Post a Comment