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


5.7 Parsing an Assembler Program

QSMM supports parsing an assembler program provided in an input stream, string buffer, or file. The result of this parsing is a memory representation of this assembler program you can inspect, print, or load 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 in a string in_p. The function qsmm_parse_asm_source_stream parses an assembler program with source text read from a stream filep. Both functions store the allocated handle of a parsed program in *prg_p. The arguments rez1 and rez2 are for future use and must be equal to 0.

If msglist is not NULL, the functions add to a message list msglist error, warning, and note messages generated while parsing the source text. If flags has a bit specified by the mask QSMM_PARSE_ASM_PREPROCESS set, the functions first preprocess the source text by the assembler preprocessor. If cwd_p is not NULL, the preprocessor uses cwd_p as the name of a current working directory when resolving ‘include’ directives. If cwd_p is NULL, the preprocessor uses an actual current working directory when resolving ‘include’ directives.

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

QSMM_ERR_INVAL

The argument prg_p is NULL.

QSMM_ERR_PRG

The source program text has at least one error. If msglist is not NULL, the message list msglist contains at least one error message.

QSMM_ERR_ILSEQ

Unable to convert a multibyte string to a wide string or vice versa according to a current locale, including the inability to convert the source program text to a wide string.

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 in a file fln. The function stores the allocated handle of a parsed program in *prg_p. If msglist is not NULL, the function adds to a message list msglist error, warning, and note messages generated while parsing the source text. If flags has a bit specified by the mask QSMM_PARSE_ASM_PREPROCESS set, the function first preprocesses the source text by the assembler preprocessor. The arguments rez1 and rez2 are 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 function can return the following error codes.

QSMM_ERR_INVAL

The argument prg_p is NULL.

QSMM_ERR_LIBC

The operating system reported a file access error. The variable errno holds the error code.

QSMM_ERR_PRG

The source program text has at least one error. If msglist is not NULL, the message list msglist contains at least one error message.

QSMM_ERR_ILSEQ

Unable to convert a multibyte string to a wide string or vice versa according to a current locale, including the inability to convert the source program text to a wide string.

QSMM_ERR_NOMEM

There was not enough memory to perform the operation.

See Creating a Message List, for the description of a function for creating an empty message list for passing it to the functions parsing an assembler program and the description of a function for destroying the message list afterwards. See Printing Messages, for the description of a function for dumping to a stream the message list possibly filled with error, warning, and note messages generated while parsing the assembler program.


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