minterpreter banner

minterpreter

2 devlogs
2h 26m 27s

a math expression interpreter written in Go, featuring a complete interpreter stack (lexer, binary parse tree, etc.)
this will be the backend for a graphing calculator project. it is not meant to be used standalone, but there will be a demo cli i…

a math expression interpreter written in Go, featuring a complete interpreter stack (lexer, binary parse tree, etc.)
this will be the backend for a graphing calculator project. it is not meant to be used standalone, but there will be a demo cli included in the repo.

This project uses AI

i use ChatGPT occasionally for guidance and learning new concepts. however, i never copy and paste or steal code generated by ai. i like to focus on personal growth and learning over putting out projects.

Repository

Loading README...

shoebob

devlog 2 - subtraction and integers

in this devlog, i added subtraction and the ability to add integers of variable length. it may not sound like much, but i’m trying to provide a good base for the rest of the interpreter. i have my obsidian notes on lexical analysis pasted below, but i’m not sure how well it will format. for the next devlog, i plan to implement operator precedence and multiplication + division, and also learn about writing tests in go (since writing tests is probably a smart thing to do)

notes

Lexical Analysis is a stage in interpretation that turns a string of text into analytical tokens, typically for a later stage like the parser.

What is a token?

A token is a type and a value. For example, an integer 8 would be converted into a token of type: Integer and value: 8.

How-to Lexical Analysis

The lexical analyzer, or lexer, breaks down a string of characters into tokens. It goes character-by-character, and has no context for the surrounding characters. It then passes the list of tokens to the interpreter to evaluate.

Lexemes

A lexeme is a collection of characters forming a token. For example, this can include simple 1 character tokens (operators, parenthesis, etc.), but also include integers, floats, etc.

A relationship between token types and lexemes can be seen in the table below:

Token Sample Lexems INTERGER 142, 19, 23, 1 PLUS + MINUS -
0
shoebob

first devlog!
i have a pretty simple first devlog. the two main things i completed are: adding two numbers and creating a project README, license, etc.
i spent a lot of time researching interpreters and learning certain terminology that is specific to them. for example, the lexer is the part of the interpreter that takes in a string and outputs a series of tokens that can be interpreted later.
i also did a lot of research into different licenses (copyleft vs. permissive), and i landed on using LGPLv3 for my project. in the future, i will be posting my Obsidian notes into my devlogs to show more of my learning.
i attached a little video demonstrating the (limited) capabilities of my calculator. i have big plans for the future however!

the crash at the end was intentional, don’t worry.

1

Comments

Karthik T S
Karthik T S about 2 months ago

Cool!