Play With Lua!

Archive for June, 2015

Making a toy programming language in Lua, part 4

without comments

This is part four of my series on writing a toy programming language using LPeg. You should start with part one here.

Last time, we used the new AST generation to make conditionals and loops. Now, we’re going to add the ability to define functions, complete with lexical scoping.

Read the rest of this entry »

Written by randrews

June 21st, 2015 at 3:54 pm

Posted in Uncategorized

Making a toy programming language in Lua, part 3

without comments

This is part three of my series on writing a toy programming language using LPeg. You should start with part one here.

Last time, we added variables and arrays to the language. Assigning to arrays was starting to strain our design some, so this time we’ll refactor it a lot, and add two features that would be impossible without that refactoring: conditional statements and loops.

Read the rest of this entry »

Written by randrews

June 12th, 2015 at 11:41 pm

Posted in Uncategorized

Making a toy programming language in Lua, part 2

without comments

This is part two of my series on writing a toy programming language using LPeg. You should first read part one here.

Last time, we made an interpreter for a simple calculator: it would read in mathematical expressions and evaluate them, printing the result. This time, we’re going to add two new features: variables and arrays. First though, we’ll refactor our parser some.
Read the rest of this entry »

Written by randrews

June 5th, 2015 at 9:46 am

Posted in Uncategorized