programming language
Révision | 8561f96c687d0ba3ff0278fb6a8394e29e5231b8 (tree) |
---|---|
l'heure | 2023-03-23 23:30:20 |
Auteur | dhrname <dhrname@joes...> |
Commiter | dhrname |
Add the initilizeCoordinate member function and the getFollowSt member function
@@ -1258,6 +1258,11 @@ namespace jstr | ||
1258 | 1258 | * 文法にマッチした記号が三次元配列のどこに配置されているかがわかる*/ |
1259 | 1259 | virtual void setCoordinate(const int32_t, const int32_t, const int32_t); |
1260 | 1260 | |
1261 | + /*initializeCoordinate メンバ関数 | |
1262 | + * BNF記法を三次元配列化したものの、座標位置を初期化 | |
1263 | + * 文法にマッチした記号が三次元配列のどこに配置されているかがわかる*/ | |
1264 | + virtual void initializeCoordinate(); | |
1265 | + | |
1261 | 1266 | /*isNonterminalSymbolId メンバ関数 |
1262 | 1267 | * 引数idが非終端記号であれば、true、 |
1263 | 1268 | * そうでなければ、falseを返す*/ |
@@ -1317,7 +1322,7 @@ namespace jstr | ||
1317 | 1322 | virtual void setFollowSetBySymbolId(const int32_t); |
1318 | 1323 | |
1319 | 1324 | /*getFollowSet メンバ関数 |
1320 | - * BNF定義を元にFOLLOW集合を求める*/ | |
1325 | + * BNF定義の座標を元にFOLLOW集合を求める*/ | |
1321 | 1326 | virtual std::unordered_set<int32_t>& getFollowSet(); |
1322 | 1327 | }; |
1323 | 1328 |
@@ -229,25 +229,7 @@ void Parser::setCoordinate() | ||
229 | 229 | { |
230 | 230 | continue; |
231 | 231 | } |
232 | - for (int32_t k = 0; k<BNF_CONCATNATION_LENGTH;k++) | |
233 | - { | |
234 | - for (int32_t j = 0; j<BNF_SELECTION_LENGTH;j++) | |
235 | - { | |
236 | - for (int32_t i = 0;i<BNF_NONTERMINAL_LENGTH;i++) | |
237 | - { | |
238 | - int32_t id = jstr::parser::BNF[i][j][k]; | |
239 | - if (id <= 0) | |
240 | - { | |
241 | - /*bnfを疎な配列と見なして最適化*/ | |
242 | - break; | |
243 | - } | |
244 | - else if (id == p->getSymbolId()) | |
245 | - { | |
246 | - p->setCoordinate(i, j, k); | |
247 | - } | |
248 | - } | |
249 | - } | |
250 | - } | |
232 | + p->initializeCoordinate(); | |
251 | 233 | } |
252 | 234 | } |
253 | 235 |