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 (
wrapped in quotes we call a string. It matches the exact content of the string:
In double quoted strings (
"..."), double quotes can be escaped by
prepending a backslash. Backslashes also must be escaped:
"\"C:\\windows\"" # is equivalent to '"C:\windows"'
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' '!' # matches the string "helloworld!"
What if we want to match multiple 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'