UTILITIES NEWBIE

Tiny language playground

Explore variables, arithmetic and parentheses in a small interpreter. This is an educational language with its own limited grammar; it does not execute JavaScript or access files or a network.

Input

0 UTF-16 code units

Inputs start empty. Load example fills them only when you choose it. Reset clears current inputs and results.

Output

This tool processes inputs in your browser. See the Privacy Policy for details about hosting and performance measurement.

Trace values into print lines. Full explanation follows.
price = 7; quantity = 3. Text explanation

The checked toy-language assignments store seven and three; print statements yield twenty-one and twenty-four. This is a bounded arithmetic teaching interpreter, not JavaScript or a persistent external account calculation.

Follow a tiny arithmetic program one line at a time

Use the supported teaching language rather than JavaScript

Toy Playground interprets a deliberately small arithmetic language. A program can assign a numeric expression with let and print an expression’s result. This is useful for learning order of operations, following a variable through a few steps and comparing an expected output with an observed one. It is not a JavaScript console, shell or general-purpose programming environment. Pasting application code does not give it access to browser APIs, files or network operations; unsupported statements are rejected by the tool’s grammar.

Each run begins with a fresh variable map and a fresh output list. Names created in an earlier run are not a persistent session that a later program can rely on. Keep a complete small program in the source field so another person can reproduce it without guessing hidden state. The language accepts numeric arithmetic, parentheses, unary signs and previously defined names. Whole-line comments beginning with a hash can explain an exercise, while blank lines are skipped. Comments are not a way to attach arbitrary JavaScript syntax to a valid statement.

The output contains printed numbers, one per print statement, rather than a display of every assignment. A program that assigns a variable but never prints produces the explicit no-print message. Decide which intermediate values need to be printed when designing a lesson. A final correct number alone can hide an incorrect intermediate assumption, so include a small extra observation where it makes the reasoning clearer. Use synthetic numbers whose purpose is explained rather than suggesting that this teaching interpreter has inspected a real account, measurement or production calculation.

Reproduce the price and quantity fixture

Checked synthetic input

let price = 7
let quantity = 3
print price * quantity
print (price + 1) * quantity

Recorded processor observation

21
24

The checked program assigns price equal to seven and quantity equal to three. It prints their product, giving twenty-one, then prints the product of quantity with price plus one, giving twenty-four. The parentheses in the second expression make the addition happen before multiplication. The exact source block and two output lines let a learner compare each statement with its result. These are synthetic arithmetic values; the tool does not fetch a price, apply tax rules or make a financial recommendation from the variable names.

An assignment stores the expression’s current numeric result. If a later assignment uses the same name, the stored value is replaced for subsequent statements. It is not a spreadsheet formula that automatically recalculates earlier values. In a separate checked example, x starts at two, is reassigned to x plus three and then prints x multiplied by x, producing twenty-five. Read that sequence in order. The diagram traces the stored values and printed output instead of implying that the program has loops, event handlers or a persistent external database.

A comparison exercise prints two plus three times four, then the product of four with parenthesized two plus three. The observed results are fourteen and twenty. Multiplication binds more tightly than addition, while parentheses change the grouping explicitly. Printing both results makes the difference testable rather than merely stating a precedence rule. Preserve the original expressions when explaining the result, because changing parentheses changes the calculation itself. The tool reports numbers and errors; it does not infer which grouping a learner intended to write.

Respect floating-point arithmetic and parser boundaries

Numbers follow JavaScript’s finite numeric arithmetic in this interpreter. Division is not the truncating integer division used by the separate bitwise calculator: minus seven divided by two produces minus three point five. The checked sum of one tenth and two tenths prints a longer decimal representation rather than an exact three tenths. This is a concrete floating-point limitation, not an instruction to change values until the display looks familiar. Use a suitable exact-arithmetic workflow when a real requirement depends on exact decimal quantities or a specific rounding policy.

The supported operators are addition, subtraction, multiplication and division, with unary signs and parentheses. There are no string values, arrays, function calls, loops, conditional statements or object properties in this language. Unknown names and incomplete expressions produce errors. A division by zero is rejected rather than returned as an ordinary result, and a nonfinite final expression is not accepted. When a program fails, retain its line number and message before editing it so a correction can be distinguished from the original observation.

Programs are bounded to one hundred physical lines and a shared two-thousand-token parsing budget, with forty expression nesting levels. Blank and comment lines still occupy physical lines even though they do not perform arithmetic. Source and output have the page’s broader text bounds as well. A short program can still contain a syntax or mathematical error; being within a limit is not proof of correctness. Reduce a failing specimen deliberately, keeping complete statements and parentheses instead of cutting at an arbitrary character position and introducing a different problem.

Use printed observations to support a clear explanation

For a classroom example, choose a variable assignment that can be checked manually and print the value before and after a deliberate reassignment. Ask what changed in the stored value rather than claiming that the interpreter performed an unseen business process. Whole-line comments can state the intended arithmetic, while printed intermediate results provide evidence for the discussion. The accessible visual and text equivalent make the example understandable without relying on syntax coloring or a screenshot of a particular browser theme.

For a parser exercise, keep one valid program beside small invalid variants: an unknown name, a missing closing parenthesis or a zero denominator. Explain why each is a distinct failure. The line number refers to the submitted physical program, including blank and comment lines, so preserve those when comparing error locations. This is a finite teaching language with its own rules, not proof that the same specimen is valid Python, JavaScript or another programming language. Test another language in its actual authorized environment rather than treating familiar keywords as conformance evidence.

Copy and Download transfer the current printed output as text. They do not save a runnable project, install software or execute it elsewhere. Reset clears the current workspace, and a new run starts its own variable map. Keep the source alongside the output if another person needs to repeat the lesson. The useful endpoint is a small, inspectable arithmetic trace with known language and numeric limits, while production algorithms, exact-number policies, application testing and publication remain separate responsibilities.

Supporting reference: Numeric representation context; this toy parser is not a JavaScript runtime.

Find a tool

Type a tool name, such as JSON or percentage.

Quick links

Browse by category

All tools