Inspiration

Steve Yegge said, "If you don't know how compilers work, then you don't know how computers work." We wonder how every interpreted programming language is converted into machine code.

What it does

This computer program can directly execute instructions are written in a programming or scripting language, without requiring them previously to have been compiled into a machine language program.

How we built it

The interpreter of a computer language is divided into two parts: parse and execute. our parse function takes a string as input, then calls the tokenize function to get a list of tokens, and then calls read_from_tokens to compile the list of tokens into an abstract syntax tree. read_ from_token function will look at the first token and report a syntax error if it is ")". If it is "(", then we start building a list of subexpressions until we match the corresponding ")". All non-bracketed tokens must be either symbols or numbers. We'll let Python recognize the difference between them: for any non-bracket token, first try to convert it to an integer, if that fails then try to convert it to a floating point number, if that still fails then convert it to a symbol. We used Python's own dictionary to implement the environment, constructing procedures, variables, conditional if judgment statements, and sequential execution (begin)

Accomplishments that we're proud of

Learned more about the structure and interpretation of computer programs and demonstrated the ability to analyze a programming language using Python.

What we learned

How to implement an interpreter for a computer language.

What's next for Simple lisp Interpreter(in python)

The ability to analyze more complex languages, such as C++.

Built With

Share this project:

Updates