35#ifndef TCEASM_ASSEMBLER_PARSER_HH
36#define TCEASM_ASSEMBLER_PARSER_HH
38#include <boost/version.hpp>
42#if BOOST_VERSION >= 103800
44#include <boost/spirit/include/classic.hpp>
45#include <boost/spirit/include/classic_push_back_actor.hpp>
46#include <boost/spirit/include/classic_clear_actor.hpp>
47#include <boost/spirit/include/classic_assign_actor.hpp>
48#include <boost/spirit/include/classic_increment_actor.hpp>
49#include <boost/spirit/include/classic_assign_key_actor.hpp>
50#include <boost/spirit/include/classic_insert_at_actor.hpp>
51#include <boost/spirit/include/classic_file_iterator.hpp>
53using namespace boost::spirit::classic;
57#include <boost/spirit.hpp>
58#include <boost/spirit/actor/push_back_actor.hpp>
59#include <boost/spirit/actor/clear_actor.hpp>
60#include <boost/spirit/actor/assign_actor.hpp>
61#include <boost/spirit/actor/increment_actor.hpp>
62#include <boost/spirit/actor/assign_key_actor.hpp>
63#include <boost/spirit/actor/insert_at_actor.hpp>
64#include <boost/spirit/iterator/file_iterator.hpp>
66using namespace boost::spirit;
199 void operator() (
const char*,
const char*)
const;
213 void operator() (
const char*,
const char*)
const;
228 void operator() (
const char*,
const char*)
const;
243 void operator() (
const char*,
const char*)
const;
258 void operator() (
const char*,
const char*)
const;
272 std::string& name,
UValue& value);
274 void operator() (
const char*,
const char*)
const;
290 std::string& name,
UValue& value);
292 void operator() (
const char*,
const char*)
const;
307 void operator() (
const char* start,
const char* end)
const;
349 template <
typename ScannerT>
370 (*(anychar_p -
'\n') >> ch_p(
'\n'))
429 (anychar_p - ch_p(
'\"')) ) >>
433 "String literals are not supported yet!\n").c_str())]
446 name = (alpha_p | chset_p(
"_")) >> *(alnum_p | chset_p(
"_"));
770 ((str_p(
"procedure") >> +
my_space >>
920 rule<ScannerT>
const&
start()
const {
930 bool compile(
const std::string& asmCode)
const;
932 void finalize(
bool littleEndian)
const;
const ParserMove::MoveType LONG_IMM
const ParserMove::MoveType TRANSPORT_MOVE
const ParserMove::MoveType EMPTY_MOVE
const RegisterTerm::TermType INDEX_TERM
scanner< iterator_t > scanner_t
const RegisterTerm::TermType FUNCTION_UNIT_TERM
const ParserMove EMPTY_BEGIN_MOVE(ParserMove::EMPTY, true)
Empty parser move with isBegin flag set.
POP_COMPILER_DIAGS typedef char char_t
const RegisterTerm::TermType BUS_TERM
file_iterator< char_t > iterator_t
#define IGNORE_COMPILER_WARNING(X)
#define POP_COMPILER_DIAGS
const DataLine & dataLine_
DataSectionCreator & creator_
void operator()(const char *, const char *) const
void operator()(const char *, const char *) const
TPEF::ASpaceElement & aSpace_
CodeSectionCreator & creator_
void operator()(const char *, const char *) const
void operator()(const char *, const char *) const
std::vector< InitDataField > payload
bool prev
Previous or next bus register.
UValue width
Number of MAUs initialized by this data line.
std::vector< InitDataField > initData
Init data fields of data line. Uninitilized data line, if empty.
std::vector< std::string > labels
Labels of this data line.
std::string dataSpace
Address space whose MAUs are initialized.
UValue asmLineNumber
Line number where in source code this DA line is found.
bool hasOffset
Is offset defined.
bool isMinus
Is offset minus.
UValue value
Resolved value.
bool hasValue
Is resolved value defined in struct.
std::string label
Name of the label.
UValue offset
Value of offset.
std::string part3
Operation name.
std::string part2
Port name.
std::string part1
Unit name.
bool part3Used
Is operation part of the term used.
std::string part1
Unit name.
std::string part2
Port or operation name.
bool part2Used
Is port name used.
UValue index
Register or operand index.
LiteralOrExpression litOrExpr
Initialisation value.
UValue width
Number of MAUs that are initialized by the init field.
bool isExpression
Does object contain expression or literal.
UValue value
If literal, the literal. Otherwise not used.
bool isSigned
Sign of the value.
Expression expression
If expression the expression, Otherwise not used.
TPEF::ASpaceElement * codeAddressSpace()
CodeSectionCreator & creator_
void operator()(const char *, const char *) const
RegisterTerm regTerm
Guard port or register.
bool isInverted
Is guard inverted.
bool isGuarded
Is guard used.
MoveType
Types of instruction slots.
@ TRANSPORT
Data transport (move).
@ LONG_IMMEDIATE
Encoding of one long immediate slot.
std::vector< Annotation > annotationes
MoveType type
Type of move.
ParserSource source
Source field.
bool isBegin
Tells whether the slot is the first of the instruction.
UValue asmLineNumber
Line number of source code for errors.
ParserGuard guard
Guard field.
RegisterTerm destination
Destination field.
bool isRegister
Is source register or immediate reference.
LiteralOrExpression immTerm
If immediate value, the literal or expression. Otherwise not used.
RegisterTerm regTerm
If register, the register. Otherwise not used.
void operator()(const char *, const char *) const
FUTerm fuTerm
The fu term, if type field is FUNCTION_UNIT. Otherwise not used.
IndexTerm indexTerm
The index term, if type field is INDEX. Otherwise not used.
TermType type
Type of terminal that is represented by this object.
BusTerm busTerm
The bus term, if type field is BUS. Otherwise not used.
void operator()(const char *start, const char *end) const
DataSectionCreator & creator_
void operator()(const char *, const char *) const
rule< ScannerT > codeHeader
rule< ScannerT > dataArea
rule< ScannerT > my_space
rule< ScannerT > instruction
rule< ScannerT > initData
rule< ScannerT > dataLabel
rule< ScannerT > directive
rule< ScannerT > codeLine
rule< ScannerT > codeArea
rule< ScannerT > codeLabel
rule< ScannerT > const & start() const
rule< ScannerT > destination
rule< ScannerT > backslashedChars
rule< ScannerT > emptyInstruction
rule< ScannerT > symExpression
rule< ScannerT > initDataField
rule< ScannerT > uLiteral
rule< ScannerT > transport
rule< ScannerT > annotation
rule< ScannerT > expression
rule< ScannerT > dataLines
rule< ScannerT > literalOrExpression
rule< ScannerT > immediateSpec
rule< ScannerT > dataLine
rule< ScannerT > sLiteral
rule< ScannerT > emptyMove
rule< ScannerT > invertFlag
rule< ScannerT > hexNumber
const AssemblerParser & parent_
rule< ScannerT > binNumber
rule< ScannerT > indexTerm
rule< ScannerT > dataHeader
definition(AssemblerParser const &self)
rule< ScannerT > codeLines
LabelManager labelManager_
Creates symbol and relocation sections.
void finalize(bool littleEndian) const
ParserTemp parserTemp_
Temp-structure containing most recent parsed tokens.
MachineResourceManager resourceManager_
Generates string, resource, null and address space sections.
bool codeLinesOnly() const
TPEF::Binary & bin_
TPEF where to program is compiled.
bool codeLinesOnly_
Controls start symbol of the grammar. False: the default symbol (program) for parsing assembly files....
DataSectionCreator dataSectionCreator_
Creates data sections.
CodeSectionCreator codeSectionCreator_
Creates code section.
bool compile(const std::string &asmCode) const
RegisterTerm regTerm
Last parsed register term (copy of most recent parsed bus, fu or index term).
bool isLastSigned
Should lastNumber be interpret as signed or unsigned value.
std::string directive
Last directive parameter string.
UValue codeLineCount
Line number of currently parsed code line.
DataLine dataLine
Last data line.
Expression expression
Last parsed label reference form: name[(+|-)offset][=literal].
UValue index
Last parsed index.
ParserMove move
Last parsed source, destination and guard.
InitDataField initDataField
Last init data field.
UValue lineNumber
Line number of currently parsed line.
IndexTerm indexTerm
Last parsed rf[.port].index or fu.operation.index reference.
LiteralOrExpression litOrExpr
Last parsed literal or expression.
BusTerm busTerm
Last parsed bus reference.
std::string label
Last label name.
Annotation annotation
Last annotation.
FUTerm fuTerm
Last parsed unit.port[.operation] reference.
UValue lastNumber
Last parsed numeric value.