Activity

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!

shoebob

adventures in pong
the entity–component–system i designed was pretty bad. it wasn’t awful for a first attempt, but i want to redesign it to something more akin to Flecs. the ecs quickly became unruly for even simple entity relationships, and it became too much to wrangle even with a simple pong game. before tackling larger projects, i definitely want to redesign the ecs to be much more ergonomic.

future game projects will occur on other projects on hack club (i think). i still have major plans for this engine (physics, networking, misc. debug stuff), but i need to take care of some primary issues with it first. i honestly have no clue what i was thinking when i was writing the ecs.

0
shoebob

ecs and other misc stuff
it’s been six days since my last devlog and, since i’ve been programming for ~1 hr a day, i’ve made some progress on the engine. firstly, i have a prototype ecs working! it’s not fast, and is not “technically” an ecs, but it behaves similarly to one. i plan to rewrite it one day to be more adherent to data-oriented design, but it will work for now. i also wrapped up the opengl backend and cleaned up some stuff.

the first game i plan to make with this engine is a pong clone. i don’t want to do anything crazy, and instead focus on simple stuff. i will make progressively more advanced clones of simple games until my engine is ready to tackle an original game (current idea is a coop wizarding game)

note: i recently discovered that glfwSwapInterval(1) (which is used to enable vsync) is broken on apple silicon macs! i truthfully don’t know what i’m going to do to fix it, and i think i will just deal with it until it becomes more unbearable than it already is. it’s stuttering like crazy, but there’s not much i can do.

0
shoebob

unfortunately, i gave up on bgfx. it was a neat idea, but sort of overkill for the simple 2d engine i’m making, and it also had poor shader documentation. i switched over to opengl and it has been great. i got a textured quad rendering in ~2 hours, and it’s been much easier than bgfx. i just need to abstract some rendering stuff now, and then i just have to make an ecs and then i’m done!

Attachment
0
shoebob

this one took a while. i’m not completely sure if the time is correct, since i spent a lot of time reading documentation and looking at my code. some stuff that was added to the engine:

  • generic graphic backend capability (however, bgfx should be the only one i need)
  • robust resource loading
  • image loading with stbi
  • window resizing
    i also made several misc changes to the engine, but it’s been many hours of programming and i forget most of it. however, i got a cube rendering! very exciting stuff.
Attachment
0
shoebob

ref-counted resource management
i realized that, before rendering, i should make some sort of asset management. i went sort of overkill and created a ref-counted cached resource management system, but it’s actually pretty simple. there’s a ResourceManager, which is exposed to the api. ResourceManager can register ResourceLoaders (load and sizeOf), and then, using ResourceManager.load(path), users can load a resource after registering a loader for that type of resource. i only made TextResourceLoader so far, but i plan to implement binary, images, and possibly compiled shaders (but idk yet). i also still need to make it async, but kotlin has pretty good async capabilities, so i’m not too worried.

Attachment
0
shoebob

got bgfx working after an hour of debugging. macos really hates rendering on background threads. next: rendering structure and draw commands.

Attachment
0
shoebob

so far I have general engine structure down. however, i’m having trouble with bgfx on mac.

Attachment
0