Chapter 7. Arrays and Hashes

This is a chapter fromCreating a compiler with Raku In this chapter, we will extend the Lingua language with aggregate data types: arrays and hashes. From this point, we will call variables that contain numbers and strings scalar variables. Arrays Arrays are collections of elements which share their common variable name and are accessible via integer indices. … Continue reading “Chapter 7. Arrays and Hashes”

On computing the number of recoveries

There are a number of issues with the raw COVID-19 statistical data. Most, if not all, of them come from the fact that different countries use different methods to get the numbers. The site aims to display the data to reduce panic, and it strongly needs data about recoveries. Unfortunately, the underlying data set … Continue reading “On computing the number of recoveries”

Chapter 6. Working with Strings

This is a chapter fromCreating a compiler with Raku Until now, the language only worked with numbers—integer and floating point, both in regular and in scientific notation. In the following two chapters, we’ll update the language and integrate other data types to it: strings, arrays, and hashes. Let us start with strings. Strings The first … Continue reading “Chapter 6. Working with Strings”

Chapter 5. Working on Grammar

This is a chapter fromCreating a compiler with Raku In this chapter, we’ll review the grammar that was created so far and will try to make some changes to make the grammar and the actions more compact, more readable and more user-friendly. The bigger the language becomes, the more important it is to keep its … Continue reading “Chapter 5. Working on Grammar”

A couple of syntax sweets in Raku

When working on preparing data for the site, I discovered a couple of interesting findings, which I did not notice earlier or did not pay much attention to it. Scanning two arrays together The first construct allows us to scan two different arrays in a single loop. For example, let’s print a table with … Continue reading “A couple of syntax sweets in Raku”

The Coronavirus Observer

Yesterday, I launched, the website displaying Coronavirus statistics. Unlike the most sources, this site tries to deliver the same data to avoid panic. It is obvious that the numbers are growing every day, but it is also important to realise two facts. First, as of today, the fraction of people with confirmed infection is … Continue reading “The Coronavirus Observer”

Chapter 4. A Better Interpreter

This is a chapter fromCreating a compiler with Raku This chapter is dedicated to Jeff Goff, who was one of the most active promoters of Raku grammars The goal of this chapter is to build a better interpreter using all the achievements of the previous three chapters. The new interpreter will be able to work … Continue reading “Chapter 4. A Better Interpreter”

Chapter 3. Creating a Calculator

This is a chapter fromCreating a compiler with Raku In this chapter, we will create a program that can evaluate simple arithmetic expressions such as 3 + 4  or 3 – 3 * 7. We’ll start from the simplest equations with two operands and will work until we can introduce parentheses. Enrolling a sum Let us first … Continue reading “Chapter 3. Creating a Calculator”