AddressingModeMatcher
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.
class MatcherNodeprivate
Represents a node in the matcher DFA.
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.
| 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 | ); |
| PARAMETER | DESCRIPTION |
|---|---|
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.
member results
The set of match results associated with this node in the matcher DFA.
method add_notation
Add a notation for an addressing mode to the matcher.
| 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 | ); |
| PARAMETER | DESCRIPTION |
|---|---|
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.
| std::unordered_set< AddressingModeMatcherResult > match | ( | const std::vector< std::shared_ptr< Node > > & nodes | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
nodes |
The nodes representing the line in the source code. |
| RETURNS | DESCRIPTION |
|---|---|
std::unordered_set< AddressingModeMatcherResult > |
A set of match results for the line. |
member startprivate
The start node of the matcher DFA.
class MatcherNodeprivate
Represents a node in the matcher DFA.
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.
| 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 | ); |
| PARAMETER | DESCRIPTION |
|---|---|
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.
member results
The set of match results associated with this node in the matcher DFA.
class AddressingModeMatcherElement
enum Type
| VALUE | DESCRIPTION |
|---|---|
PUNCTUATION |
|
KEYWORD |
|
INTEGER |
constructor AddressingModeMatcherElement
| AddressingModeMatcherElement | ( | ); |
constructor AddressingModeMatcherElement
| AddressingModeMatcherElement | ( | Node * node | ); |
| PARAMETER | DESCRIPTION |
|---|---|
node |
constructor AddressingModeMatcherElement
| AddressingModeMatcherElement | ( | Type type, | |
| Symbol symbol | ); |
| PARAMETER | DESCRIPTION |
|---|---|
type |
|
symbol |
method elements_forstatic
| static std::vector< AddressingModeMatcherElement > elements_for | ( | const AddressingMode::Notation::Element & element, | |
| const std::unordered_map< Symbol, std::unique_ptr< AddressingMode::Argument > > & arguments | ); |
| PARAMETER | DESCRIPTION |
|---|---|
element |
|
arguments |
| RETURNS | DESCRIPTION |
|---|---|
std::vector< AddressingModeMatcherElement > |
method operator==const
| bool operator== | ( | const AddressingModeMatcherElement & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
| RETURNS | DESCRIPTION |
|---|---|
bool |
member symbol
member type
class AddressingModeMatcherResult
Represents a match for the given line.
constructor AddressingModeMatcherResult
Initialize a match result with the given addressing mode and notation index.
| AddressingModeMatcherResult | ( | Symbol addressing_mode, | |
| size_t notation_index | ); |
| PARAMETER | DESCRIPTION |
|---|---|
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.
| bool operator== | ( | const AddressingModeMatcherResult & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The other match result to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
member addressing_mode
The addressing mode that matched.
member notation_index
The index of the addressing mode's notation that matched.
class hash< AddressingModeMatcherElement >
method operator()const
| std::size_t operator() | ( | AddressingModeMatcherElement const & element | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
element |
| RETURNS | DESCRIPTION |
|---|---|
std::size_t |
class hash< AddressingModeMatcherResult >
method operator()const
| std::size_t operator() | ( | AddressingModeMatcherResult const & result | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
result |
| RETURNS | DESCRIPTION |
|---|---|
std::size_t |