All Projects → thesephist → Tabloid

thesephist / Tabloid

Licence: mit
A minimal programming language inspired by clickbait headlines

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Tabloid

Webassemblyjs
Toolchain for WebAssembly
Stars: ✭ 566 (+140.85%)
Mutual labels:  parser, interpreter
Rs Monkey Lang
Monkey Programming Language written in Rust.
Stars: ✭ 80 (-65.96%)
Mutual labels:  parser, interpreter
Mico
Mico ("Monkey" in catalan). Monkey language implementation done with C++. https://interpreterbook.com/
Stars: ✭ 19 (-91.91%)
Mutual labels:  parser, interpreter
Goawk
A POSIX-compliant AWK interpreter written in Go
Stars: ✭ 995 (+323.4%)
Mutual labels:  parser, interpreter
Lioness
The Lioness Programming Language
Stars: ✭ 155 (-34.04%)
Mutual labels:  parser, interpreter
Sh
A shell parser, formatter, and interpreter with bash support; includes shfmt
Stars: ✭ 4,343 (+1748.09%)
Mutual labels:  parser, interpreter
Littlelang
A little language interpreter written in Go
Stars: ✭ 56 (-76.17%)
Mutual labels:  parser, interpreter
Craftinginterpreters
Repository for the book "Crafting Interpreters"
Stars: ✭ 4,298 (+1728.94%)
Mutual labels:  parser, interpreter
Forge
A lightweight, elegant scripting language with built-in Rust-FFI.
Stars: ✭ 153 (-34.89%)
Mutual labels:  parser, interpreter
Endbasic
BASIC environment with a REPL, a web interface, and RPi support written in Rust
Stars: ✭ 106 (-54.89%)
Mutual labels:  parser, interpreter
Internettools
XPath/XQuery 3.1 interpreter for Pascal with compatibility modes for XPath 2.0/XQuery 1.0/3.0, custom and JSONiq extensions, XML/HTML parsers and classes for HTTP/S requests
Stars: ✭ 82 (-65.11%)
Mutual labels:  parser, interpreter
Cub
The Cub Programming Language
Stars: ✭ 198 (-15.74%)
Mutual labels:  parser, interpreter
Monkey Rust
An interpreter for the Monkey programming language written in Rust
Stars: ✭ 174 (-25.96%)
Mutual labels:  parser, interpreter
Logo
A Logo interpreter written in Swift
Stars: ✭ 207 (-11.91%)
Mutual labels:  parser, interpreter
Parsica
Parsica - PHP Parser Combinators - The easiest way to build robust parsers.
Stars: ✭ 223 (-5.11%)
Mutual labels:  parser
Cppast.net
CppAst is a .NET library providing a C/C++ parser for header files powered by Clang/libclang with access to the full AST, comments and macros
Stars: ✭ 228 (-2.98%)
Mutual labels:  parser
Neodoc
Beautiful, hand-crafted commandline interfaces for node.js
Stars: ✭ 221 (-5.96%)
Mutual labels:  parser
Phonia
Phonia Toolkit is one of the most advanced toolkits to scan phone numbers using only free resources. The goal is to first gather standard information such as country, area, carrier and line type on any international phone numbers with a very good accuracy.
Stars: ✭ 221 (-5.96%)
Mutual labels:  parser
Posthtml
PostHTML is a tool to transform HTML/XML with JS plugins
Stars: ✭ 2,737 (+1064.68%)
Mutual labels:  parser
Arturo
Simple, expressive & portable programming language for efficient scripting
Stars: ✭ 225 (-4.26%)
Mutual labels:  interpreter

The Tabloid Programming Language 💣

Tabloid is a minimal but Turing complete programming language inspired, nay, supercharged by clickbait headlines that rule the Internet today. You can try Tabloid on the Tabloid website or on the Riju repl. Thanks to @otherjoel, there's also a Racket implementation of Tabloid that's very nearly compatible.

Tabloid website screenshot

Tabloid is quite small -- it only supports number, string, and boolean values at the moment, and have semantics that match JavaScript since JavaScript is used to implement the language backend. But it's good enough for a joke language made in six hours, so I'm rollin' with it.

Language overview

You can find the complete list of special Tabloid keywords on the Tabloid website.

Tabloid has an expression-based grammar, and lacks any distinction between expressions and statements. If there isn't an explicit return from a function, the last expression's value will be returned.

Here are some primitive values in Tabloid: numbers, strings, booleans

100
3.141592
.718
'Hello, World!'
TOTALLY RIGHT
COMPLETELY WRONG

The last two -- TOTALLY RIGHT and COMPLETELY WRONG -- are how we write true and false in Tabloid.

Tabloid supports binary infix operators for arithmetic and logic.

(3 TIMES 5) PLUS (20 DIVIDED BY 7)
(x IS ACTUALLY 3.1415) OR COMPLETELY WRONG

IS ACTUALLY is a way to test equality, like == in most other languages. We can also make comparisons with X BEATS Y (x > y) and X SMALLER THAN Y (x < y).

We can print the result of any expression with YOU WON'T WANT TO MISS. You won't want to miss what you're printing, and now you never will!

YOU WON'T WANT TO MISS 'Hello, World!'

Conversely, we can take (string) input from the user with LATEST NEWS ON. This creates a prompt to ask the user of your incredible program about the latest news.

EXPERTS CLAIM age TO BE
    LATEST NEWS ON 'What is your age?'

We define functions with DISCOVER HOW TO functionName WITH arguments, like, this. We can call them with the OF keyword.

DISCOVER HOW TO speak WITH message
RUMOR HAS IT
    YOU WON'T WANT TO MISS message
END OF STORY

speak OF 'Hello!'

Lastly, Tabloid has conditional expressions in the form of an if-else, which is written like...

WHAT IF condition
    doIfThing
LIES!
    doElseThing

We can have multi-line bodies in the doIfThing and doElseThing sections by creating a new scope, delimited by RUMOR HAS IT and END OF STORY. LIES! is optional.

WHAT IF condition RUMOR HAS IT
    do
    many
    things
END OF STORY

In Tabloid, newlines are not significant. If you want, you can squeeze your entire damn program in a single line of source code! How wonderful! I see exactly zero ways that could possibly go wrong.

The entire interpreter is contained in a single file, static/js/lang.js, and pretty straightforward. Due to the, ahem, unusual syntax of Tabloid, there are four layers, which includes a double-pass tokenizer that first produces a stream of word tokens (a string literal is a single word, punctuations are treated separately), and then a second tokenizer that tokenizes multi-word keywords like DISCOVER HOW TO (which is 3 words).

The interpreter uses a tree-walk evaluator on the syntax tree to execute a program.

How to use

Please don't.

Limitations

Tabloid's syntax has some (soft) limitations for now, because I had ~8 hours to finish it. Here are some of them:

  • The parser doesn't know about operator precedence. To chain infix operators together like 3 PLUS 2 TIMES 10, use parentheses, like 3 PLUS (2 TIMES 10).
  • There isn't a built-in looping construct, like a while loop. This could be viewed as a feature, but is a little annoying. I left it out because it was less trivial than the other features to implement.
  • There isn't very good error reporting. If there is an error during parsing or at runtime, the interpreter will currently report an error and what went wrong, but won't tell you where it messed up and will reveal interpreter implementation details.

Tabloid also doesn't have comments, because... I honestly forgot about them when I made this and only remembered like 7 hours in, and I got lazy. If this bothers you for some insane reason, feel free to make a pull request... I guess.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].