<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Natalia</title>
    <description>The latest articles on DEV Community by Natalia (@nataliapavlovic).</description>
    <link>https://dev.to/nataliapavlovic</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F390143%2Fa88dd528-c6b6-4a42-a6ba-8deda49540c4.jpeg</url>
      <title>DEV Community: Natalia</title>
      <link>https://dev.to/nataliapavlovic</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nataliapavlovic"/>
    <language>en</language>
    <item>
      <title>Compiler with WebAssembly Target</title>
      <dc:creator>Natalia</dc:creator>
      <pubDate>Wed, 20 May 2020 07:07:15 +0000</pubDate>
      <link>https://dev.to/nataliapavlovic/compiler-with-webassembly-target-3kml</link>
      <guid>https://dev.to/nataliapavlovic/compiler-with-webassembly-target-3kml</guid>
      <description>&lt;h2&gt;
  
  
  My Final Project
&lt;/h2&gt;

&lt;p&gt;One of the final projects that I did during my 4-year Electrical/Computer Engineering degree was to write a compiler with a WebAssembly target. The compiler is written in C, and was implemented using compiler construction tools (Flex, Bison). The scanner, parser, semantic checker and code generation were all developed as part of this compiler. The source language is J-- (subset of Java), and the compiler targets WebAssembly by outputting WebAssembly Text Format (WAT).&lt;/p&gt;

&lt;h2&gt;
  
  
  Link to Code
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vWogaON8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-28d89282e0daa1e2496205e2f218a44c755b0dd6536bbadf5ed5a44a7ca54716.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/NataliaPavlovic"&gt;
        NataliaPavlovic
      &lt;/a&gt; / &lt;a href="https://github.com/NataliaPavlovic/CPSC411_Compiler"&gt;
        CPSC411_Compiler
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A J-- (subset of Java) compiler written in C, that compiles J-- into WebAssembly Text Format (WAT).
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
J-- Compiler&lt;/h1&gt;
&lt;p&gt;This project is a J-- (subset of Java) compiler written in C, that compiles J-- into WebAssembly Text Format (WAT).&lt;/p&gt;
&lt;p&gt;See the full J-- specification here: &lt;a href="https://pages.cpsc.ucalgary.ca/~aycock/411/spec.html" rel="nofollow"&gt;https://pages.cpsc.ucalgary.ca/~aycock/411/spec.html&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
There are 4 parts to the compiler:&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Scanner (Flex)&lt;/li&gt;
&lt;li&gt;Parser (Bison)&lt;/li&gt;
&lt;li&gt;Semantic Checker&lt;/li&gt;
&lt;li&gt;Code Generation&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When the compiler is run, it generates WAT files from J-- files. WASM files are then generated from the WAT files, and then the WASM files are run.&lt;/p&gt;
&lt;p&gt;All the provided J-- test cases can found here: &lt;a href="https://github.com/NataliaPavlovic/CPSC411_Compiler/tree/master/J--%20Test%20Files"&gt;J-- Files&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;All the generated WAT files can be found here: &lt;a href="https://github.com/NataliaPavlovic/CPSC411_Compiler/tree/master/Generated%20Files/WAT%20Files"&gt;WAT Files&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
Test Cases:&lt;/h4&gt;
gen.t1


&lt;p&gt;This test case makes use of the &lt;code&gt;prints&lt;/code&gt; run-time function, and outputs a string.&lt;/p&gt;

&lt;p&gt;Provided J-- File: &lt;a href="https://github.com/NataliaPavlovic/CPSC411_Compiler/blob/master/J--%20Test%20Files/gen.t1"&gt;gen.t1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Generated WAT File: &lt;a href="https://github.com/NataliaPavlovic/CPSC411_Compiler/blob/master/Generated%20Files/WAT%20Files/gen_t1.wat"&gt;gen_t1.wat&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
gen_t1.wasm output:&lt;/h5&gt;

&lt;pre&gt;&lt;code&gt;Hello, world
&lt;/code&gt;&lt;/pre&gt;



gen.t5

&lt;p&gt;Add Description.&lt;/p&gt;
&lt;p&gt;Provided J-- File: &lt;a href="https://github.com/NataliaPavlovic/CPSC411_Compiler/blob/master/J--%20Test%20Files/gen.t5"&gt;gen.t5&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Generated WAT File: &lt;a href="https://github.com/NataliaPavlovic/CPSC411_Compiler/blob/master/Generated%20Files/WAT%20Files/gen_t5.wat"&gt;gen_t5.wat&lt;/a&gt;&lt;/p&gt;
&lt;h5&gt;
gen_t5.wasm output:&lt;/h5&gt;
&lt;pre&gt;&lt;code&gt;42
42
42
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;gen.t10&lt;/p&gt;



&lt;p&gt;Add Description.&lt;/p&gt;

&lt;p&gt;Provided J-- File: &lt;a href="https://github.com/NataliaPavlovic/CPSC411_Compiler/blob/master/J--%20Test%20Files/gen.t10"&gt;gen.t10&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Generated WAT File: &lt;a href="https://github.com/NataliaPavlovic/CPSC411_Compiler/blob/master/Generated%20Files/WAT%20Files/gen_t10.wat"&gt;gen_t10.wat&lt;/a&gt;&lt;/p&gt;…&lt;/div&gt;


&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/NataliaPavlovic/CPSC411_Compiler"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;The compiler was implemented over the course of 4 months. The biggest challenge in this project was integrating all the parts of the compiler together in order to be able to do code generation. I learned the importance of doing thorough testing of each project milestone, and I also learned how to write useful test cases.&lt;/p&gt;

&lt;p&gt;Overall, the experience of implementing a compiler that was able to generate correct WAT code was very rewarding. I really enjoyed learning about various parts of a compiler and how those parts work.&lt;/p&gt;

</description>
      <category>octograd2020</category>
    </item>
  </channel>
</rss>
