Drus-Ja
A small language I wrote in C++ in 2022 and 2023. It compiled to MASM32 on Windows. Here it compiles to JavaScript, and it can still only say numbers.
Names are exactly six letters. Cmd or Ctrl + Enter also runs it.
JavaScript
The program does not compile, so there is no JavaScript.
The language
A program is Program Name; Var; … Start; … Finish;. It prints whole numbers,
one per line, and has no other output.
Integer Number 5;- Declares a variable, in the Var block. Integer is the only type, 32 bits, signed.
Number -> Number + 1;- Assigns.
Output Number;Input Number;- Print a value. Read a line from the input box.
If (Number Ge 1); … Else; … EndIf;- Branches. Else is optional.
For Number; … Downto 1;- Counts Number down to 1, including 1. This is the only loop.
Arithmetic is + - Mul Div Mod. Conditions use
== != Ge Le && || !!. Comments are /* like this */.
Names are exactly six letters and can't begin with a keyword, so Letter and Forest won't do. Bracket every comparison.
Quirks kept from the original
- Keywords match the front of any word, in any case. Letter reads as
Leand then fails. 5-3is two numbers. Write5 - 3.- Tabs are not allowed. The Tab key here inserts spaces.
- A comment swallows the character right after it, and a multi-line comment counts as one line, so later error numbers drift.
- Only
Mul Div Modbind tighter. Everything else shares one level, left to right. GeandLeare strict, and so is!!(a Ge b): both are false when a equals b. Inside||, all of these include equality.- In
a || b || c, c is never tested. (a && b) || cneeds all three.(a || b) && cignores c. Ina || (b && c), only a decides.!!flips each test but does not swap&&and||.If (Number + 1);always takes the body.If (Number);fails with Unknown node type.- An If with an Else needs a statement before the Else.
!!can end a declaration in place of;.- The already declared error names the token after the variable.
- Everything after
Finish;is ignored once it has passed the lexer.
What changed for the browser
- Programs the C++ accepts and
mlwould refuse get an Assembly error, in wording written for this page. That covers comparisons outside If, assigning to a number, Input or For on anything but a variable, and numbers over 32 bits. - Unary
-and!!outside a condition generate no code, so the original reads stack garbage. Here the program stops with a Runtime error.-5is a number and works. - Starting a variable from another copies its value. The original stored its address.
- Names that clash with MASM, like offset, buffer or StdOut, work here.
- Div or Mod by zero, and -2147483648 Div -1, stop with a Runtime error. The original process crashes.
- Output no longer leaks stack, so a long loop can't overflow it. Output stops at 64,000 characters instead.
- Press enter key to close program is not printed.
- Input takes one line at a time by
atoirules, and stale console buffer contents can't show through. With no line left the program stops, where the original would wait at the console. - The C++ reads past its token list at the end of a file. Those errors point at the last token here, and undefined cycle and undefined if fire as intended.
- Error text is the original's, and its line number can drift. The marked line is always the real one.
- An empty program prints nothing. The original reports a missing file.
- The JavaScript has not been compared against a real MASM32 build.