First, let’s get familiar with the basic building blocks of the language.

Pomsky expressions describe the syntactical structure of a text. There are several kinds of expressions, which will be explained now.

In Pomsky, whitespace is insignificant, except between quotes. This means that we can add spaces and line breaks to make the code look clearer. We can also add comments to explain what the expressions are doing. They start with a # and span until the end of the line:

# this is a comment
# comments are ignored by pomsky!


In Pomsky, characters that should be matched as-is are always wrapped in quotes. We can use double quotes ("") or single quotes (''). We call text wrapped in quotes a string. It matches the exact content of the string:


In double quoted strings ("..."), double quotes can be escaped by prepending a backslash. Strings in single quotes are “raw strings” and do not support backslash escapes:

# is equivalent to

Concatenate expressions

Pomsky consists of expressions. For example, a string is an expression. If we write several expressions in a row, they are matched one after the other:

'hello' 'world' '!'
# is equivalent to


What if we want to match one of several strings? In a regex, we can enumerate multiple alternatives, divided by a |:


The same works in Pomsky:

'one' | 'two' | 'three' | 'four' | 'five'

This type of expression is called an alternation. Pomsky also allows a leading |, which looks a bit nicer if we put each alternative on its own line:

| 'one'
| 'two'
| 'three'
| 'four'
| 'five'