Compiler Stages and Reverse Polish Notation

A compiler turns characters into tokens, a parse tree and stack instructions without changing what the expression means, and RPN needs no brackets because a stack applies each operator in turn.

Compiler Stages and Reverse Polish Notation
↺

A Level

Which characters become tokens?

Edit Source so all three given operands become Tokens without an unknown character; Run.

Characters → tokensLexical analysis
Tokens → treeSyntax analysis
Tree → instructionsCode generation
Less work, same meaningOptimisation

Run time Values → Stack → Result

One expression; names are case-sensitive, start with a letter and continue with letters or digits. Whole numbers, + - * / and brackets; // begins a comment. Inputs 0–99; negative results are allowed. Non-whole quotients and division by zero stop at run time. Fifteen tokens and six stack values are teaching limits; instruction counts are not timings.