Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
WAST::StaticData Struct Reference
Collaboration diagram for WAST::StaticData:

Public Member Functions

 StaticData ()
 

Public Attributes

NFA::Machine nfaMachine
 

Detailed Description

Definition at line 27 of file Lexer.cpp.

Constructor & Destructor Documentation

◆ StaticData()

WAST::StaticData::StaticData ( )

Definition at line 65 of file Lexer.cpp.

66 {
67 static const std::pair<TokenType,const char*> regexpTokenPairs[] =
68 {
69 {t_decimalInt,"[+\\-]?\\d+(_\\d+)*"},
70 {t_decimalFloat,"[+\\-]?\\d+(_\\d+)*\\.(\\d+(_\\d+)*)*([eE][+\\-]?\\d+(_\\d+)*)?"},
71 {t_decimalFloat,"[+\\-]?\\d+(_\\d+)*[eE][+\\-]?\\d+(_\\d+)*"},
72
73 {t_hexInt,"[+\\-]?0[xX][\\da-fA-F]+(_[\\da-fA-F]+)*"},
74 {t_hexFloat,"[+\\-]?0[xX][\\da-fA-F]+(_[\\da-fA-F]+)*\\.([\\da-fA-F]+(_[\\da-fA-F]+)*)*([pP][+\\-]?\\d+(_\\d+)*)?"},
75 {t_hexFloat,"[+\\-]?0[xX][\\da-fA-F]+(_[\\da-fA-F]+)*[pP][+\\-]?\\d+(_\\d+)*"},
76
77 {t_floatNaN,"[+\\-]?nan(:0[xX][\\da-fA-F]+(_[\\da-fA-F]+)*)?"},
78 {t_floatInf,"[+\\-]?inf"},
79
80 {t_string,"\"([^\"\n\\\\]*(\\\\([^0-9a-fA-Fu]|[0-9a-fA-F][0-9a-fA-F]|u\\{[0-9a-fA-F]+})))*\""},
81
82 {t_name,"\\$[a-zA-Z0-9\'_+*/~=<>!?@#$%&|:`.\\-\\^\\\\]+"},
83 };
84
85 static const std::tuple<TokenType,const char*,bool> literalTokenTuples[] =
86 {
87 std::make_tuple(t_leftParenthesis,"(",true),
88 std::make_tuple(t_rightParenthesis,")",true),
89 std::make_tuple(t_equals,"=",true),
90
91 #define VISIT_TOKEN(name,description) std::make_tuple(t_##name,#name,false),
93 #undef VISIT_TOKEN
94
95 #undef VISIT_OPERATOR_TOKEN
96 #define VISIT_OPERATOR_TOKEN(_,name,nameString,...) std::make_tuple(t_##name,nameString,false),
98 #undef VISIT_OPERATOR_TOKEN
99 };
100
101 Timing::Timer timer;
102
103 NFA::Builder* nfaBuilder = NFA::createBuilder();
104
105 for(auto regexpTokenPair : regexpTokenPairs)
106 {
107 NFA::StateIndex finalState = NFA::maximumTerminalStateIndex - (NFA::StateIndex)regexpTokenPair.first;
108 finalState = createTokenSeparatorPeekState(nfaBuilder,finalState);
109 Regexp::addToNFA(regexpTokenPair.second,nfaBuilder,0,finalState);
110 }
111
112 for(auto literalTokenTuple : literalTokenTuples)
113 {
114 const TokenType tokenType = std::get<0>(literalTokenTuple);
115 const char* literalString = std::get<1>(literalTokenTuple);
116 const bool isTokenSeparator = std::get<2>(literalTokenTuple);
117
119 if(!isTokenSeparator) { finalState = createTokenSeparatorPeekState(nfaBuilder,finalState); }
120
121 addLiteralToNFA(literalString,nfaBuilder,0,finalState);
122 }
123
124 #ifndef _DEBUG
125 if(false)
126 #endif
127 {
128 std::ofstream debugGraphStream("nfaGraph.dot");
129 debugGraphStream << NFA::dumpNFAGraphViz(nfaBuilder).c_str();
130 debugGraphStream.close();
131 }
132
133 nfaMachine = NFA::Machine(nfaBuilder);
134
135 #ifndef _DEBUG
136 if(false)
137 #endif
138 {
139 std::ofstream debugGraphStream("dfaGraph.dot");
140 debugGraphStream << nfaMachine.dumpDFAGraphViz().c_str();
141 debugGraphStream.close();
142 }
143
144 Timing::logTimer("built lexer tables",timer);
145 }
#define VISIT_OPERATOR_TOKEN(_, name, nameString,...)
#define ENUM_LITERAL_TOKENS()
Definition Lexer.h:11
#define ENUM_OPERATORS(visitOp)
Definition Operators.h:571
std::string dumpNFAGraphViz(const Builder *builder)
Definition NFA.cpp:467
@ maximumTerminalStateIndex
Definition NFA.h:20
Builder * createBuilder()
Definition NFA.cpp:40
I16 StateIndex
Definition NFA.h:14
void addToNFA(const char *regexpString, NFA::Builder *nfaBuilder, NFA::StateIndex initialState, NFA::StateIndex finalState)
Definition Regexp.cpp:335
void logTimer(const char *context, Timer &timer)
Definition Timing.h:28
TokenType
Definition Lexer.h:88
std::string dumpDFAGraphViz() const
Definition NFA.cpp:510
NFA::Machine nfaMachine
Definition Lexer.cpp:29
Here is the call graph for this function:

Member Data Documentation

◆ nfaMachine

NFA::Machine WAST::StaticData::nfaMachine

Definition at line 29 of file Lexer.cpp.


The documentation for this struct was generated from the following file: