Next: , Previous: , Up: Assembler Programs   [Contents][Index]


5.7 Parsing an Assembler Program

The QSMM framework supports parsing an assembler program provided in a string buffer, in a file, or which should be read from a stream. The program is converted to a memory representation that can be inspected, printed, or loaded into a node.

Function: int qsmm_parse_asm_source_buf (const char *in_p, const char *cwd_p, unsigned int flags, void *rez1, void *rez2, qsmm_msglist_t msglist, qsmm_prg_t *prg_p)
Function: int qsmm_parse_asm_source_stream (FILE *filep, const char *cwd_p, unsigned int flags, void *rez1, void *rez2, qsmm_msglist_t msglist, qsmm_prg_t *prg_p)

The function qsmm_parse_asm_source_buf parses an assembler program with source text provided by argument in_p in the form of a null-terminated string. The function qsmm_parse_asm_source_stream parses an assembler program with source text read from stream filep. Both functions store the allocated handle of a memory representation of the program in *prg_p.

If msglist is not 0, then error, warning, and note messages generated during parsing will be written to message list msglist. If flags has a bit specified by mask QSMM_PARSE_ASM_PREPROCESS set, then the source program text will be first preprocessed by the assembler preprocessor. If cwd_p is not NULL, then cwd_p will be used for the name of current working directory by the assembler preprocessor when resolving ‘include’ directives. If cwd_p is NULL, then the actual current working directory will be used when resolving ‘include’ directives. Arguments rez1 and rez2 are reserved for future use and must be equal to 0.

The functions return a non-negative value on success or a negative error code on failure. Currently, the following error codes can be returned.

QSMM_ERR_INVAL

Argument prg_p is NULL.

QSMM_ERR_PRG

At least one error was encountered in the source program text.

QSMM_ERR_ILSEQ

The source text of the assembler program cannot be converted to a wide string according to the current locale.

QSMM_ERR_NOMEM

There was not enough memory to perform the operation.

Function: int qsmm_parse_asm_source_file (const char *fln, unsigned int flags, void *rez1, void *rez2, qsmm_msglist_t msglist, qsmm_prg_t *prg_p)

This function parses an assembler program with source text provided in a file named fln. The function stores the allocated handle of a memory representation of the program in *prg_p. If msglist is not NULL, then error, warning, and note messages generated during parsing will be written to message list msglist. If flags has a bit specified by mask QSMM_PARSE_ASM_PREPROCESS set, then the source program text will be first preprocessed by the assembler preprocessor. Arguments rez1 and rez2 are reserved for future use and must be equal to 0.

The function returns a non-negative value on success or a negative error code on failure. Currently, the following error codes can be returned.

QSMM_ERR_INVAL

Argument prg_p is NULL.

QSMM_ERR_LIBC

When accessing file fln, the operating system has returned an error. The variable errno holds the error code.

QSMM_ERR_PRG

At least one error was encountered in the source program text.

QSMM_ERR_ILSEQ

The source text of the assembler program cannot be converted to a wide string according to the current locale.

QSMM_ERR_NOMEM

There was not enough memory to perform the operation.

See Creating a Message List, for a description of functions using which an empty message list can be created to pass it to the functions qsmm_parse_asm_source_* to possibly fill it with messages and finally destroyed. See Printing Messages, for a description of a function using which that message list can be dumped to a stream.


Next: , Previous: , Up: Assembler Programs   [Contents][Index]