Giona2_lfc<p>As a first post on this account, I've decided to make an explanation on a compiler I'm writing. Please refer to my main account, <span class="h-card" translate="no"><a href="https://mastodon.social/@Giona_2" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>Giona_2</span></a></span>, if you would like more information on it.</p><p>This post is meant to explain each module of my compiler (Optimizer, Tokenizer, Assembler). Each module will have a dedicated paragraph who were their originally their own posts, but I think it's a great way to kick off this first post</p><p># Optimizer<br>The Optimizer is the most simplistic part of my compiler. It's job is to arrange the raw text file into a more readable format for the Tokenizer.</p><p>Essentially, it arranges the source code you wrote into an array where each word (keyword, number, symbol, etc) is it's own element. This allows the Tokenizer to iterate through each word more reliably than if it just read the raw text file verbatim.</p><p># Tokenizer<br>The Tokenizer is arguably the most important module.</p><p>The Tokenizer takes the list generated from the Optimizer and iterates through each word. When it finds a keyword in the list, it goes through the following steps:<br>1. Finds the end of the declaration the keyword is indicating<br>2. Sends this full declaration to a function that'll parse it into a token</p><p>The final result is arranged as an array of tokens that emulates the steps the final executable must go through.</p><p># Assembler<br>Finally, the Assembler is what's responsible for turning the token array generated by the Tokenizer and turning it into the final program.</p><p>All this does is iterate over each token in the array and translate it into its assembly-instruction equivalent.</p><p>This module, by far, is my favorite for one reason and one reason only: It's extremely volatile in the sense that it can turn the token array into pretty much anything you want Unimal to compile to.</p><p><a href="https://mastodon.bsd.cafe/tags/programming" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>programming</span></a> <a href="https://mastodon.bsd.cafe/tags/coding" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>coding</span></a> <a href="https://mastodon.bsd.cafe/tags/compiler" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>compiler</span></a></p>