Compiler: Motivation for my own toy language and Handwriting Lexer

https://github.com/choikwa/Rekt

I wanted a language that combined the likeable features of Python, C, and functional programming. I replaced somethings in Python such as ‘:’ and indent for braces and kept heterogeneous element containers. I especially liked how Python exposes fundamental container data types so natively, so I kept all the brace notations such as [],(),{},set(). Grammar is still being worked out, to add more desirable features that Python lacked such as operator overloading (variable length operator too!), complex switch statement, and perhaps more functional list comprehension which I dubbed as iterator, which works more like Mathematical set notation.

Imagine if you could write code like

for {float f| |f| < 10, stepSize(0.01), isReal, otherFilters}
{
//do stuff with f
}

I had to revive my old memories about writing a lexer, from days of university. At the same time, I wanted to practice using C++11 features. I decided to handwrite a lexer using C++11 features. I unfortunately did not implement the main logic using NFA->DFA transformation for additional performance, but I suspect this won’t be a typical performance bottleneck in the pipeline.

Screenshot from 2015-03-08 01:59:51

Advertisements

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