Skip to content

AddressingModeMatcher

INCLUDE FILE
#include "AddressingModeMatcher.h"

class AddressingModeMatcher

Determines which addressing modes match a given line in the source code.

It does not take into account the constraints of the argument types, only if the syntax matches.

It is implemented via a deterministic finite automaton (DFA) that is built from all notations of all addressing modes.

When matched against a line, it returns all addressing modes that match the line, along with the index of the notation that matched.

DEFINITION
class AddressingModeMatcher;

class MatcherNodeprivate

Represents a node in the matcher DFA.

DEFINITION
class MatcherNode;

method add_notation

Add a notation to the matcher.

This method recursively adds the elements of the notation to the matcher, creating new nodes as necessary.

DEFINITION
void  add_notation ( const AddressingModeMatcherResult & result,
std::vector< AddressingMode::Notation::Element >::const_iterator  current,
std::vector< AddressingMode::Notation::Element >::const_iterator  end,
const std::unordered_map< Symbol, std::unique_ptr< AddressingMode::Argument > > & arguments );
PARAMETERDESCRIPTION
result

The match result associated with the notation.

current

The current element in the notation being processed.

end

The end iterator of the notation's elements.

arguments

The arguments for the addressing mode.

member next

The next node in the matcher DFA for each next node from the source code.

DEFINITION
std::unordered_map< AddressingModeMatcherElement, std::unique_ptr< MatcherNode > >  next;

member results

The set of match results associated with this node in the matcher DFA.

DEFINITION
std::unordered_set< AddressingModeMatcherResult >  results;

method add_notation

Add a notation for an addressing mode to the matcher.

DEFINITION
void  add_notation ( Symbol  addressing_mode,
size_t  notation_index,
const AddressingMode::Notation & notation,
const std::unordered_map< Symbol, std::unique_ptr< AddressingMode::Argument > > & arguments );
PARAMETERDESCRIPTION
addressing_mode

The name of the addressing mode.

notation_index

The index in the addressing mode's notations.

notation

The notation to add.

arguments

The arguments for the addressing mode.

method matchconst

Match a line in the source code against all known addressing modes.

DEFINITION
std::unordered_set< AddressingModeMatcherResult >  match ( const std::vector< std::shared_ptr< Node > > & nodes ) const;
PARAMETERDESCRIPTION
nodes

The nodes representing the line in the source code.

RETURNSDESCRIPTION
std::unordered_set< AddressingModeMatcherResult >

A set of match results for the line.

member startprivate

The start node of the matcher DFA.

DEFINITION
MatcherNode  start;

class MatcherNodeprivate

Represents a node in the matcher DFA.

DEFINITION
class MatcherNode;

method add_notation

Add a notation to the matcher.

This method recursively adds the elements of the notation to the matcher, creating new nodes as necessary.

DEFINITION
void  add_notation ( const AddressingModeMatcherResult & result,
std::vector< AddressingMode::Notation::Element >::const_iterator  current,
std::vector< AddressingMode::Notation::Element >::const_iterator  end,
const std::unordered_map< Symbol, std::unique_ptr< AddressingMode::Argument > > & arguments );
PARAMETERDESCRIPTION
result

The match result associated with the notation.

current

The current element in the notation being processed.

end

The end iterator of the notation's elements.

arguments

The arguments for the addressing mode.

member next

The next node in the matcher DFA for each next node from the source code.

DEFINITION
std::unordered_map< AddressingModeMatcherElement, std::unique_ptr< MatcherNode > >  next;

member results

The set of match results associated with this node in the matcher DFA.

DEFINITION
std::unordered_set< AddressingModeMatcherResult >  results;

class AddressingModeMatcherElement

DEFINITION
class AddressingModeMatcherElement;

enum Type

DEFINITION
enum Type;
VALUEDESCRIPTION
PUNCTUATION
KEYWORD
INTEGER

constructor AddressingModeMatcherElement

DEFINITION
AddressingModeMatcherElement ( );

constructor AddressingModeMatcherElement

DEFINITION
AddressingModeMatcherElement ( Node * node );
PARAMETERDESCRIPTION
node

constructor AddressingModeMatcherElement

DEFINITION
AddressingModeMatcherElement ( Type  type,
Symbol  symbol );
PARAMETERDESCRIPTION
type
symbol

method elements_forstatic

DEFINITION
static std::vector< AddressingModeMatcherElement >  elements_for ( const AddressingMode::Notation::Element & element,
const std::unordered_map< Symbol, std::unique_ptr< AddressingMode::Argument > > & arguments );
PARAMETERDESCRIPTION
element
arguments
RETURNSDESCRIPTION
std::vector< AddressingModeMatcherElement >

method operator==const

DEFINITION
bool  operator== ( const AddressingModeMatcherElement & other ) const;
PARAMETERDESCRIPTION
other
RETURNSDESCRIPTION
bool

member symbol

DEFINITION
Symbol  symbol;

member type

DEFINITION
Type  type;

class AddressingModeMatcherResult

Represents a match for the given line.

DEFINITION
class AddressingModeMatcherResult;

constructor AddressingModeMatcherResult

Initialize a match result with the given addressing mode and notation index.

DEFINITION
AddressingModeMatcherResult ( Symbol  addressing_mode,
size_t  notation_index );
PARAMETERDESCRIPTION
addressing_mode

The addressing mode that matched.

notation_index

The index of the addressing mode's notation that matched.

method operator==const

Check if two match results are equal.

DEFINITION
bool  operator== ( const AddressingModeMatcherResult & other ) const;
PARAMETERDESCRIPTION
other

The other match result to compare with.

RETURNSDESCRIPTION
bool

true if the match results are equal, false otherwise.

member addressing_mode

The addressing mode that matched.

DEFINITION
Symbol  addressing_mode;

member notation_index

The index of the addressing mode's notation that matched.

DEFINITION
size_t  notation_index;

class hash< AddressingModeMatcherElement >

DEFINITION
class hash< AddressingModeMatcherElement >;

method operator()const

DEFINITION
std::size_t  operator() ( AddressingModeMatcherElement const & element ) const;
PARAMETERDESCRIPTION
element
RETURNSDESCRIPTION
std::size_t

class hash< AddressingModeMatcherResult >

DEFINITION
class hash< AddressingModeMatcherResult >;

method operator()const

DEFINITION
std::size_t  operator() ( AddressingModeMatcherResult const & result ) const;
PARAMETERDESCRIPTION
result
RETURNSDESCRIPTION
std::size_t