VirtualBox

Changeset 108280 in vbox for trunk/include


Ignore:
Timestamp:
Feb 19, 2025 9:28:41 AM (2 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167622
Message:

Runtime/RTScriptLex*: Implement support for optionally returning parsed comments (single and multi line) as tokens when enabled in the lexer config, bugref:10321

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/script.h

    r108049 r108280  
    9898    /** Some punctuator. */
    9999    RTSCRIPTLEXTOKTYPE_PUNCTUATOR,
     100    /** A single line comment. */
     101    RTSCRIPTLEXTOKTYPE_COMMENT_SINGLE_LINE,
     102    /** A multi line comment. */
     103    RTSCRIPTLEXTOKTYPE_COMMENT_MULTI_LINE,
    100104    /** Special error token, conveying an error message from the lexer. */
    101105    RTSCRIPTLEXTOKTYPE_ERROR,
     
    212216            PCRTSCRIPTLEXTOKMATCH pPunctuator;
    213217        } Punctuator;
     218        /** Comment */
     219        struct
     220        {
     221            /** Pointer to the start of the comment (including the symbols starting the comment). */
     222            const char            *pszComment;
     223            /** Number of characters of the comment, including the null terminator. */
     224            size_t                cchComment;
     225        } Comment;
    214226        /** Error. */
    215227        struct
     
    316328 * as the lexer will convert everything to uppercase internally. */
    317329#define RTSCRIPT_LEX_CFG_F_CASE_INSENSITIVE_UPPER RT_BIT(1)
     330/** Comments are not skipped but passed back as tokens. */
     331#define RTSCRIPT_LEX_CFG_F_COMMENTS_AS_TOKENS     RT_BIT(2)
    318332
    319333
     
    369383 *                                 If not NULL the string cache must be freed by the caller when not used
    370384 *                                 anymore.
     385 * @param   phStrCacheComments     Where to store the pointer to the string cache containing all
     386 *                                 comments on success when RTSCRIPT_LEX_CFG_F_COMMENTS_AS_TOKENS
     387 *                                 is given, optional.
     388 *                                 If not NULL the string cache must be freed by the caller when not used
     389 *                                 anymore.
    371390 * @param   pCfg                   The lexer config to use for identifying the different tokens.
    372391 */
     
    374393                                        PFNRTSCRIPTLEXDTOR pfnDtor, void *pvUser,
    375394                                        size_t cchBuf, PRTSTRCACHE phStrCacheId, PRTSTRCACHE phStrCacheStringLit,
    376                                         PCRTSCRIPTLEXCFG pCfg);
     395                                        PRTSTRCACHE phStrCacheComments, PCRTSCRIPTLEXCFG pCfg);
    377396
    378397
     
    391410 *                                 If not NULL the string cache must be freed by the caller when not used
    392411 *                                 anymore.
     412 * @param   phStrCacheComments     Where to store the pointer to the string cache containing all
     413 *                                 comments on success when RTSCRIPT_LEX_CFG_F_COMMENTS_AS_TOKENS
     414 *                                 is given, optional.
     415 *                                 If not NULL the string cache must be freed by the caller when not used
     416 *                                 anymore.
    393417 * @param   pCfg                   The lexer config to use for identifying the different tokens.
    394418 */
    395419RTDECL(int) RTScriptLexCreateFromString(PRTSCRIPTLEX phScriptLex, const char *pszSrc, PRTSTRCACHE phStrCacheId,
    396                                         PRTSTRCACHE phStrCacheStringLit, PCRTSCRIPTLEXCFG pCfg);
     420                                        PRTSTRCACHE phStrCacheStringLit, PRTSTRCACHE phStrCacheComments,
     421                                        PCRTSCRIPTLEXCFG pCfg);
    397422
    398423
     
    411436 *                                 If not NULL the string cache must be freed by the caller when not used
    412437 *                                 anymore.
     438 * @param   phStrCacheComments     Where to store the pointer to the string cache containing all
     439 *                                 comments on success when RTSCRIPT_LEX_CFG_F_COMMENTS_AS_TOKENS
     440 *                                 is given, optional.
     441 *                                 If not NULL the string cache must be freed by the caller when not used
     442 *                                 anymore.
    413443 * @param   pCfg                   The lexer config to use for identifying the different tokens.
    414444 */
    415445RTDECL(int) RTScriptLexCreateFromFile(PRTSCRIPTLEX phScriptLex, const char *pszFilename, PRTSTRCACHE phStrCacheId,
    416                                       PRTSTRCACHE phStrCacheStringLit, PCRTSCRIPTLEXCFG pCfg);
     446                                      PRTSTRCACHE phStrCacheStringLit, PRTSTRCACHE phStrCacheComments,
     447                                      PCRTSCRIPTLEXCFG pCfg);
    417448
    418449
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette