If available in Hex, the package can be installed
by adding awake
to your list of dependencies in mix.exs
:
def deps do
[
# ...
{:awake, "~> 0.1.0"},
# ...
]
end
An awk like 'mini language', with a more concise syntax (tailored for command line usage) and a little bit less powerful (for now).
Awake applies a pattern to each input line.
The pattern is composed by a sequence of verbatim text, field_definitions and function_pipelines.
If not inhibited by any function in a function_pipeline a default print of the pattern is the action at the end of the pattern's application to a line.
All Fields start with a %
(use %%
for a verbatim %
in the pattern) and have an
optional name. It ends with a white space or the %e
(end_of_pipeline
, or `epsilon) field which
is rendered as an empty string and can also interrupt a pipeline.
If a fieled is followed by a list of lisp s-expressions the whole together forms a pipeline. As indicated by the name this will be interpreted as a pipeline of functions with the field value injected into it.
All text not containing a %
or a (
is verbatim text, and as mentioned above %%
and ((
will
be parsed as verbatim text containung %
and (
respectively.
This is implemented with a 3 phase compilation
It parses a pattern into an Abstract Syntax Tree (aka AST). Here is an example
"%ts hello %%"
becomes
[{:field, "ts"], {:verb "hello"}, # N.B. the first space is missing
{:verb, "%"}]
For a detailed description refer to the doctests of the Parser
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/awake.
Copyright © 2025 Robert Dober robert DOBER GmaIL com
GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 or later. Please refer to LICENSE for details.