39 lines
853 B
C
39 lines
853 B
C
#ifndef LEXER_H
|
|
#define LEXER_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
/* @return: char*, the next token
|
|
*
|
|
*/
|
|
char *get_token(void);
|
|
|
|
/*
|
|
* @warning: NOT IMPLEMENTED.
|
|
*
|
|
* @note: maybe usefull for subshells.
|
|
*/
|
|
|
|
char *get_token_str(void);
|
|
|
|
/*
|
|
* @brief: return a newly allocated token.
|
|
* This token contains [size] chars, starting from [begin].
|
|
*
|
|
* @return: NULL on error, null-terminated char* otherwise.
|
|
*
|
|
*/
|
|
char *new_token(char *begin, ssize_t size);
|
|
|
|
/*
|
|
* @brief: checks if the stream used for the last token creation is empty.
|
|
* If it is, it calls stream_read() from IO_backend,
|
|
* and sets [remaing_chars].
|
|
* If not, it starts from the end of the last token.
|
|
* Also trims left blanks before returning.
|
|
*
|
|
* @return: char* stream from which we tokenise.
|
|
*/
|
|
char *stream_init(void);
|
|
|
|
#endif /* ! LEXER_H */
|