#ifndef V_PARSE_H
#define V_PARSE_H

#ifdef  CONFIG_SCANNER

typedef vhandle_t   scanner_t;

#ifdef  __cplusplus
extern  "C" {
#endif  /* __cplusplus */
    /*
     * Different constructors
     */
    /* Create scanner for in-memory buffer; 'buffer' must be valid while scanning */
    scanner_t V_GLOBAL  tokParseBuffer(char *buffer,u32_t buffer_len,char *delim);
    /* Same as above, buffer_len determined as strlen(buffer) */
    scanner_t V_GLOBAL  tokParseString(char *buffer,char *delim);
    /* File scanner */
    scanner_t V_GLOBAL  tokParseFile(char *filename,char *delim);
    /* Resets position to start, optionally (if args != NULL) 
     * sets new source and delimiters. */
    void        V_GLOBAL    tokRestart(scanner_t tok,
        char *new_buffer,char *new_delim);
    /* Saving/restoring scanner's cursor position */
    vboolean    V_GLOBAL    tokPush(scanner_t tok);
    vboolean    V_GLOBAL    tokPop(scanner_t tok);
    /* Returns current line number (number of passed 0x0A's) */
    u32_t       V_GLOBAL    tokCurrentLine(scanner_t tok);
    /*
     * Returns next token or NULL if no more tokens
     */
    char_p      V_GLOBAL    tokNext(scanner_t tok);
    /*
    TODO
    char_p      V_GLOBAL    tokNextEx(scanner_t tok,vboolean crossline);
    */
    /*
     *  Same as tokNext(), whitespace and quotes handled as usual chars.
     */
    char_p      V_GLOBAL    tokStrict(scanner_t tok);
    /*  Returns next string (i.e. sequence ended with EOL);
     *  EOL itself NOT stored in result.
     */
    char_p      V_GLOBAL    tokString(scanner_t tok);
    /*
     *  Returns last result of tok[Next | Strict | String], or
     *  NULL if:
     *      - was no previous call to mentioned functions;
     *      - no more chars (or something else wrong).
     */
    char_p      V_GLOBAL    tokLast(scanner_t tok);
    /*  Destroys scanner */
    void        V_GLOBAL    tokDestroy(scanner_t tok);
#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* CONFIG_SCANNER */

#endif /* V_PARSE_H */
