Token classification and representation for expression parsing in fpx.
This module provides the lightweight but robust token infrastructure used by the fpx preprocessor when evaluating constant expressions in #if / #elif directives.
It defines:
These types are used internally by evaluate_expression() (from fpx_token) to parse and compute #if DEBUG > 1 && defined(USE_MPI)-style conditions.
| Enumerator | Value | Meaning |
|---|---|---|
| unknown | -1 | Invalid / unrecognized token |
| number | 0 | Integer or floating-point literal |
Data Types | |
| type | token |
| Represents a single token in a parsed expression. Holds the string value of the token and its classified type. More... | |
| integer, parameter, public tokens_enum = kind(unknown) |
| subroutine, public tokenize | ( | character(*), intent(in) | expr, |
| type(token), dimension(:), intent(out), allocatable | tokens, | ||
| integer, intent(out) | ntokens ) |
Tokenizes a preprocessor expression into an array of token structures. Handles whitespace, multi-character operators (&&, ||, ==, etc.), the defined operator (with or without parentheses), numbers in various bases, identifiers, and parentheses.
| [in] | expr | Expression string to tokenize |
| [out] | tokens | Allocated array receiving the tokens |
| [out] | ntokens | Number of tokens produced |
Remarks