fcml  1.2.2
fcml_parser.h
Go to the documentation of this file.
1 /*
2  * FCML - Free Code Manipulation Library.
3  * Copyright (C) 2010-2020 Slawomir Wojtasiak
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
27 #ifndef FCML_PARSER_H_
28 #define FCML_PARSER_H_
29 
30 #include "fcml_lib_export.h"
31 
32 #include "fcml_types.h"
33 #include "fcml_errors.h"
34 #include "fcml_common.h"
35 #include "fcml_dialect.h"
36 #include "fcml_symbols.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
43 #define FCML_PARSER_MAX_INSTRUCTION_LEN 1024
44 
46 typedef struct fcml_st_parser_config {
59  fcml_bool override_labels;
70  // TODO: Support has to be implemented yet.
74 
76 typedef struct fcml_st_parser_context {
97 
99 typedef struct fcml_st_parser_result {
111 
130 LIB_EXPORT fcml_ceh_error LIB_CALL fcml_fn_parse(
131  fcml_st_parser_context *context, const fcml_string instruction,
132  fcml_st_parser_result *result);
133 
147 LIB_EXPORT void LIB_CALL fcml_fn_parser_result_prepare(
148  fcml_st_parser_result *result);
149 
159 LIB_EXPORT void LIB_CALL fcml_fn_parser_result_free(
160  fcml_st_parser_result *result);
161 
162 #ifdef __cplusplus
163 }
164 #endif
165 
166 #endif /* FCML_PARSER_H_ */
fcml_st_instruction * instruction
Parsed instruction as generic instruction model.
Definition: fcml_parser.h:109
fcml_ptr fcml_st_symbol_table
Type for symbol tables.
Definition: fcml_symbols.h:35
struct fcml_st_parser_result fcml_st_parser_result
Reusable result holder.
fcml_bool override_labels
Set to true in order to allow overriding existing labels.
Definition: fcml_parser.h:59
fcml_st_symbol_table symbol_table
Symbol table.
Definition: fcml_parser.h:95
fcml_st_symbol * symbol
Defined symbol if there is any.
Definition: fcml_parser.h:107
fcml_bool enable_error_messages
Enables textual error messages.
Definition: fcml_parser.h:72
Container for all collected errors and warnings.
Definition: fcml_errors.h:180
Definitions of common structures used by FCML components.
struct fcml_st_dialect fcml_st_dialect
Assembler dialect.
Definition: fcml_dialect.h:36
Generic instruction model.
Definition: fcml_common.h:783
Handles Win32 DLL symbols importing/exporting.
Parser configuration.
Definition: fcml_parser.h:46
fcml_st_dialect * dialect
Dialect to be used by parser.
Definition: fcml_parser.h:78
Reusable result holder.
Definition: fcml_parser.h:99
fcml_int64_t fcml_ip
General instruction pointer holder.
Definition: fcml_common.h:96
fcml_bool ignore_undefined_symbols
Set to true in order to ignore all undefined symbols.
Definition: fcml_parser.h:50
LIB_EXPORT void LIB_CALL fcml_fn_parser_result_prepare(fcml_st_parser_result *result)
Prepares reusable result holder for parser.
struct fcml_st_parser_context fcml_st_parser_context
Parser runtime context.
API for symbols handling.
fcml_st_parser_config configuration
Parser configuration.
Definition: fcml_parser.h:80
Represents one named symbol with associated value.
Definition: fcml_symbols.h:42
LIB_EXPORT fcml_ceh_error LIB_CALL fcml_fn_parse(fcml_st_parser_context *context, const fcml_string instruction, fcml_st_parser_result *result)
Parses given instruction into the generic instruction model.
fcml_bool disable_symbols_declaration
Disables symbols support.
Definition: fcml_parser.h:54
Parser runtime context.
Definition: fcml_parser.h:76
fcml_st_ceh_error_container errors
Parsing errors and warnings going here.
Definition: fcml_parser.h:101
Structures and functions related to dialects.
Global error handling related declarations.
LIB_EXPORT void LIB_CALL fcml_fn_parser_result_free(fcml_st_parser_result *result)
Cleans result holder.
fcml_uint16_t fcml_ceh_error
All error codes should be held in variables of this type.
Definition: fcml_errors.h:156
fcml_ip ip
Instruction pointer.
Definition: fcml_parser.h:85
Types declarations.
fcml_bool alloc_symbol_table_if_needed
By default parser ignores all symbol declarations if there is no symbol table provided in the parser ...
Definition: fcml_parser.h:69
struct fcml_st_parser_config fcml_st_parser_config
Parser configuration.