rosie - Rosie Pattern Engine (Rosie Pattern Language)
rosie [global-options] command [command-options] pattern-expression [file1 [file2 ...]]
searches all given input files for lines that match a pattern. The pattern
language is similar to regular expressions, but more powerful. Also, a set of
predefined (named) patterns are provided. The pattern library is extensible.
Rosie patterns are written in
Rosie Pattern Language (RPL).
A shared library,
librosie, provides a programmatic interface to rosie in C,
Go, Python, and other languages that support
Rosie can be used for
data mining on large data sets, or for the kind of smaller tasks that Unix
grep and other regex tools are used for. The output can be plain text, like
grep produces, or can be structured JSON, in the form of a parse tree. A
number of other output options are available (see below).
The RPL Language Reference may be found via the Rosie home page (news, docs, and more).
The primary commands are
grep. Help for a command is obtained using the
-h option (see below). General help is available with the
Print the configuration of the Rosie installation, including build information if available.
Expands a pattern expression entered on the command line. Output is: (1) the expression as entered (which will show any shell expansions or substitutions); (2) the parsed expression; (3) what the expression means at top level, where a bare expression is a tokenized expression; and (4) the result after any macro expansions.
grepexp [file1 ...]
In the style of grep, match the given pattern against lines in the given input files (or the standard input). In this mode, the pattern may match anywhere within a line, and all matches within a line are found. The default output form in this mode is to print the entire line for all lines that match.
Print help text.
List the available patterns from the library whose name matches name. To
list all the names in an imported package, use
matchexp [file1 ...]
Match the given pattern against lines in the given input files (or the
standard input). Patterns in RPL begin at the start of the input line. See
grep command for behavior that is more like that utility.
Enter the read-eval-print loop for interactive development and testing of patterns
Execute the unit tests embedded within the listed rpl files.
traceexp [file1 ...]
Perform a match, but generate a trace listing of all the steps performed in the matching process. This can be quite a lot of output.
Print the Rosie version and exit.
Specify a set of colors and font attributes, each associated with a pattern
name. The format of colorspecs is a colon-separated list of
spec is a semi-colon separated list of ANSI (SGR) color and font
attributes. Colors may be specified by name or integer code. Attributes
include bold, underline, and others.
name can be
* for a global default;
pkgname.* for a package default;
localname to match a name exactly, without a prefix; or
pkgname.localname to match an imported name exactly.
Load a file of rpl code. This option may be repeated.
Set the rosie libpath, which is a colon-separated list of directories to
search, in order, for imported packages. The value is a colon-separated
string. When the libpath is not set by the user, Rosie looks for
imported packages in the installation directory, at ROSIE_LIBDIR (the
value of which can be seen using the
rosie config command).
Important note: If you set the libpath, you must explicitly include the standard library if you want Rosie to include the standard library in its search. A libpath set on the command line takes precedence over one set in an initialization file.
Do not load any initialization file.
Output match data according to format, which may be one of:
color, subs, data, json, line
or possibly other (installation-dependent) values. Use rosie help to discover what is available in your installation.
Note the default output style for the
match command is
color, and for
grep command, is
Load the initialization file specified, instead of the default,
Define additional patterns, import additional packages. The argument passed to --rpl is typically enclosed in single quotes so that Rosie will see it as a single string with no shell expansions performed.
When appropriate, output additional information.
Display help for a command. This option must be given after the command
rosie match -h.
Generate output for all input lines. Lines that do not match the pattern are written to stderr, while matched output is written to stdout.
Match against the whole input file as if it were a single string.
Interpret pattern as a set of fixed (literal) strings, instead of an RPL pattern (which reqires double quotes around string literals).
Stop reading from the given input files, if any, and start reading from the standard input.
Currently, Rosie does not use any environment variables. If this would be a useful addition, please open an issue on Rosie's GitLab repository to request this enhancement.
This is the default initialization file, which is loaded before any command line options are processed. The syntax of a Rosie rcfile is essentially the RPL syntax, with two dashes to start comments, and option values in double-quoted strings.
Options are set using an assignment-like syntax, e.g.
libpath = "bar:baz"
to set the rosie
libpath to a sequence of two directories,
The recognized options are:
colors to a colorspec (can be used multiple times; values will be concatenated)
libpath (can be used multiple times; values will be concatenated)
to load the specified file (can be used multiple times to load multiple rpl files)
Rosie does not normalize Unicode input. If a pattern contains composed characters, for example, these will not match their decomposed equivalents in the input (and vice versa).
The RPL compiler is slow (but matching is reasonably fast).
Issues (bugs and enhancement requests) may be found on the Rosie issue page.
See Rosie's home for news, docs, etc.
Jamie A. Jennings
With contributions from the people listed in the CONTRIBUTORS file.
Email the Rosie Project at email@example.com.
Follow @jamietheriveter on Twitter.