the Qdx namespace contains all the objects in the Qdx module
More...
|
| hash< auto > | count_all_brackets (string text) |
| | Counts all bracket types in a string using proper tokenization.
|
| |
| hash< auto > | count_braces (string text) |
| | Counts open and close braces in a string using proper tokenization.
|
| |
| string | formatParseDiagnostics (soft< int > max_entries, list< auto > diagnostics, string path, string code) |
| | Formats astparser diagnostics for output.
|
| |
|
|
const auto | ADK_Class = ... |
| | Declaration kind constants from astparser (ADK_*)
|
| |
|
const auto | TOK_BLOCK_COMMENT = ... |
| | Block comment (/* ... */)
|
| |
|
const auto | TOK_DOLLAR_HASH = ... |
| | Loop iteration index ($#)
|
| |
|
const auto | TOK_EOF = ... |
| | End of input.
|
| |
|
const auto | TOK_HEREDOC = ... |
| | Heredoc string (<<END...END)
|
| |
|
const auto | TOK_IDENTIFIER = ... |
| | Identifier (variable/function names)
|
| |
|
const auto | TOK_LBRACE = ... |
| | Left brace ({)
|
| |
|
const auto | TOK_LBRACKET = ... |
| | Left bracket ([)
|
| |
|
const auto | TOK_LINE_COMMENT = ... |
| | Line comment (# to end of line)
|
| |
|
const auto | TOK_LPAREN = ... |
| | Left parenthesis (()
|
| |
|
const auto | TOK_NEWLINE = ... |
| | Newline character.
|
| |
|
const auto | TOK_OTHER = ... |
| | Any other single character.
|
| |
|
const auto | TOK_RBRACE = ... |
| | Right brace (})
|
| |
|
const auto | TOK_RBRACKET = ... |
| | Right bracket (])
|
| |
|
const auto | TOK_REGEX = ... |
| | Regex pattern (/pattern/flags)
|
| |
|
const auto | TOK_REGEX_MATCH = ... |
| | Regex match operator (=~)
|
| |
|
const auto | TOK_REGEX_NOT_MATCH = ... |
| | Regex not-match operator (!~)
|
| |
|
const auto | TOK_RPAREN = ... |
| | Right parenthesis ())
|
| |
|
const auto | TOK_STRING_DOUBLE = ... |
| | Double-quoted string literal ("...")
|
| |
|
const auto | TOK_SUBSTITUTION = ... |
| | Regex substitution (s/pattern/replacement/flags)
|
| |
|
const auto | TOK_TRANSLITERATION = ... |
| | Transliteration (tr/chars/replacements/ or y/.../)
|
| |
|
const auto | TOK_WHITESPACE = ... |
| | Whitespace (spaces, tabs)
|
| |
the Qdx namespace contains all the objects in the Qdx module
◆ count_all_brackets()
| hash< auto > Qdx::count_all_brackets |
( |
string |
text | ) |
|
Counts all bracket types in a string using proper tokenization.
This function correctly handles brackets inside strings, comments, and regex patterns, and correctly handles $# (loop iteration index) vs # (line comment start).
- Parameters
-
- Returns
- a hash with counts for braces, parentheses, and brackets
- Example:
hash<auto> counts = count_all_brackets("if (x[$#]) { y; }");
printf("open_braces: %d, close_braces: %d\n", counts.open_braces, counts.close_braces);
printf("open_parens: %d, close_parens: %d\n", counts.open_parens, counts.close_parens);
◆ count_braces()
| hash< auto > Qdx::count_braces |
( |
string |
text | ) |
|
Counts open and close braces in a string using proper tokenization.
This function correctly handles braces inside strings, comments, and regex patterns, and correctly handles $# (loop iteration index) vs # (line comment start).
- Parameters
-
- Returns
- a hash with "open" and "close" keys containing the brace counts
- Example:
hash<auto> counts = count_braces("if (x) { list[$#] }");
printf("open: %d, close: %d\n", counts.open, counts.close);
◆ formatParseDiagnostics()
| string Qdx::formatParseDiagnostics |
( |
soft< int > |
max_entries, |
|
|
list< auto > |
diagnostics, |
|
|
string |
path, |
|
|
string |
code |
|
) |
| |
Formats astparser diagnostics for output.
- Parameters
-
| path | source path used in formatted output |
| code | source contents |
| diagnostics | list of diagnostics from AstParser::getDiagnostics() |
| max_entries | optional max number of diagnostics to format |
- Returns
- formatted diagnostics string for logging
- Example:
AstParser parser();
parser.parseString(code);
*list diagnostics = parser.getDiagnostics();
if (exists(diagnostics)) {
string message = Qdx::formatParseDiagnostics("example.qm", code, diagnostics);
printf("%s", message);
}