27#ifndef FCML_PARSER_HPP_
28#define FCML_PARSER_HPP_
63 _throwExceptionOnError(true),
64 _ignoreUndefinedSymbols(false),
65 _disableSymbolsDeclaration(true),
66 _overrideLabels(false),
67 _allocSymbolTableIfNeeded(false),
68 _enableErrorMessages(true) {
73 return _allocSymbolTableIfNeeded;
78 _allocSymbolTableIfNeeded = allocSymbolTableIfNeeded;
83 return _disableSymbolsDeclaration;
88 _disableSymbolsDeclaration = disableSymbolsDeclaration;
93 return _enableErrorMessages;
98 _enableErrorMessages = enableErrorMessages;
103 return _ignoreUndefinedSymbols;
108 _ignoreUndefinedSymbols = ignoreUndefinedSymbols;
113 return _overrideLabels;
118 _overrideLabels = overrideLabels;
127 return _throwExceptionOnError;
138 _throwExceptionOnError = throwExceptionOnError;
142 bool _throwExceptionOnError;
143 bool _ignoreUndefinedSymbols;
144 bool _disableSymbolsDeclaration;
145 bool _overrideLabels;
146 bool _allocSymbolTableIfNeeded;
147 bool _enableErrorMessages;
163 _ip(ip), _symbolTable(NULL) {
175 _ip(ip), _symbolTable(symbolTable) {
258 _symbolTable = symbolTable;
320 _symbol.setNotNull(
false);
321 _symbol.setValue(
Symbol());
343 _instruction = instruction;
427 parserResult.
clean();
431 instruction.c_str(), &parser_result);
434 ErrorTypeConverter::convert(parser_result.
errors, errorContainer);
447 FCML_TEXT(
"Parsing failed")), errorContainer,
454 TypeConverter::convert(*(parser_result.
instruction),
461 parser_result.
symbol->value) :
468 }
catch (std::exception &exc) {
Inherit from this class in order to get access to the native FCML dialect structure.
Definition fcml_dialect.hpp:98
fcml_st_dialect * extractDialect(const Dialect &dialect) const
Extracts the native FCML dialect from the dialect object.
Definition fcml_dialect.hpp:122
An abstract dialect.
Definition fcml_dialect.hpp:41
Base class for all exceptions that are aware of ErrorContainer.
Definition fcml_errors.hpp:347
Wraps multiple errors into one component.
Definition fcml_errors.hpp:148
fcml_cstring prepareErrorMessage(const fcml_cstring &message) const
Prepares an error message basing on the first error in the container.
Definition fcml_errors.hpp:283
void clean()
Cleans all errors and warnings.
Definition fcml_errors.hpp:296
Describes an instruction.
Definition fcml_common.hpp:7185
Wrapper for nullable value types.
Definition fcml_common.hpp:120
Parser configuration.
Definition fcml_parser.hpp:55
bool isAllocSymbolTableIfNeeded() const
Definition fcml_parser.hpp:72
void setAllocSymbolTableIfNeeded(bool allocSymbolTableIfNeeded)
Definition fcml_parser.hpp:77
bool isIgnoreUndefinedSymbols() const
Definition fcml_parser.hpp:102
bool isThrowExceptionOnError() const
Gets true if exception should be thrown in case of error.
Definition fcml_parser.hpp:126
bool isOverrideLabels() const
Definition fcml_parser.hpp:112
void setIgnoreUndefinedSymbols(bool ignoreUndefinedSymbols)
Definition fcml_parser.hpp:107
void setThrowExceptionOnError(bool throwExceptionOnError)
Sets exception on error flag.
Definition fcml_parser.hpp:137
bool isDisableSymbolsDeclaration() const
Definition fcml_parser.hpp:82
void setOverrideLabels(bool overrideLabels)
Definition fcml_parser.hpp:117
void setEnableErrorMessages(bool enableErrorMessages)
Definition fcml_parser.hpp:97
ParserConfig()
Default constructor.
Definition fcml_parser.hpp:62
bool isEnableErrorMessages() const
Definition fcml_parser.hpp:92
void setDisableSymbolsDeclaration(bool disableSymbolsDeclaration)
Definition fcml_parser.hpp:87
Parser context.
Definition fcml_parser.hpp:153
void incrementIP(fcml_ip ip)
Increments instruction pointer by given number of bytes.
Definition fcml_parser.hpp:227
fcml_ip getIp() const
Gets the instruction pointer.
Definition fcml_parser.hpp:206
ParserContext(fcml_ip ip=0)
Creates a parser context instance for optional instruction pointer.
Definition fcml_parser.hpp:162
void setSymbolTable(SymbolTable *symbolTable)
Sets a symbol table for the instruction.
Definition fcml_parser.hpp:257
ParserContext(SymbolTable *symbolTable, fcml_ip ip=0)
Creates a parser context for given symbol table and optional instruction pointer.
Definition fcml_parser.hpp:174
const ParserConfig & getConfig() const
Gets the parser configuration associated with the context.
Definition fcml_parser.hpp:186
ParserConfig & getConfig()
Gets the parser configuration associated with the context.
Definition fcml_parser.hpp:196
SymbolTable * getSymbolTable()
Gets the symbol table associated with the context.
Definition fcml_parser.hpp:247
void setIp(fcml_ip ip)
Gets a new instruction pointer.
Definition fcml_parser.hpp:216
const SymbolTable * getSymbolTable() const
Gets the symbol table associated with the context.
Definition fcml_parser.hpp:237
Parser result.
Definition fcml_parser.hpp:275
void setInstruction(const Instruction &instruction)
Sets an instruction for the container.
Definition fcml_parser.hpp:342
void setErrors(const ErrorContainer &errors)
Sets error container for the context.
Definition fcml_parser.hpp:333
const Nullable< Symbol > & getSymbol() const
Gets declared symbol is there is any.
Definition fcml_parser.hpp:310
const ErrorContainer & getErrors() const
Gets errors container with parsing errors.
Definition fcml_parser.hpp:291
ParserResult()
Creates an empty parser result.
Definition fcml_parser.hpp:282
const Instruction & getInstruction() const
Gets the parsed instruction.
Definition fcml_parser.hpp:301
void clean()
Cleans the parser result.
Definition fcml_parser.hpp:318
void setSymbol(const Nullable< Symbol > &symbol)
Sets symbol.
Definition fcml_parser.hpp:351
Converts objects to their structures counterparts.
Definition fcml_parser.hpp:371
Parser wrapper.
Definition fcml_parser.hpp:387
fcml_ceh_error parse(ParserContext &ctx, const fcml_cstring &instruction, ParserResult &parserResult)
Parses instruction given in the parameters.
Definition fcml_parser.hpp:410
Parser(const Dialect &dialect)
Creates a parser instance for the given dialect.
Definition fcml_parser.hpp:396
Something failed while parsing.
Definition fcml_parser.hpp:43
Derive from this class if you really need access to the native symbol table.
Definition fcml_symbols.hpp:251
fcml_st_symbol_table & extractSymbolTable(SymbolTable &symbolTable)
Extracts the native symbol table for the given symbol table wrapper.
Definition fcml_symbols.hpp:259
Definition fcml_symbols.hpp:143
Represents one named symbol with associated value.
Definition fcml_symbols.hpp:41
fcml_int64_t fcml_ip
General instruction pointer holder.
Definition fcml_common.h:96
C++ wrappers common classes.
std::basic_string< fcml_char > fcml_cstring
By using this type definition here, it will be definitely much easier to support UNICODE in future re...
Definition fcml_common.hpp:53
C++ wrapper for the base dialect.
fcml_uint16_t fcml_ceh_error
All error codes should be held in variables of this type.
Definition fcml_errors.h:156
C++ wrapper for the FCML errors handling.
Structures and functions declarations related to FCML parsers.
LIB_EXPORT void LIB_CALL fcml_fn_parser_result_free(fcml_st_parser_result *result)
Cleans result holder.
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.
LIB_EXPORT void LIB_CALL fcml_fn_parser_result_prepare(fcml_st_parser_result *result)
Prepares reusable result holder for parser.
C++ API for symbols handling.
#define FCML_TEXT(x)
Used to code literal strings.
Definition fcml_types.h:61
@ FCML_CEH_GEC_INTERNAL_ERROR
An internal error occurred.
Definition fcml_errors.h:49
@ FCML_CEH_GEC_NO_ERROR
Operation succeed.
Definition fcml_errors.h:42
Parser configuration.
Definition fcml_parser.h:46
fcml_bool override_labels
Set to true in order to allow overriding existing labels.
Definition fcml_parser.h:59
fcml_bool ignore_undefined_symbols
Set to true in order to ignore all undefined symbols.
Definition fcml_parser.h:50
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
fcml_bool enable_error_messages
Enables textual error messages.
Definition fcml_parser.h:72
fcml_bool disable_symbols_declaration
Disables symbols support.
Definition fcml_parser.h:54
Parser runtime context.
Definition fcml_parser.h:76
fcml_st_dialect * dialect
Dialect to be used by parser.
Definition fcml_parser.h:78
fcml_st_symbol_table symbol_table
Symbol table.
Definition fcml_parser.h:95
fcml_ip ip
Instruction pointer.
Definition fcml_parser.h:85
fcml_st_parser_config configuration
Parser configuration.
Definition fcml_parser.h:80
Reusable result holder.
Definition fcml_parser.h:99
fcml_st_symbol * symbol
Defined symbol if there is any.
Definition fcml_parser.h:107
fcml_st_ceh_error_container errors
Parsing errors and warnings going here.
Definition fcml_parser.h:101
fcml_st_instruction * instruction
Parsed instruction as generic instruction model.
Definition fcml_parser.h:109