Writing Interpreters with Python part two. Writing the Parser

The next step in developing a programming language is the development of the Parser. The role of the Parser is to request tokens which are then matched to the Grammar of the parser matches the correct sequence of tokens the sequence of tokens is then accepted as correct and then stored as a Node in an abstract syntax tree. Here is an example of the Parser implementation for a small Lisp like language.

Read More

Writing Interpreters with Python part one. Writing the Lexer

Writing a Lexer for a small Lisp-like programming language. One of the first parts of developing a programming language is defining the Lexer a Lexer takes an input string and breaks the string into Tokens. Tokens can represent anything from the types of data such as Strings , Integers to keyword indentifiers. After breaking the input string into tokens the tokens are then requested by the Parser. Below is an implementation of the Lexer using Python Ply.

Read More