Basic

What a compiler is for

A compiler takes text and returns a meaning. The text is the input and the meaning is the output, and the whole subject is the shape of the thing in between.

What you will see

3. The answer is a decision a test can check.

About 1 min of reading

Try It

Write the three parts

1

Write the input

printf '1 + 2\n' > /tmp/i.txt; cat /tmp/i.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
1 + 2. Text, which is the input with no shape.
2

Write the middle

printf 'add left=1 right=2\n' > /tmp/m.txt; cat /tmp/m.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
One line with a name and two places. That is the shape written down.
3

Write the answer

printf '3\n' > /tmp/o.txt; cat /tmp/o.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
3. The answer is a decision a test can check.

Data Flow

Text to a decision
1 Text arrives with no shape
↓
2 The text is given a shape
↓
3 The shape is kept as a value
↓
4 The answer is accepted or a place is named
Why this works
Why the middle is drawn

A compiler with no middle is a function that cannot be tested in pieces. The middle is what makes the pieces testable.

The claim of this subject

A compiler you can read at every step. Reading at every step is the reason the compiler is built rather than used.

Examples

The input is text

Text has no shape. A number in text is a number only after something decides it is one.

The output is a decision

The compiler either says the text is a program or names where it is not. Both answers are decisions, and a decision is what a test can check.

The middle is the interesting part

The middle is a value with a shape. A shape that is written down is a shape that can be printed and argued with.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

Next Lesson
Tokens as a language with a shape
Tokens as a language with a shape →