Qore Qdx Module Reference 1.1.3
Loading...
Searching...
No Matches
Qdx Namespace Reference

the Qdx namespace contains all the objects in the Qdx module More...

Classes

class  DocumentTableHelper
 converts specially-formatted text in the input to HTML tables More...
 
class  DocumentTableInputStreamLineIterator
 a line-based input stream iterator that converts specially-formatted input line text to HTML table output More...
 
class  QorePostProcessingInputStreamLineIterator
 a line-based input stream iterator for post-processing HTML and JS files created for Qore documentation More...
 
class  QorePostProcessingTexInputStreamLineIterator
 a line-based input stream iterator for post-processing HTML and JS files created for Qore documentation More...
 
class  QoreTokenizer
 Tokenizer for Qore source code. More...
 
hashdecl  TokenInfo
 

Functions

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.
 

Variables

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)
 

Detailed Description

the Qdx namespace contains all the objects in the Qdx module

Function Documentation

◆ 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
textthe text to analyze
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
textthe text to analyze
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); # open: 1, close: 1

◆ formatParseDiagnostics()

string Qdx::formatParseDiagnostics ( soft< int >  max_entries,
list< auto >  diagnostics,
string  path,
string  code 
)

Formats astparser diagnostics for output.

Parameters
pathsource path used in formatted output
codesource contents
diagnosticslist of diagnostics from AstParser::getDiagnostics()
max_entriesoptional 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);
}