BenchGen
BenchGen is a tool for generating benchmarks to stress-test a computing system.
Loading...
Searching...
No Matches
lSystem Namespace Reference

The lSystem namespace contains functions to apply L-system rules to sequences of tokens, including matching rules and applying production rules. More...

Functions

std::vector< TokenlSystem (int iterations, const std::vector< ProductionRule > &productionRules, const std::vector< Token > &inputTokens)
 Applies L-system rules to generate a sequence of tokens.
 
int match (std::string match, const std::vector< ProductionRule > &rules)
 Matches a string to a production rule.
 
int findEqualCall (const std::unordered_map< std::vector< Token >, int, TokenVectorHash, TokenVectorEqual > &callMap, const std::vector< Token > &callTokens)
 Finds an existing call ID for a given set of tokens, if one exists.
 
void applyCallIds (std::list< Token > &outputTokens, int &callCounter)
 Applies call IDs to sequences of tokens representing function calls.
 
void applyProductionRules (std::list< Token > &outputTokens, const std::vector< ProductionRule > &productionRules)
 Applies production rules to the output tokens.
 

Detailed Description

The lSystem namespace contains functions to apply L-system rules to sequences of tokens, including matching rules and applying production rules.

Function Documentation

◆ applyCallIds()

void lSystem::applyCallIds ( std::list< Token > & outputTokens,
int & callCounter )

Applies call IDs to sequences of tokens representing function calls.

Processes the output tokens to assign unique call IDs to sequences representing function calls, ensuring that each unique call sequence has a unique ID.

Parameters
outputTokensA list of tokens representing the current state of the output.
callCounterA reference to the counter used for assigning new call IDs.

◆ applyProductionRules()

void lSystem::applyProductionRules ( std::list< Token > & outputTokens,
const std::vector< ProductionRule > & productionRules )

Applies production rules to the output tokens.

Replaces tokens in the output that match a production rule with the corresponding production, modifying the output sequence accordingly.

Parameters
outputTokensA list of tokens representing the current state of the output.
productionRulesThe vector of production rules to apply to the output.

◆ findEqualCall()

int lSystem::findEqualCall ( const std::unordered_map< std::vector< Token >, int, TokenVectorHash, TokenVectorEqual > & callMap,
const std::vector< Token > & callTokens )

Finds an existing call ID for a given set of tokens, if one exists.

Checks if a given sequence of tokens has already been assigned a call ID.

Parameters
callMapA map of token sequences to their corresponding call IDs.
callTokensThe vector of tokens representing the call to check.
Returns
The call ID if found, or -1 if no existing call ID is found.

◆ lSystem()

std::vector< Token > lSystem::lSystem ( int iterations,
const std::vector< ProductionRule > & productionRules,
const std::vector< Token > & inputTokens )

Applies L-system rules to generate a sequence of tokens.

Takes an initial set of tokens, applies the specified production rules for a given number of iterations, and generates a new sequence of tokens based on the rules.

Parameters
iterationsThe number of times the production rules should be applied.
productionRulesThe production rules to apply, represented as a vector of ProductionRule objects.
inputTokensThe initial vector of Tokens to which the rules are applied.
Returns
A vector of Tokens resulting from applying the production rules to the input.

◆ match()

int lSystem::match ( std::string match,
const std::vector< ProductionRule > & rules )

Matches a string to a production rule.

Searches for a match between a given string and the rules in the provided vector.

Parameters
matchThe string to match against the production rules.
rulesThe vector of production rules to search.
Returns
The index of the matching rule, or -1 if no match is found.