<commit_before><template>
    <article class='p-article-grid'>
        <h1 class='p-wide p-title'>
            Writing A Compiler, the Hard Way
        </h1>

        <p class='p-wide p-text'>
            For my undergrad degree in Software Systems at SFU, I took a course in compilers.
            The course was a really great, in my opnion.
            I took it with <v-link to='https://www.sfu.ca/computing/people/faculty/thomasshermer.html'><NAME></v-link>, who is one of those professors that will make you work hard because he knows it will cause you to learn things.
        </p>

        <p class='p-wide p-text'>
            All the projects in the course were connected.
            They were one long project, broken into several parts.
            In other words, each project relied on the previous project being completed, much like implementing real software, which is something I haven't often seen in classes.
        </p>

        <p class='p-note p-thin'>
            The only time I experienced this outside of one of Tom's classes was in a
            <v-link local to='/projects/big-team-project'>semester-long team project</v-link>
            where we had a real client.
        </p>

        <p class='p-wide p-text'>
            For this class, we were targeting a simple stack machine with a several dozen commands.
            The virtual stack machine we used was designed by Tom, and made specifically for teaching students compilers without having to simultaneously worry about the hardware.
        </p>

        <p class='p-wide p-text'>
            The language we were compiling was called Pika.
            The compiler was all written without the help of external libraries.
            We weren't even allowed to use a
            <v-link to='https://en.wikipedia.org/wiki/Regular_expression'>regular expressions</v-link> unless we wrote the libraries from scratch.
            All we had were Java's core libraries and a minimally functional compiler Tom started us with.
            By the end it had surprisingly many features:
        </p>

        <p class='p-note p-thin'>
            The language pika is named after this adorable
            <v-link to='https://www.google.ca/search?q=pika&tbm=isch'>rabbit-esque animal</v-link>.
            Some people think it is the inspiration behind pikachu.
            On the other hand, ぴかぴか (pika-pika) is an onomatopoeia for sparkle in Japanese, so it could be either.
        </p>

        <ul class='p-wide p-list'>
            <li>
                Supported first-class data-types:
                <ul class='p-list'>
                    <li>Booleans</li>
                    <li>8bit Characters</li>
                    <li>Strings</li>
                    <li>32bit Integers</li>
                    <li>32bit Floats</li>
                    <li>64bit Rationals <span class='p-note'>composed of two 32bit Integers</span></li>
                    <li>Higher Order Functions</li>
                    <li>Arrays <span class='p-note'>composed of any type here including arrays</span></li>
                </ul>
            </li>
            <li>
                All data-types had type inference, and casting was allowed within a strict hierarchy
            </li>
            <li>
                Scopes
            </li>
            <li>
                Functions <span class='p-note'>able to use static variables in outer scopes and stack variables in the current scope</span>
            </li>
            <li>
                Manually managed dynamic memory
            </li>
            <li>
                Rationals were automatically reduced to
                <v-link to='https://en.wikipedia.org/wiki/Greatest_common_divisor'>gcd</v-link>
                form
            </li>
            <li>
                An Optimizer which could do all the following optimizations:
                <ul class='p-list'>
                    <li>peephole</li>
                    <li>string deduplication</li>
                    <li>
                        trimming of unreferenced code via
                        <v-link to='https://en.wikipedia.org/wiki/Basic_block'>basic blocks</v-link>
                    </li>
                    <li>basic block reordering and duplicating <span class='p-note'>to reduce jumps</span></li>
                    <li>some <b>very</b> basic constant variable replacement</li>
                </ul>
            </li>
            <li>
                It was possible to do the following with every numeric data-type:
                <ul class='p-list'>
                    <li>addition</li>
                    <li>subtraction</li>
                    <li>multiplication</li>
                    <li>division</li>
                    <li>value comparisons <span class='p-note'>{{"<, >, <=, >=, ==, !="}}</span></li>
                </ul>
            </li><commit_msg>fix parse warning about < and > in string<commit_after><template>
    <article class='p-article-grid'>
        <h1 class='p-wide p-title'>
            Writing A Compiler, the Hard Way
        </h1>

        <p class='p-wide p-text'>
            For my undergrad degree in Software Systems at SFU, I took a course in compilers.
            The course was a really great, in my opnion.
            I took it with <v-link to='https://www.sfu.ca/computing/people/faculty/thomasshermer.html'><NAME></v-link>, who is one of those professors that will make you work hard because he knows it will cause you to learn things.
        </p>

        <p class='p-wide p-text'>
            All the projects in the course were connected.
            They were one long project, broken into several parts.
            In other words, each project relied on the previous project being completed, much like implementing real software, which is something I haven't often seen in classes.
        </p>

        <p class='p-note p-thin'>
            The only time I experienced this outside of one of Tom's classes was in a
            <v-link local to='/projects/big-team-project'>semester-long team project</v-link>
            where we had a real client.
        </p>

        <p class='p-wide p-text'>
            For this class, we were targeting a simple stack machine with a several dozen commands.
            The virtual stack machine we used was designed by Tom, and made specifically for teaching students compilers without having to simultaneously worry about the hardware.
        </p>

        <p class='p-wide p-text'>
            The language we were compiling was called Pika.
            The compiler was all written without the help of external libraries.
            We weren't even allowed to use a
            <v-link to='https://en.wikipedia.org/wiki/Regular_expression'>regular expressions</v-link> unless we wrote the libraries from scratch.
            All we had were Java's core libraries and a minimally functional compiler Tom started us with.
            By the end it had surprisingly many features:
        </p>

        <p class='p-note p-thin'>
            The language pika is named after this adorable
            <v-link to='https://www.google.ca/search?q=pika&tbm=isch'>rabbit-esque animal</v-link>.
            Some people think it is the inspiration behind pikachu.
            On the other hand, ぴかぴか (pika-pika) is an onomatopoeia for sparkle in Japanese, so it could be either.
        </p>

        <ul class='p-wide p-list'>
            <li>
                Supported first-class data-types:
                <ul class='p-list'>
                    <li>Booleans</li>
                    <li>8bit Characters</li>
                    <li>Strings</li>
                    <li>32bit Integers</li>
                    <li>32bit Floats</li>
                    <li>64bit Rationals <span class='p-note'>composed of two 32bit Integers</span></li>
                    <li>Higher Order Functions</li>
                    <li>Arrays <span class='p-note'>composed of any type here including arrays</span></li>
                </ul>
            </li>
            <li>
                All data-types had type inference, and casting was allowed within a strict hierarchy
            </li>
            <li>
                Scopes
            </li>
            <li>
                Functions <span class='p-note'>able to use static variables in outer scopes and stack variables in the current scope</span>
            </li>
            <li>
                Manually managed dynamic memory
            </li>
            <li>
                Rationals were automatically reduced to
                <v-link to='https://en.wikipedia.org/wiki/Greatest_common_divisor'>gcd</v-link>
                form
            </li>
            <li>
                An Optimizer which could do all the following optimizations:
                <ul class='p-list'>
                    <li>peephole</li>
                    <li>string deduplication</li>
                    <li>
                        trimming of unreferenced code via
                        <v-link to='https://en.wikipedia.org/wiki/Basic_block'>basic blocks</v-link>
                    </li>
                    <li>basic block reordering and duplicating <span class='p-note'>to reduce jumps</span></li>
                    <li>some <b>very</b> basic constant variable replacement</li>
                </ul>
            </li>
            <li>
                It was possible to do the following with every numeric data-type:
                <ul class='p-list'>
                    <li>addition</li>
                    <li>subtraction</li>
                    <li>multiplication</li>
                    <li>division</li>
                    <li>value comparisons <span class='p-note'>&lt;, &gt;, &lt;=, &gt;=, ==, !=</span></li>
                </ul>
            </li>
{'fraction_non_alphanumeric': 0.09572301425661914, 'fraction_numerical': 0.002240325865580448, 'mean_word_length': 1.6140537663029013, 'pattern_counts': {'":': 0, '<': 206, '<?xml version=': 0, '>': 206, 'https://': 10, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4732735', 'n_tokens_mistral': 2650, 'n_tokens_neox': 2480, 'n_words': 918}