class Fexpr::Scanner
- Fexpr::Scanner
- Reference
- Object
Overview
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 //)
Defined in:
fexpr/scanner.crConstant Summary
-
IDENTIFIER_REGEX =
/^[\@\#\_]?[\w\.\:]*\w+$/
-
Regular expression for a valid identifier.
Constructors
-
.new(io : IO)
Creates a new scanner that reads from the given IO.
Instance Method Summary
-
#comment_start_char?(ch : Char) : Bool
Checks if a character is a valid start of a comment.
-
#digit_char?(ch : Char) : Bool
Checks if a character is a digit.
-
#group_start_char?(ch : Char) : Bool
Checks if a character is a valid start of a group/parenthesis.
-
#identifier?(literal : String) : Bool
Checks if a literal is a properly formatted identifier.
-
#identifier_start_char?(ch : Char) : Bool
Checks if a character is a valid first character of an identifier.
-
#join_start_char?(ch : Char) : Bool
Checks if a character is a valid start of a join type operator.
-
#letter_char?(ch : Char) : Bool
Checks if a character is a letter.
-
#number?(literal : String) : Bool
Checks if a literal is numeric.
-
#number_start_char?(ch : Char) : Bool
Checks if a character is a valid first character of a number.
- #reader : IO
-
#scan : TokenResult
Returns the next token from the input stream.
-
#sign_start_char?(ch : Char) : Bool
Checks if a character is a valid start of a sign operator.
-
#text_start_char?(ch : Char) : Bool
Checks if a character is a valid first character of a quoted text.
-
#whitespace_char?(ch : Char) : Bool
Checks if a character is a space, tab, or newline.
Constructor Detail
Instance Method Detail
Checks if a character is a valid start of a group/parenthesis.
Checks if a character is a valid first character of an identifier.
Checks if a character is a valid start of a join type operator.
Checks if a character is a valid first character of a number.
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.
Checks if a character is a valid first character of a quoted text.