BenchGen
BenchGen is a tool for generating benchmarks to stress-test a computing system.
Loading...
Searching...
No Matches
globalStructs.h
Go to the documentation of this file.
1#ifndef GLOBALSTRUCTS_H
2#define GLOBALSTRUCTS_H
3
4#include <iostream>
5#include <tuple>
6#include <vector>
7
8#include "globalIncludes.h"
9
13struct LexerRule {
14 int type; // Type of the lexer rule
15 std::string regex; // Regular expression defining the rule
16};
17
21struct Token {
22 int type; // Type of the token
23 std::string text; // Text content of the token
24
31 bool operator==(const Token& other) const {
32 return std::tie(type, text) == std::tie(other.type, other.text);
33 }
34};
35
49 size_t operator()(const std::vector<Token>& t) const {
50 size_t seed = t.size();
51 for (auto& i : t) {
52 size_t h1 = std::hash<int>{}(i.type);
53 size_t h2 = std::hash<std::string>{}(i.text);
54 size_t seedo = h1 ^ (h2 << 1);
55 seed ^= seedo;
56 }
57 return seed;
58 }
59};
60
75 bool operator()(const std::vector<Token>& t1, const std::vector<Token>& t2) const {
76 return t1 == t2;
77 }
78};
79
84 std::string rule; // The name or identifier of the production rule
85 std::vector<Token> production; // The sequence of Tokens that defines the production
86};
87
88#endif
Represents a lexer rule with a type and a regular expression pattern.
Definition globalStructs.h:13
std::string regex
Definition globalStructs.h:15
int type
Definition globalStructs.h:14
Represents a production rule in a grammar, consisting of a rule name and a sequence of Tokens.
Definition globalStructs.h:83
std::string rule
Definition globalStructs.h:84
std::vector< Token > production
Definition globalStructs.h:85
Equality comparison object for vectors of Tokens.
Definition globalStructs.h:67
bool operator()(const std::vector< Token > &t1, const std::vector< Token > &t2) const
Compares two vectors of Tokens for equality.
Definition globalStructs.h:75
Hash function object for a vector of Tokens.
Definition globalStructs.h:42
size_t operator()(const std::vector< Token > &t) const
Computes the hash value for a vector of Tokens.
Definition globalStructs.h:49
Represents a token with a type and text content.
Definition globalStructs.h:21
bool operator==(const Token &other) const
Equality operator to compare two Token objects.
Definition globalStructs.h:31
int type
Definition globalStructs.h:22
std::string text
Definition globalStructs.h:23