# loki.frontend.regex module

The implementation of a regex parser frontend

This is intended to allow for fast, partial extraction of IR objects from Fortran source files without the need to generate a complete parse tree.

class RegexParserClass(*values)

  Bases: `Flag`

  Classes to configure active patterns in the `REGEX` frontend

  Every `Pattern` in the frontend is categorized as one of these classes. By specifying some (or all of them) as `parser_classes` to `parse_regex_source`, pattern matching can be switched on and off for some pattern classes, and thus the overall parse time reduced.

  EmptyClass = 0
  ProgramUnitClass = 1
  InterfaceClass = 2
  ImportClass = 4
  TypeDefClass = 8
  DeclarationClass = 16
  CallClass = 32
  PragmaClass = 64
  AllClasses = 127

parse_regex_source(source, parser_classes=None, scope=None)

  Generate a reduced Loki IR from regex parsing of the given Fortran source

  The IR nodes that should be matched can be configured via `parser_classes`. Any non-matched source code snippets are retained as `RawSource` objects.

  Parameters:

    - source (str or `Source`) – The raw source string

    - parser_classes (RegexParserClass) – Active parser classes for matching

    - scope (`Scope`, optional) – The enclosing parent scope

HAVE_REGEX = True

  Indicate that the regex frontend is available.