Meso^(pronounced /me.zo/) is a programming language of which I'm designing the spec for before starting to work on a compiler, which I will describe here! I hope to be as thorough as possible in both implementation details and from the perspective of someone trying to learn and understand Meso. The goal being that if you wanted to, you could implement your own Meso compiler or write complete Meso code with minimal knowledge of the underlying infrastructure.
Meso is a high level programming language built on top of the Lua ecosystem whose compiler generates LuaJIT compatible source code. The Meso language is designed to standardize and organize how things can be expressed in Lua, more than simplifying its syntax. Meso code is constructed from a series of expressions, directives, tags, and finally statements which build the basic features of the language.
██████████████████
l122.posts.articles.meso.expressionsMeso's expressions are unique compared to other programming languages in that there is no operator precedence and no set expression notation, making expressions one operator per expression. The only exception to this is unary operators like not, which operate on the immediate next value and do not count to the "limit". In practice this means that Meso enforces a single operator per expression, rather than evaluating things in order.
-* You can imagine that it scans the expression left to right, storing the two data arguments and one operator on a stack, and then executing the expression. *- (1 * 2), -- 2 (* 1 2), -- 2 (1 2 *), -- 2 -* There can only be one operator per expression this way, making multiple operators ambiguous syntax, and a syntax error. *- ((1 + 2) * 3), -- 9 (1 + (2 * 3)), -- 7 (1 + 2 * 3), -- [Ambiguous syntax]
To demonstrate further, you could imagine an operator either that picks between two boolean values as (either (x > 5) (y > 5)) and this is completely valid in Meso given the either operator is defined.
Expressions in Meso are tag dependant and may not exist outside of a directive, but this will be explained in later sections. For now we represent the code between expressions of different meanings using ....
To begin, Meso comes with the basic arithmetic operators as well as explicit declaration and assignment operators which are used like (identifier : Type), and identifier := value;.
... (x : Number), (y : Number), ... x := 1; y := 2; (x + y); -- 3 ...
Please note the use of parentheses here is only for style and doesn't change the behavior of the code. This code could be coalesced by combining the declaration and assignment operators as (y : Number) := 2,. The significance of the separation will make sense in later sections. Here you may notice a small inconsistency between the two sections of expressions in that the first two use a comma delimiter and the last three use a semicolon delimiter. Expressions in Meso are universal, meaning that every statement, line, and arithmetic operation is made of the same basic building blocks.
Because of this, most of Meso's syntax is made up of small conventions that help to add additional context for the reader to peer into how the code actually behaves.^(In this way Meso acts as the ultimate DSL, its syntax is very minimal and very flexible by design.) Here this context is separating the data definitions inside the first block with the code that runs on the second block. Doing this is the same way we would separate fields by comma or arguments for a procedure by comma. This provides a simplified high level similarity so that the reader can tell what they're looking at. This is an important concept for understanding how to read and write Meso code.
For the next section we introduce a standard library procedure f, whose signature is procedure f input [n : Number] output [Number] end f;. The nuances of how this is defined should make sense by the end of the directives section, but all that's needed for the moment is that f is a function which takes one argument n and returns the factorial of n.
l122.posts.articles.meso.directivesDirectives take the form of a statement while creating a new scope and opening tags. All directives start with a reserved
tagsTags
l122.posts.articles.meso.statementsStatements