Home

Axel Gehlert

Project Admins:

RAG Pattern replacer

The first release v0.1 is on its way

Only a few more preparation steps have to be taken and v0.1 is ready.
v0.1 will be a working but first draft version of rag pr to play around with.
The aim is to find possible usability improvements and to test the pr language syntax.

v0.1 will not be production ready but i am sure you can write first simple useful pr scripts.
Be aware that some language features may change in the future so you have to port your scripts to new rag pr versions in the future.

Take a look on the sample scripts in the code folder example_scripts to get a first impression of the language.

By the way: You can make the cmd line tool print the pr script syntax by executing

rag --print-syntax

Get more info by executing:

rag --help

Whats can i use the pattern replacer for?

  • Extract any kind of information out of input files
  • Filter input files
  • Convert ASCII file formats
  • Quickly develop your own DSL (Domain-Specific-Language)
  • Write code generators
  • ...

How does it work?

In order to use rag pr, you need to write a pattern replacer script that

1) Defines the syntax of the input file (the "patterns")
2) Defines the actions to be taken depending in the input

The pattern-replacer-language is a simple OOP-Language that allows you to

  • Define your own syntax rules and/ or regexps
  • Do simple pattern-replacement operations based on "default replacements" and user-defined replacement on syntax-rule-level
  • Define classes and methods if you need more than just syntax rules and replacements
  • Use syntax rules like classes
  • Use everything as an object

Is it like awk?

Yes and no.

Like awk, rag pr

  • applies patterns/ regexps to an input file and performs the actions defined in the script whenever a pattern is recognized.

Unlike awk, rag pr

  • needs a complete syntax description for the input file as a the "patterns".
  • first reads the input file completely into "objects" and then the actions or replacements are performed like methods on those objects.
  • has an oop scripting language

If you like, you can think of rag pr as a modernized version of awk.

Well, in fact first i had the idea to the pattern replacer and while working on it i found that it slightly reminded me of AWK - which is one of my favourite command line tools.