AI Writes the Code. Why Hasn't the Syntax Changed?

I decided to make a programming language. I had no idea how to run it.

Designing FlowScript syntax was fun. I could write Set user age to 20. or When user age is greater than 18:. But after putting those sentences on paper, a basic question remained: how would the computer actually execute them?

I had committed to building a language without understanding how languages run. I asked AI and began learning about compilers and interpreters. In my initial understanding, a compiler transforms source code into another executable form; an interpreter reads and executes a program. Real implementations are more varied than that simple distinction, but it was a new world to me.

Then I encountered the transpiler: a tool that converts one programming language into another, rather than necessarily compiling straight to machine code.

Suddenly the problem seemed manageable. I wasn't trying to reinvent the computer. I wanted a syntax that humans could read. An existing language could handle execution.

Wait, TypeScript works that way too?

My first association was TypeScript. The language I had been using gets transformed into JavaScript before execution.

“So TypeScript becomes JavaScript, and then the JavaScript engine processes it again?”

Those aren't identical kinds of translation, technically. But the discovery mattered: a language's syntax and its execution environment can be separate things.

I briefly worried that adding a translation stage would be slow. Then again, TypeScript was widely used. And my project was a small experiment in English-like syntax, not a new industrial runtime.

I chose JavaScript as the output language. I already knew it, and I wouldn't have to build an execution environment.

FlowScript source (.flow)
        ↓ transpile
JavaScript source
        ↓ execute
JavaScript runtime

Now I just had to turn FlowScript sentences into JavaScript. At first, that sounded easy.

My first approach: just replace the words

Consider:

Set price to 100.
Print price.

With a few rules, I imagined producing something like:

let price = 100;
console.log(price);

A sentence beginning with Set declares a variable; one beginning with Print outputs a value. I actually started by trying regular expressions and string replacement.

But that approach grew fragile as sentences changed. Replacing Set with let doesn't explain what appears on either side of to. After Print, the input could be a number, a string, a variable, or an expression.

Then came the syntax decision I was determined to keep: variable names could contain spaces, without quotation marks or backticks.

Set total price to item price times item quantity.

A person can infer that total price is the target variable and the rest is an expression. Blind replacement cannot reliably tell which words belong to a name and which express an operation.

What had seemed like a stylistic decision in episode two had become an architectural problem.

Lexer: splitting on spaces isn't tokenization

That led me to the Lexer. A lexer reads source code and produces meaningful units called tokens.

Splitting Set user age to 20. on spaces gives Set, user, age, to, and 20.. But those pieces don't tell us that user age is one variable name. Tokenization instead identifies clues the grammar can use: keywords, numbers, operators, and possible names.

Conceptually:

Input: Set user age to 20.

SET       → instruction keyword
user age  → candidate variable name
TO        → separator
20        → numeric value

This is a conceptual illustration, not a claim that the actual lexer emits a single user age token. An implementation can tokenize smaller pieces and let the parser group them.

The essential issue was that a space could no longer automatically mean the end of a name. Quoted identifiers would have been easier to recognize, but they weren't the language I wanted to make.

Parser: recognizing tokens doesn't mean understanding a sentence

The next stage is the Parser. It determines which grammatical structure the tokens form.

Set user age to 20.
Print user age.

These sentences use similar words but perform different operations. The parser needs to recognize that Set takes a name followed by to and a value, whereas Print takes an expression to output.

It also needs to reject invalid structures:

Set user age 20.

Here the to separator is missing. A person might guess the intention, but if the language guessed freely, its rules would stop being dependable.

Multiword identifiers made the problem harder. Before to, a series of words can form a variable name. Inside an expression, the parser must also know where names stop and operators begin. Human English relies on context; a programming language needs to turn that context into explicit grammar.

AST: keep the meaning, not every word

Once the parser recognizes the structure, it needs a representation. That's where I learned about the Abstract Syntax Tree (AST).

An AST isn't a copy of the original sentence. It's a tree representing the essential structure:

Set user age to 20.
Assignment
├── target: "user age"
└── value
    └── Number: 20

The words Set and to helped identify the statement, but the AST doesn't have to preserve them in their original form. It keeps the relationship: assign the number 20 to a variable named user age.

That intermediate representation matters because code generation no longer has to care whether the original sentence contained the or used different capitalization.

I began to understand the distinct jobs:

  • Lexer: what pieces are present?
  • Parser: how are those pieces structured?
  • AST: what operation does that structure represent?

They had sounded similar to me at first. They answer different questions.

Now I could generate JavaScript

With an AST, the final step is code generation: express the structure in JavaScript syntax.

FlowScript
  Set user age to 20.
          ↓
Lexer → Parser → AST
          ↓
JavaScript
  let userAge = 20;

The let userAge output illustrates the principle; actual identifier conversion and declaration rules can produce different output.

The same architecture makes it easier to add new syntax. To support When, the parser recognizes a conditional structure and the generator translates it into JavaScript's if. A For each loop follows the same general pattern.

Unlike replacing text line by line, understanding a sentence and generating its output had become separate steps. As features grew, that separation made the code easier to reason about.

The first successful run wasn't the finish line

Using this structure, I could run .flow programs with variable assignments, printing, conditionals, and loops. Seeing my own sentences become JavaScript and produce output was a meaningful milestone.

But a few successful examples didn't prove the language was complete. I still had to deal with malformed statements, indentation and block boundaries, and expressions mixing multiword names with operators.

Most importantly, a choice that had initially felt like a visual preference—allow spaces in variable names—had pushed me to learn how lexers and parsers work.

My question changed three times: “How do I build a language?” became “How do I translate English-like sentences into JavaScript?” and then something deeper:

“What rules will keep the computer from misunderstanding my sentences?”

That question remained even after the first program ran.