Crate scnr

Source
Expand description

§scnr

The ‘scnr’ crate is a library that provides lexical scanner for programming languages. It is designed to be used in a parser of a compiler or interpreter for a programming language or in similar tools that require lexical analysis, e.g. in a language server. It provides multiple scanner modes out of the box, which can be switched at runtime depending on the context of the input. A parser can use different modes for different parts of the input, e.g. to scan comments in one mode and code in another. The scanner is designed to be fast and efficient, and it is implemented with the help of finite state machines. To parse the given regular expressions, the crate uses the regex-syntax crate.

Structs§

  • An iterator over all non-overlapping matches.
  • A lookahead that is used to match the input. The lookahead is a regular expression that must match after the pattern for the pattern to be considered a match. The lookahead can be positive or negative. If the lookahead is positive, it must match for the pattern to be considered a match. If the lookahead is negative, it must not match for the pattern to be considered a match. The lookahead is optional. The characters read by the lookahead are not included in the match.
  • A match in the haystack.
  • A match with start and end positions.
  • A pattern that is used to match the input. The pattern is represented by a regular expression and a token type number. The token type number is used to identify the pattern in the scanner. The pattern also has an optional lookahead.
  • A position in the haystack. The position is represented by a line and column number. The line and column numbers are 1-based.
  • A Scanner. It consists of multiple DFAs that are used to search for matches.
  • A builder for creating a scanner.
  • A scanner mode that can be used to scan specific parts of the input. The contained data is used to create a scanner mode that can be used to scan the input.
  • The error type for the scrn crate.
  • A span in a source file.
  • An iterator over all non-overlapping matches with positions.

Enums§

Traits§

Type Aliases§

  • The result type for the scrn crate.