-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLexicalExpression.cpp
More file actions
46 lines (27 loc) · 831 Bytes
/
Copy pathLexicalExpression.cpp
File metadata and controls
46 lines (27 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "LexicalExpression.h"
#include <regex>
LexicalExpression::LexicalExpression(const char* expression, bool isExpression)
{
if (!isExpression) {
this->expressionString = "(";
this->expressionString.append(expression).append(")");
this->expression = std::regex(this->expressionString);
}
else {
this->expression = std::regex(expression);
}
this->expressionString = expression;
int counter = 0;
for (int i = 0; i < expressionString.length(); i++) if (expressionString[i] != '\\') counter++;
this->expressionLength = counter;
}
bool LexicalExpression::check(const char* text)
{
return std::regex_match(text, this->expression);
}
int LexicalExpression::getExpressionLength() {
return this->expressionLength;
}
std::string LexicalExpression::getExpression() {
return this->expressionString;
}