class

Fexpr::Scanner

Inherits Reference < Object

Reads and tokenizes filter expression text into a stream of tokens.

The scanner processes input character by character, recognizing tokens like:

  • Identifiers (e.g., name, age, @timestamp)
  • Numbers (e.g., 42, -1.5)
  • Quoted text (e.g., "crystal", 'v1.0')
  • Operators (e.g., =, !=, &&, ||)
  • Groups (expressions in parentheses)
  • Comments (starting with //)

Constants

IDENTIFIER_REGEX = /^[\@\#\_]?[\w\.\:]*\w+$/

Regular expression for a valid identifier.

Constructors

new(io : IO)

Creates a new scanner that reads from the given IO.

Source

Instance methods

comment_start_char?(ch : Char) : Bool

Checks if a character is a valid start of a comment.

Source
digit_char?(ch : Char) : Bool

Checks if a character is a digit.

Source
group_start_char?(ch : Char) : Bool

Checks if a character is a valid start of a group/parenthesis.

Source
identifier?(literal : String) : Bool

Checks if a literal is a properly formatted identifier.

Source
identifier_start_char?(ch : Char) : Bool

Checks if a character is a valid first character of an identifier.

Source
join_start_char?(ch : Char) : Bool

Checks if a character is a valid start of a join type operator.

Source
letter_char?(ch : Char) : Bool

Checks if a character is a letter.

Source
number?(literal : String) : Bool

Checks if a literal is numeric.

Source
number_start_char?(ch : Char) : Bool

Checks if a character is a valid first character of a number.

Source
reader
Source
scan

Returns the next token from the input stream.

If an error occurs during scanning, the returned TokenResult will contain an error message explaining what went wrong.

Source
sign_start_char?(ch : Char) : Bool

Checks if a character is a valid start of a sign operator.

Source
text_start_char?(ch : Char) : Bool

Checks if a character is a valid first character of a quoted text.

Source
whitespace_char?(ch : Char) : Bool

Checks if a character is a space, tab, or newline.

Source