rosie − Rosie Pattern Engine (Rosie Pattern Language)
rosie [ global-options ] command [ command-options ] pattern-expression file [...]
Rosie 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, Ruby, Javascript, and other languages that support libffi. Rosie can be used for data mining on large data sets, or for the kind of smaller tasks that 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, etc.).
The primary commands are match and grep. Help for a command is obtained using the −h option (see below).
config |
Print the configuration of the Rosie installation, including build information if available. |
expand exp
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.
grep exp [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.
help |
Print help text. |
list [name[.name]]
List the available patterns from the library whose name matches name. To list all the names in an imported package, use list pkgname.*.
match exp [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 the grep command for behavior that is more like that utility.
repl |
Enter the read-eval-print loop for interactive development and testing of patterns |
test file1 [...]
Execute the pattern tests embedded within the listed rpl files.
trace exp [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.
version
Print the Rosie version and exit.
−-colors colorspecs
Specify a set of colors and font attributes, each associated with a pattern name. The format of colorspecs is a colon-separated list of name=spec, where 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. The format of 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.
−f, −-file file
Load a file of rpl code. This option may be repeated.
−-libpath paths
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 libapth 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.
−-norcfile
Do not load any initialization file.
−o, --output style
Output match data according to style, which may be color, subs, matches, json, line, and 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 the grep command, is line.
−-rcfile file
Load the initialization file specified, instead of the default, ~/.rosierc.
−-rpl source
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.
−-verbose
When appropriate, output additional information.
−h, −-help
Display help for a command. This option must be given after the command name, e.g. rosie match −h.
−a, −−all
Generate some output for all input lines. Lines that do not match the pattern are written to stderr, while matched output is written to stdout.
−w, −−wholefile
Match against the whole input file as if it were a single string.
−F, −−fixed−strings
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 GitHub repository.
~/.rosierc
This is the default initialization file, which is loaded before any command line options are processed. The syntax of .rosierc 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, bar and baz. The recognized options are:
colors="..." |
sets colors to a colorspec (can be used multiple times; values will be concatenated) |
||
libpath="..." |
sets libpath (can be used multiple times; values will be concatenated) |
||
loadfile="..." |
loads the specified (single) file (can be used multiple times to load multiple rpl files) |
Forthcoming
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 Rosie's issue page.
Rosie's home (news, docs, etc.)
Jamie A.
Jennings
email contact
@jamietheriveter
With contributions from the people listed in the CONTRIBUTORS file.