#[no_mangle]
pub extern "C" fn roup_parse_with_language(
input: *const c_char,
language: i32,
) -> *mut OmpDirective
Expand description
Parse an OpenMP directive with explicit language specification.
§Parameters
input
: Null-terminated string containing the directivelanguage
: Language format (ROUP_LANG_C, ROUP_LANG_FORTRAN_FREE, ROUP_LANG_FORTRAN_FIXED)
§Returns
- Pointer to
OmpDirective
on success NULL
on error:input
is NULLlanguage
is not a valid ROUP_LANG_* constantinput
contains invalid UTF-8- Parse error (invalid OpenMP directive syntax)
§Error Handling
This function returns NULL
for all error conditions without detailed error codes.
There is no way to distinguish between different error types (invalid language,
NULL input, UTF-8 error, or parse failure) from the return value alone.
Callers should:
- Validate
language
parameter before calling (use only ROUP_LANG_* constants) - Ensure
input
is non-NULL and valid UTF-8 - Verify directive syntax is correct
- For debugging, enable logging or use a separate validation layer
For a version with detailed error codes, consider using the Rust API directly.
§Example (Fortran free-form)
OmpDirective* dir = roup_parse_with_language("!$OMP PARALLEL PRIVATE(A)", ROUP_LANG_FORTRAN_FREE);
if (dir) {
// Use directive
roup_directive_free(dir);
} else {
// Handle error: NULL, invalid language, invalid UTF-8, or parse failure
fprintf(stderr, "Failed to parse directive\n");
}