Python Interpreter

Script Interpreter implements in Python

This is my attempt to create a new programing language, the language called ALPL and the interpreter implemented in Python. The program should get a "alpl" script and execute it, The program expect to get a file with extension ".alpl" as a command-line argument.

In this phase the ALPL language contains only six commands, the following is a description and rules of the language:

  • The language only deals with positive or negative integer numbers
  • There are ten registers numbered R0 - R9, each register can hold an integer number
  • All the language tokens are in UPPERCASE
  • Each line includes exactly one command or label, there are no multiline commands
  • A label is an alphanumeric token followed by a colon (the token can’t be a command or a register name)
  • When the program reaches the end of file it is ended

The solution includes the following scripts:

  • main.py - the entry point and create the execution plan
  • lexer.py - where we parse the source code and create execution tokens
  • statements.py - where we initial the execution objects
  • executer.py - where we execute the execution plan line by line
  • tracer.py - where we set the tracer mode


Usage:

python main.py FILE_NAME (ALPL code file)

The source code on Github


To view or add a comment, sign in

More articles by Shlomi Elbaz

  • Is jQuery still relevant?

    I had an interview and I was asked if I would start a new project do I choose to use jQuery? my immediate and intuitive…

    1 Comment
  • Protect your HTTP requests using Node and JWT

    If you ever switched from one technology to another you probably found your self asking how I'm doing… like I was doing…

    1 Comment
  • Parse urlencoded string into JSON in ONE line of code

    The source code can be found in: https://github.com/shlomisderot/url-encoded I would like to share with you some regex…

    3 Comments
  • Using Cencha CMD as development environment aid

    One of the common mistakes developers make is jumping into the code "to see things happening", that's OK if you have…

Explore content categories