Gema

Gema — Free Download. Text processing using patterns
Gema is a general-purpose text processing utility based on the concept of pattern matching. It reads an input file and copies it to an output file, performing specific transformations on the data according to a set of patterns defined by the user. This tool performs functions similar to Unix utilities such as cpp, grep, sed, awk, or strings. It operates as a macro processor, but with greater generality than cpp or m4, as it does not impose a particular syntax for macro calls.
5.0(1 ratings)

Download Gema (Official links)
File size: 44.4 MB
The latest version of Gema is: 2.0
Operating system: Windows, Linux, MacOS
Languages: English
Price: $0.00 USD

  • Pattern Matching. Gema uses a powerful pattern language to identify text in the input stream. Patterns can contain literals, wildcard characters, character classes, and references to matched parts. Matching is greedy, seeking the longest possible match.
  • Text Substitution. When a pattern match is found, Gema executes associated actions that generate output text. Actions can include literal text, references to matched parts, calls to built-in or user-defined functions, and variable modification.
  • User-Defined Macros. Users can define named macros that encapsulate complex patterns and actions. These macros can accept parameters and be invoked in other parts of the program, allowing the construction of reusable libraries of text transformations.
  • Variables and State. Gema maintains a set of variables that can be set, modified, and referenced during processing. Variables can store strings, numbers, or even fragments of action code, providing a mechanism to maintain state between pattern matches.
  • Built-in Functions. It includes numerous built-in functions for string manipulation, type conversion, mathematical operations, and flow control. These functions can be used within actions to transform data before output.
  • Line and Block Processing. It can operate in modes that process text line by line or in larger blocks, with patterns that can extend beyond line boundaries. This mode is suitable for processing structured text or markup languages.
  • Regular Expressions. Although it has its own pattern language, Gema can integrate with regular expressions through built-in functions, allowing the power of regex to be used in patterns when necessary.
  • Conditionals and Flow Control. It includes constructs for conditional execution and loops within actions. This allows decisions to be made based on the matched content or the state of variables, making transformations more dynamic.
  • File Inclusion. It supports including other pattern files during processing, facilitating the organization of large rule sets across multiple files and the reuse of pattern libraries.
  • Context Handling. Patterns can be context-sensitive, activating only when certain conditions are true or after other patterns have matched. This allows implementing complex transformations that depend on previous state.
  • Recursive Processing. Actions can generate output that is subsequently processed by the same patterns, allowing recursive processing. This feature is useful for nested transformations or processing hierarchical structures.
  • Unicode Support. Gema supports Unicode text, allowing the processing of international data and writing patterns that match characters beyond ASCII.

Gema was initially created by David N. Gray in 1996. Development began as a more general alternative to existing macro processors. The program is written in the C language, which provides portability across different operating systems. Over the years, several collaborators have contributed to the project, adding new features and improvements. Gema is distributed as source code software through platforms such as SourceForge, where users can access the latest versions and contribute to development.


Alternatives to Gema: