OpenASIP  2.0
Classes | Public Member Functions | Private Attributes | List of all members
AssemblerParser Struct Reference

#include <AssemblerParser.hh>

Inheritance diagram for AssemblerParser:
Inheritance graph
Collaboration diagram for AssemblerParser:
Collaboration graph

Classes

struct  definition
 

Public Member Functions

 AssemblerParser (TPEF::Binary &aBin, const TTAMachine::Machine &aMach, AssemblyParserDiagnostic *parserDiagnostic, bool codeLinesOnly=false)
 AssemblerParser. More...
 
bool compile (const std::string &asmCode) const
 
void finalize (bool littleEndian) const
 
void cleanup ()
 
UValue errorLine ()
 
bool codeLinesOnly () const
 

Private Attributes

TPEF::Binarybin_
 TPEF where to program is compiled. More...
 
MachineResourceManager resourceManager_
 Generates string, resource, null and address space sections. More...
 
DataSectionCreator dataSectionCreator_
 Creates data sections. More...
 
CodeSectionCreator codeSectionCreator_
 Creates code section. More...
 
LabelManager labelManager_
 Creates symbol and relocation sections. More...
 
ParserTemp parserTemp_
 Temp-structure containing most recent parsed tokens. More...
 
bool codeLinesOnly_ = false
 Controls start symbol of the grammar. False: the default symbol (program) for parsing assembly files. True: 'codeLines' symbol suitable for inline assembly parsing. More...
 

Detailed Description

Definition at line 331 of file AssemblerParser.hh.

Constructor & Destructor Documentation

◆ AssemblerParser()

AssemblerParser::AssemblerParser ( TPEF::Binary aBin,
const TTAMachine::Machine aMach,
AssemblyParserDiagnostic parserDiagnostic,
bool  codeLinesOnly = false 
)

AssemblerParser.

Grammar constructor.

Parameters
aBinTPEF where to program is compiled.
aMachMachine which for program is compiled.
parentError message manager of the compiler.
codeLinesOnlyIf true start symbol for the grammar is 'codeLines'. The option is suitable for inline assembly parsing. Default is false.

Constructor.

Parameters
aBinTPEF object where to create program.
aMachMachine which for program is written.
parserDiagnosticAssembler root class for warning handling.

Definition at line 231 of file AssemblerParser.cc.

234  :
235  bin_(aBin),
236  resourceManager_(aBin, aMach, parserDiagnostic),
237  dataSectionCreator_(resourceManager_, parserDiagnostic),
238  codeSectionCreator_(resourceManager_, aMach, parserDiagnostic),
239  labelManager_(aBin, resourceManager_, parserDiagnostic),
241 }

Member Function Documentation

◆ cleanup()

void AssemblerParser::cleanup ( )

Frees all resources allocated by parser.

Definition at line 247 of file AssemblerParser.cc.

247  {
251 }

References DataSectionCreator::cleanup(), CodeSectionCreator::cleanup(), LabelManager::cleanup(), codeSectionCreator_, dataSectionCreator_, and labelManager_.

Referenced by Assembler::compile().

Here is the call graph for this function:

◆ codeLinesOnly()

bool AssemblerParser::codeLinesOnly ( ) const
inline

Definition at line 938 of file AssemblerParser.hh.

938 { return codeLinesOnly_; }

Referenced by AssemblerParser::definition< ScannerT >::start().

◆ compile()

bool AssemblerParser::compile ( const std::string &  asmCode) const

Definition at line 254 of file AssemblerParser.cc.

254  {
255 #if BOOST_VERSION >= 103800
256  return boost::spirit::classic::parse(asmCode.c_str(), *this).full;
257 #else
258  return boost::spirit::parse(asmCode.c_str(), *this).full;
259 #endif
260 }

Referenced by Assembler::compile(), and InlineAsmParser::parse().

◆ errorLine()

UValue AssemblerParser::errorLine ( )

Returns line number where parse error happened in assembler file.

Returns
Line number where parse error happened in assembler file.

Definition at line 268 of file AssemblerParser.cc.

268  {
269  return parserTemp_.lineNumber;
270 }

References ParserTemp::lineNumber, and parserTemp_.

Referenced by Assembler::compile(), and InlineAsmParser::parse().

◆ finalize()

void AssemblerParser::finalize ( bool  littleEndian) const

Finalizes parsed TPEF.

After calling this successfully parser should contain valid tpef.

Definition at line 278 of file AssemblerParser.cc.

278  {
279  bin_.setArch(Binary::FA_TTA_TUT);
280  bin_.setType(Binary::FT_PARALLEL);
281 
282  // these must be called in this order to make sure that all label values
283  // are resolved before they are used
287 }

References bin_, codeSectionCreator_, dataSectionCreator_, DataSectionCreator::finalize(), CodeSectionCreator::finalize(), LabelManager::finalize(), labelManager_, TPEF::Binary::setArch(), and TPEF::Binary::setType().

Referenced by Assembler::compile(), and InlineAsmParser::parse().

Here is the call graph for this function:

Member Data Documentation

◆ bin_

TPEF::Binary& AssemblerParser::bin_
private

TPEF where to program is compiled.

Definition at line 943 of file AssemblerParser.hh.

Referenced by finalize().

◆ codeLinesOnly_

bool AssemblerParser::codeLinesOnly_ = false
private

Controls start symbol of the grammar. False: the default symbol (program) for parsing assembly files. True: 'codeLines' symbol suitable for inline assembly parsing.

Definition at line 960 of file AssemblerParser.hh.

◆ codeSectionCreator_

CodeSectionCreator AssemblerParser::codeSectionCreator_
mutableprivate

Creates code section.

Definition at line 950 of file AssemblerParser.hh.

Referenced by cleanup(), and finalize().

◆ dataSectionCreator_

DataSectionCreator AssemblerParser::dataSectionCreator_
mutableprivate

Creates data sections.

Definition at line 948 of file AssemblerParser.hh.

Referenced by cleanup(), and finalize().

◆ labelManager_

LabelManager AssemblerParser::labelManager_
mutableprivate

Creates symbol and relocation sections.

Definition at line 952 of file AssemblerParser.hh.

Referenced by cleanup(), and finalize().

◆ parserTemp_

ParserTemp AssemblerParser::parserTemp_
mutableprivate

Temp-structure containing most recent parsed tokens.

Definition at line 955 of file AssemblerParser.hh.

Referenced by errorLine().

◆ resourceManager_

MachineResourceManager AssemblerParser::resourceManager_
mutableprivate

Generates string, resource, null and address space sections.

Definition at line 946 of file AssemblerParser.hh.


The documentation for this struct was generated from the following files:
AssemblerParser::labelManager_
LabelManager labelManager_
Creates symbol and relocation sections.
Definition: AssemblerParser.hh:952
TPEF::Binary::setType
void setType(FileType type)
LabelManager::finalize
void finalize()
Definition: LabelManager.cc:301
DataSectionCreator::cleanup
void cleanup()
Definition: DataSectionCreator.cc:156
AssemblerParser::codeLinesOnly
bool codeLinesOnly() const
Definition: AssemblerParser.hh:938
LabelManager::cleanup
void cleanup()
Definition: LabelManager.cc:263
ParserTemp::lineNumber
UValue lineNumber
Line number of currently parsed line.
Definition: AssemblerParser.hh:140
DataSectionCreator::finalize
void finalize(TPEF::Binary &tpef, LabelManager &labels, bool littleEndian)
Definition: DataSectionCreator.cc:190
AssemblerParser::dataSectionCreator_
DataSectionCreator dataSectionCreator_
Creates data sections.
Definition: AssemblerParser.hh:948
AssemblerParser::codeLinesOnly_
bool codeLinesOnly_
Controls start symbol of the grammar. False: the default symbol (program) for parsing assembly files....
Definition: AssemblerParser.hh:960
CodeSectionCreator::finalize
void finalize(TPEF::Binary &tpef, LabelManager &labels)
Definition: CodeSectionCreator.cc:347
AssemblerParser::resourceManager_
MachineResourceManager resourceManager_
Generates string, resource, null and address space sections.
Definition: AssemblerParser.hh:946
AssemblerParser::parserTemp_
ParserTemp parserTemp_
Temp-structure containing most recent parsed tokens.
Definition: AssemblerParser.hh:955
CodeSectionCreator::cleanup
void cleanup()
Definition: CodeSectionCreator.cc:518
AssemblerParser::codeSectionCreator_
CodeSectionCreator codeSectionCreator_
Creates code section.
Definition: AssemblerParser.hh:950
AssemblerParser::bin_
TPEF::Binary & bin_
TPEF where to program is compiled.
Definition: AssemblerParser.hh:943
TPEF::Binary::setArch
void setArch(FileArchitecture arch)