Skip to content

A modern awk variation with a lisp language and an implicit stack

License

Notifications You must be signed in to change notification settings

RobertDober/awake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Awake

Installation

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

Synopsis

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.

Simple Patterns: Fields

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.

Complex Patterns: Function Pipelines (aka pipelines)

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.

Simple Patterns: Verbatim text

All text not containing a % or a ( is verbatim text, and as mentioned above %% and (( will be parsed as verbatim text containung % and ( respectively.

Implementation

This is implemented with a 3 phase compilation

Parser

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.

Author

Copyright © 2025 Robert Dober robert DOBER GmaIL com

LICENSE

GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 or later. Please refer to LICENSE for details.

About

A modern awk variation with a lisp language and an implicit stack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages