VapourSynth-llvmexpr
Loading...
Searching...
No Matches
infix2postfix::preprocessor::Expander Class Reference

Public Member Functions

 Expander (const MacroTable &macros, int recursion_depth=0)
std::vector< Tokenexpand (const std::vector< Token > &input)
std::vector< MacroExpansiongetExpansions () const

Detailed Description

Definition at line 1136 of file Preprocessor.cpp.

Constructor & Destructor Documentation

◆ Expander()

infix2postfix::preprocessor::Expander::Expander ( const MacroTable & macros,
int recursion_depth = 0 )
inline

Definition at line 1138 of file Preprocessor.cpp.

1139 : macros(macros), recursion_depth(recursion_depth) {}

Member Function Documentation

◆ expand()

std::vector< Token > infix2postfix::preprocessor::Expander::expand ( const std::vector< Token > & input)
inline

Definition at line 1141 of file Preprocessor.cpp.

1141 {
1142 TokenStream stream(input);
1143 std::vector<Token> result;
1144
1145 while (!stream.is_eof()) {
1146 const auto tok = stream.peek();
1147
1148 if (tok.type == TokenType::Identifier) {
1149 if (tok.text == "defined") {
1150 handleDefinedOperator(stream, result);
1151 continue;
1152 }
1153
1154 if (tok.text == "consteval" || tok.text == "is_consteval") {
1155 handleConstevalIntrinsics(stream, result, tok);
1156 continue;
1157 }
1158
1159 if (tok.text == "static_assert") {
1160 handleStaticAssertIntrinsic(stream, result, tok);
1161 continue;
1162 }
1163
1164 const Macro* macro = macros.find(tok.text);
1165 if (macro == nullptr) {
1166 result.push_back(stream.consume());
1167 continue;
1168 }
1169
1170 Token macro_token = stream.consume();
1171
1172 if (macro->is_function_like) {
1173 expandFunctionLikeMacro(stream, result, macro_token,
1174 *macro);
1175 } else {
1176 expandObjectLikeMacro(stream, result, macro_token, *macro);
1177 }
1178 } else {
1179 result.push_back(stream.consume());
1180 }
1181 }
1182
1183 return result;
1184 }
preprocessor_detail::Token Token

References infix2postfix::preprocessor::TokenStream::consume(), infix2postfix::preprocessor::TokenStream::is_eof(), infix2postfix::preprocessor::Macro::is_function_like, infix2postfix::preprocessor::TokenStream::peek(), Token::text, and Token::type.

◆ getExpansions()

std::vector< MacroExpansion > infix2postfix::preprocessor::Expander::getExpansions ( ) const
inlinenodiscard

Definition at line 1186 of file Preprocessor.cpp.

1186 {
1187 return expansions;
1188 }

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