libstdc++
regex_compiler.tcc
Go to the documentation of this file.
1 // class template regex -*- C++ -*-
2 
3 // Copyright (C) 2013-2018 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10 
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19 
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24 
25 /**
26  * @file bits/regex_compiler.tcc
27  * This is an internal header file, included by other library headers.
28  * Do not attempt to use it directly. @headername{regex}
29  */
30 
31 // FIXME make comments doxygen format.
32 
33 /*
34 // This compiler refers to "Regular Expression Matching Can Be Simple And Fast"
35 // (http://swtch.com/~rsc/regexp/regexp1.html),
36 // but doesn't strictly follow it.
37 //
38 // When compiling, states are *chained* instead of tree- or graph-constructed.
39 // It's more like structured programs: there's if statement and loop statement.
40 //
41 // For alternative structure (say "a|b"), aka "if statement", two branches
42 // should be constructed. However, these two shall merge to an "end_tag" at
43 // the end of this operator:
44 //
45 // branch1
46 // / \
47 // => begin_tag end_tag =>
48 // \ /
49 // branch2
50 //
51 // This is the difference between this implementation and that in Russ's
52 // article.
53 //
54 // That's why we introduced dummy node here ------ "end_tag" is a dummy node.
55 // All dummy nodes will be eliminated at the end of compilation.
56 */
57 
58 namespace std _GLIBCXX_VISIBILITY(default)
59 {
60 _GLIBCXX_BEGIN_NAMESPACE_VERSION
61 
62 namespace __detail
63 {
64  template<typename _TraitsT>
65  _Compiler<_TraitsT>::
66  _Compiler(_IterT __b, _IterT __e,
67  const typename _TraitsT::locale_type& __loc, _FlagT __flags)
68  : _M_flags((__flags
69  & (regex_constants::ECMAScript
70  | regex_constants::basic
71  | regex_constants::extended
72  | regex_constants::grep
73  | regex_constants::egrep
74  | regex_constants::awk))
75  ? __flags
76  : __flags | regex_constants::ECMAScript),
77  _M_scanner(__b, __e, _M_flags, __loc),
78  _M_nfa(make_shared<_RegexT>(__loc, _M_flags)),
79  _M_traits(_M_nfa->_M_traits),
80  _M_ctype(std::use_facet<_CtypeT>(__loc))
81  {
82  _StateSeqT __r(*_M_nfa, _M_nfa->_M_start());
83  __r._M_append(_M_nfa->_M_insert_subexpr_begin());
84  this->_M_disjunction();
85  if (!_M_match_token(_ScannerT::_S_token_eof))
86  __throw_regex_error(regex_constants::error_paren);
87  __r._M_append(_M_pop());
88  __glibcxx_assert(_M_stack.empty());
89  __r._M_append(_M_nfa->_M_insert_subexpr_end());
90  __r._M_append(_M_nfa->_M_insert_accept());
91  _M_nfa->_M_eliminate_dummy();
92  }
93 
94  template<typename _TraitsT>
95  void
96  _Compiler<_TraitsT>::
97  _M_disjunction()
98  {
99  this->_M_alternative();
100  while (_M_match_token(_ScannerT::_S_token_or))
101  {
102  _StateSeqT __alt1 = _M_pop();
103  this->_M_alternative();
104  _StateSeqT __alt2 = _M_pop();
105  auto __end = _M_nfa->_M_insert_dummy();
106  __alt1._M_append(__end);
107  __alt2._M_append(__end);
108  // __alt2 is state._M_next, __alt1 is state._M_alt. The executor
109  // executes _M_alt before _M_next, as well as executing left
110  // alternative before right one.
111  _M_stack.push(_StateSeqT(*_M_nfa,
112  _M_nfa->_M_insert_alt(
113  __alt2._M_start, __alt1._M_start, false),
114  __end));
115  }
116  }
117 
118  template<typename _TraitsT>
119  void
120  _Compiler<_TraitsT>::
121  _M_alternative()
122  {
123  if (this->_M_term())
124  {
125  _StateSeqT __re = _M_pop();
126  this->_M_alternative();
127  __re._M_append(_M_pop());
128  _M_stack.push(__re);
129  }
130  else
131  _M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->_M_insert_dummy()));
132  }
133 
134  template<typename _TraitsT>
135  bool
136  _Compiler<_TraitsT>::
137  _M_term()
138  {
139  if (this->_M_assertion())
140  return true;
141  if (this->_M_atom())
142  {
143  while (this->_M_quantifier())
144  ;
145  return true;
146  }
147  return false;
148  }
149 
150  template<typename _TraitsT>
151  bool
152  _Compiler<_TraitsT>::
153  _M_assertion()
154  {
155  if (_M_match_token(_ScannerT::_S_token_line_begin))
156  _M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->_M_insert_line_begin()));
157  else if (_M_match_token(_ScannerT::_S_token_line_end))
158  _M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->_M_insert_line_end()));
159  else if (_M_match_token(_ScannerT::_S_token_word_bound))
160  // _M_value[0] == 'n' means it's negative, say "not word boundary".
161  _M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->
162  _M_insert_word_bound(_M_value[0] == 'n')));
163  else if (_M_match_token(_ScannerT::_S_token_subexpr_lookahead_begin))
164  {
165  auto __neg = _M_value[0] == 'n';
166  this->_M_disjunction();
167  if (!_M_match_token(_ScannerT::_S_token_subexpr_end))
168  __throw_regex_error(regex_constants::error_paren,
169  "Parenthesis is not closed.");
170  auto __tmp = _M_pop();
171  __tmp._M_append(_M_nfa->_M_insert_accept());
172  _M_stack.push(
173  _StateSeqT(
174  *_M_nfa,
175  _M_nfa->_M_insert_lookahead(__tmp._M_start, __neg)));
176  }
177  else
178  return false;
179  return true;
180  }
181 
182  template<typename _TraitsT>
183  bool
184  _Compiler<_TraitsT>::
185  _M_quantifier()
186  {
187  bool __neg = (_M_flags & regex_constants::ECMAScript);
188  auto __init = [this, &__neg]()
189  {
190  if (_M_stack.empty())
191  __throw_regex_error(regex_constants::error_badrepeat,
192  "Nothing to repeat before a quantifier.");
193  __neg = __neg && _M_match_token(_ScannerT::_S_token_opt);
194  };
195  if (_M_match_token(_ScannerT::_S_token_closure0))
196  {
197  __init();
198  auto __e = _M_pop();
199  _StateSeqT __r(*_M_nfa,
200  _M_nfa->_M_insert_repeat(_S_invalid_state_id,
201  __e._M_start, __neg));
202  __e._M_append(__r);
203  _M_stack.push(__r);
204  }
205  else if (_M_match_token(_ScannerT::_S_token_closure1))
206  {
207  __init();
208  auto __e = _M_pop();
209  __e._M_append(_M_nfa->_M_insert_repeat(_S_invalid_state_id,
210  __e._M_start, __neg));
211  _M_stack.push(__e);
212  }
213  else if (_M_match_token(_ScannerT::_S_token_opt))
214  {
215  __init();
216  auto __e = _M_pop();
217  auto __end = _M_nfa->_M_insert_dummy();
218  _StateSeqT __r(*_M_nfa,
219  _M_nfa->_M_insert_repeat(_S_invalid_state_id,
220  __e._M_start, __neg));
221  __e._M_append(__end);
222  __r._M_append(__end);
223  _M_stack.push(__r);
224  }
225  else if (_M_match_token(_ScannerT::_S_token_interval_begin))
226  {
227  if (_M_stack.empty())
228  __throw_regex_error(regex_constants::error_badrepeat,
229  "Nothing to repeat before a quantifier.");
230  if (!_M_match_token(_ScannerT::_S_token_dup_count))
231  __throw_regex_error(regex_constants::error_badbrace,
232  "Unexpected token in brace expression.");
233  _StateSeqT __r(_M_pop());
234  _StateSeqT __e(*_M_nfa, _M_nfa->_M_insert_dummy());
235  long __min_rep = _M_cur_int_value(10);
236  bool __infi = false;
237  long __n;
238 
239  // {3
240  if (_M_match_token(_ScannerT::_S_token_comma))
241  if (_M_match_token(_ScannerT::_S_token_dup_count)) // {3,7}
242  __n = _M_cur_int_value(10) - __min_rep;
243  else
244  __infi = true;
245  else
246  __n = 0;
247  if (!_M_match_token(_ScannerT::_S_token_interval_end))
248  __throw_regex_error(regex_constants::error_brace,
249  "Unexpected end of brace expression.");
250 
251  __neg = __neg && _M_match_token(_ScannerT::_S_token_opt);
252 
253  for (long __i = 0; __i < __min_rep; ++__i)
254  __e._M_append(__r._M_clone());
255 
256  if (__infi)
257  {
258  auto __tmp = __r._M_clone();
259  _StateSeqT __s(*_M_nfa,
260  _M_nfa->_M_insert_repeat(_S_invalid_state_id,
261  __tmp._M_start, __neg));
262  __tmp._M_append(__s);
263  __e._M_append(__s);
264  }
265  else
266  {
267  if (__n < 0)
268  __throw_regex_error(regex_constants::error_badbrace,
269  "Invalid range in brace expression.");
270  auto __end = _M_nfa->_M_insert_dummy();
271  // _M_alt is the "match more" branch, and _M_next is the
272  // "match less" one. Switch _M_alt and _M_next of all created
273  // nodes. This is a hack but IMO works well.
274  std::stack<_StateIdT> __stack;
275  for (long __i = 0; __i < __n; ++__i)
276  {
277  auto __tmp = __r._M_clone();
278  auto __alt = _M_nfa->_M_insert_repeat(__tmp._M_start,
279  __end, __neg);
280  __stack.push(__alt);
281  __e._M_append(_StateSeqT(*_M_nfa, __alt, __tmp._M_end));
282  }
283  __e._M_append(__end);
284  while (!__stack.empty())
285  {
286  auto& __tmp = (*_M_nfa)[__stack.top()];
287  __stack.pop();
288  std::swap(__tmp._M_next, __tmp._M_alt);
289  }
290  }
291  _M_stack.push(__e);
292  }
293  else
294  return false;
295  return true;
296  }
297 
298 #define __INSERT_REGEX_MATCHER(__func, ...)\
299  do {\
300  if (!(_M_flags & regex_constants::icase))\
301  if (!(_M_flags & regex_constants::collate))\
302  __func<false, false>(__VA_ARGS__);\
303  else\
304  __func<false, true>(__VA_ARGS__);\
305  else\
306  if (!(_M_flags & regex_constants::collate))\
307  __func<true, false>(__VA_ARGS__);\
308  else\
309  __func<true, true>(__VA_ARGS__);\
310  } while (false)
311 
312  template<typename _TraitsT>
313  bool
314  _Compiler<_TraitsT>::
315  _M_atom()
316  {
317  if (_M_match_token(_ScannerT::_S_token_anychar))
318  {
319  if (!(_M_flags & regex_constants::ECMAScript))
320  __INSERT_REGEX_MATCHER(_M_insert_any_matcher_posix);
321  else
322  __INSERT_REGEX_MATCHER(_M_insert_any_matcher_ecma);
323  }
324  else if (_M_try_char())
325  __INSERT_REGEX_MATCHER(_M_insert_char_matcher);
326  else if (_M_match_token(_ScannerT::_S_token_backref))
327  _M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->
328  _M_insert_backref(_M_cur_int_value(10))));
329  else if (_M_match_token(_ScannerT::_S_token_quoted_class))
330  __INSERT_REGEX_MATCHER(_M_insert_character_class_matcher);
331  else if (_M_match_token(_ScannerT::_S_token_subexpr_no_group_begin))
332  {
333  _StateSeqT __r(*_M_nfa, _M_nfa->_M_insert_dummy());
334  this->_M_disjunction();
335  if (!_M_match_token(_ScannerT::_S_token_subexpr_end))
336  __throw_regex_error(regex_constants::error_paren,
337  "Parenthesis is not closed.");
338  __r._M_append(_M_pop());
339  _M_stack.push(__r);
340  }
341  else if (_M_match_token(_ScannerT::_S_token_subexpr_begin))
342  {
343  _StateSeqT __r(*_M_nfa, _M_nfa->_M_insert_subexpr_begin());
344  this->_M_disjunction();
345  if (!_M_match_token(_ScannerT::_S_token_subexpr_end))
346  __throw_regex_error(regex_constants::error_paren,
347  "Parenthesis is not closed.");
348  __r._M_append(_M_pop());
349  __r._M_append(_M_nfa->_M_insert_subexpr_end());
350  _M_stack.push(__r);
351  }
352  else if (!_M_bracket_expression())
353  return false;
354  return true;
355  }
356 
357  template<typename _TraitsT>
358  bool
359  _Compiler<_TraitsT>::
360  _M_bracket_expression()
361  {
362  bool __neg =
363  _M_match_token(_ScannerT::_S_token_bracket_neg_begin);
364  if (!(__neg || _M_match_token(_ScannerT::_S_token_bracket_begin)))
365  return false;
366  __INSERT_REGEX_MATCHER(_M_insert_bracket_matcher, __neg);
367  return true;
368  }
369 #undef __INSERT_REGEX_MATCHER
370 
371  template<typename _TraitsT>
372  template<bool __icase, bool __collate>
373  void
374  _Compiler<_TraitsT>::
375  _M_insert_any_matcher_ecma()
376  {
377  _M_stack.push(_StateSeqT(*_M_nfa,
378  _M_nfa->_M_insert_matcher
379  (_AnyMatcher<_TraitsT, true, __icase, __collate>
380  (_M_traits))));
381  }
382 
383  template<typename _TraitsT>
384  template<bool __icase, bool __collate>
385  void
386  _Compiler<_TraitsT>::
387  _M_insert_any_matcher_posix()
388  {
389  _M_stack.push(_StateSeqT(*_M_nfa,
390  _M_nfa->_M_insert_matcher
391  (_AnyMatcher<_TraitsT, false, __icase, __collate>
392  (_M_traits))));
393  }
394 
395  template<typename _TraitsT>
396  template<bool __icase, bool __collate>
397  void
398  _Compiler<_TraitsT>::
399  _M_insert_char_matcher()
400  {
401  _M_stack.push(_StateSeqT(*_M_nfa,
402  _M_nfa->_M_insert_matcher
403  (_CharMatcher<_TraitsT, __icase, __collate>
404  (_M_value[0], _M_traits))));
405  }
406 
407  template<typename _TraitsT>
408  template<bool __icase, bool __collate>
409  void
410  _Compiler<_TraitsT>::
411  _M_insert_character_class_matcher()
412  {
413  __glibcxx_assert(_M_value.size() == 1);
414  _BracketMatcher<__icase, __collate> __matcher
415  (_M_ctype.is(_CtypeT::upper, _M_value[0]), _M_traits);
416  __matcher._M_add_character_class(_M_value, false);
417  __matcher._M_ready();
418  _M_stack.push(_StateSeqT(*_M_nfa,
419  _M_nfa->_M_insert_matcher(std::move(__matcher))));
420  }
421 
422  template<typename _TraitsT>
423  template<bool __icase, bool __collate>
424  void
425  _Compiler<_TraitsT>::
426  _M_insert_bracket_matcher(bool __neg)
427  {
428  _BracketMatcher<__icase, __collate> __matcher(__neg, _M_traits);
429  _BracketState __last_char;
430  if (_M_try_char())
431  __last_char.set(_M_value[0]);
432  else if (_M_match_token(_ScannerT::_S_token_bracket_dash))
433  // Dash as first character is a normal character.
434  __last_char.set('-');
435  while (_M_expression_term(__last_char, __matcher))
436  ;
437  if (__last_char._M_is_char())
438  __matcher._M_add_char(__last_char.get());
439  __matcher._M_ready();
440  _M_stack.push(_StateSeqT(
441  *_M_nfa,
442  _M_nfa->_M_insert_matcher(std::move(__matcher))));
443  }
444 
445  template<typename _TraitsT>
446  template<bool __icase, bool __collate>
447  bool
448  _Compiler<_TraitsT>::
449  _M_expression_term(_BracketState& __last_char,
450  _BracketMatcher<__icase, __collate>& __matcher)
451  {
452  if (_M_match_token(_ScannerT::_S_token_bracket_end))
453  return false;
454 
455  // Add any previously cached char into the matcher and update cache.
456  const auto __push_char = [&](_CharT __ch)
457  {
458  if (__last_char._M_is_char())
459  __matcher._M_add_char(__last_char.get());
460  __last_char.set(__ch);
461  };
462  // Add any previously cached char into the matcher and update cache.
463  const auto __push_class = [&]
464  {
465  if (__last_char._M_is_char())
466  __matcher._M_add_char(__last_char.get());
467  // We don't cache anything here, just record that the last thing
468  // processed was a character class (or similar).
469  __last_char.reset(_BracketState::_Type::_Class);
470  };
471 
472  if (_M_match_token(_ScannerT::_S_token_collsymbol))
473  {
474  auto __symbol = __matcher._M_add_collate_element(_M_value);
475  if (__symbol.size() == 1)
476  __push_char(__symbol[0]);
477  else
478  __push_class();
479  }
480  else if (_M_match_token(_ScannerT::_S_token_equiv_class_name))
481  {
482  __push_class();
483  __matcher._M_add_equivalence_class(_M_value);
484  }
485  else if (_M_match_token(_ScannerT::_S_token_char_class_name))
486  {
487  __push_class();
488  __matcher._M_add_character_class(_M_value, false);
489  }
490  else if (_M_try_char())
491  __push_char(_M_value[0]);
492  // POSIX doesn't allow '-' as a start-range char (say [a-z--0]),
493  // except when the '-' is the first or last character in the bracket
494  // expression ([--0]). ECMAScript treats all '-' after a range as a
495  // normal character. Also see above, where _M_expression_term gets called.
496  //
497  // As a result, POSIX rejects [-----], but ECMAScript doesn't.
498  // Boost (1.57.0) always uses POSIX style even in its ECMAScript syntax.
499  // Clang (3.5) always uses ECMAScript style even in its POSIX syntax.
500  //
501  // It turns out that no one reads BNFs ;)
502  else if (_M_match_token(_ScannerT::_S_token_bracket_dash))
503  {
504  if (_M_match_token(_ScannerT::_S_token_bracket_end))
505  {
506  // For "-]" the dash is a literal character.
507  __push_char('-');
508  return false;
509  }
510  else if (__last_char._M_is_class())
511  {
512  // "\\w-" is invalid, start of range must be a single char.
513  __throw_regex_error(regex_constants::error_range,
514  "Invalid start of range in bracket expression.");
515  }
516  else if (__last_char._M_is_char())
517  {
518  if (_M_try_char())
519  {
520  // "x-y"
521  __matcher._M_make_range(__last_char.get(), _M_value[0]);
522  __last_char.reset();
523  }
524  else if (_M_match_token(_ScannerT::_S_token_bracket_dash))
525  {
526  // "x--"
527  __matcher._M_make_range(__last_char.get(), '-');
528  __last_char.reset();
529  }
530  else
531  __throw_regex_error(regex_constants::error_range,
532  "Invalid end of range in bracket expression.");
533  }
534  else if (_M_flags & regex_constants::ECMAScript)
535  {
536  // A dash that is not part of an existing range. Might be the
537  // start of a new range, or might just be a literal '-' char.
538  // Only ECMAScript allows that in the middle of a bracket expr.
539  __push_char('-');
540  }
541  else
542  __throw_regex_error(regex_constants::error_range,
543  "Invalid dash in bracket expression.");
544  }
545  else if (_M_match_token(_ScannerT::_S_token_quoted_class))
546  {
547  __push_class();
548  __matcher._M_add_character_class(_M_value,
549  _M_ctype.is(_CtypeT::upper,
550  _M_value[0]));
551  }
552  else
553  __throw_regex_error(regex_constants::error_brack,
554  "Unexpected character in bracket expression.");
555 
556  return true;
557  }
558 
559  template<typename _TraitsT>
560  bool
561  _Compiler<_TraitsT>::
562  _M_try_char()
563  {
564  bool __is_char = false;
565  if (_M_match_token(_ScannerT::_S_token_oct_num))
566  {
567  __is_char = true;
568  _M_value.assign(1, _M_cur_int_value(8));
569  }
570  else if (_M_match_token(_ScannerT::_S_token_hex_num))
571  {
572  __is_char = true;
573  _M_value.assign(1, _M_cur_int_value(16));
574  }
575  else if (_M_match_token(_ScannerT::_S_token_ord_char))
576  __is_char = true;
577  return __is_char;
578  }
579 
580  template<typename _TraitsT>
581  bool
582  _Compiler<_TraitsT>::
583  _M_match_token(_TokenT __token)
584  {
585  if (__token == _M_scanner._M_get_token())
586  {
587  _M_value = _M_scanner._M_get_value();
588  _M_scanner._M_advance();
589  return true;
590  }
591  return false;
592  }
593 
594  template<typename _TraitsT>
595  int
596  _Compiler<_TraitsT>::
597  _M_cur_int_value(int __radix)
598  {
599  long __v = 0;
600  for (typename _StringT::size_type __i = 0;
601  __i < _M_value.length(); ++__i)
602  __v =__v * __radix + _M_traits.value(_M_value[__i], __radix);
603  return __v;
604  }
605 
606  template<typename _TraitsT, bool __icase, bool __collate>
607  bool
608  _BracketMatcher<_TraitsT, __icase, __collate>::
609  _M_apply(_CharT __ch, false_type) const
610  {
611  return [this, __ch]
612  {
613  if (std::binary_search(_M_char_set.begin(), _M_char_set.end(),
614  _M_translator._M_translate(__ch)))
615  return true;
616  auto __s = _M_translator._M_transform(__ch);
617  for (auto& __it : _M_range_set)
618  if (_M_translator._M_match_range(__it.first, __it.second, __s))
619  return true;
620  if (_M_traits.isctype(__ch, _M_class_set))
621  return true;
622  if (std::find(_M_equiv_set.begin(), _M_equiv_set.end(),
623  _M_traits.transform_primary(&__ch, &__ch+1))
624  != _M_equiv_set.end())
625  return true;
626  for (auto& __it : _M_neg_class_set)
627  if (!_M_traits.isctype(__ch, __it))
628  return true;
629  return false;
630  }() ^ _M_is_non_matching;
631  }
632 } // namespace __detail
633 
634 _GLIBCXX_END_NAMESPACE_VERSION
635 } // namespace
shared_ptr< _Tp > make_shared(_Args &&... __args)
Create an object that is owned by a shared_ptr.
bool empty() const
Definition: stl_stack.h:185
void push(const value_type &__x)
Add data to the top of the stack.
Definition: stl_stack.h:225
A standard container giving FILO behavior.
Definition: stl_stack.h:99
reference top()
Definition: stl_stack.h:198
_GLIBCXX17_INLINE constexpr syntax_option_type ECMAScript
constexpr error_type error_brace(_S_error_brace)
constexpr error_type error_badrepeat(_S_error_badrepeat)
const _Facet & use_facet(const locale &__loc)
Return a facet.use_facet looks for and returns a reference to a facet of type Facet where Facet is th...
void pop()
Removes first element.
Definition: stl_stack.h:258
ISO C++ entities toplevel namespace is std.
_GLIBCXX17_INLINE constexpr syntax_option_type extended
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
Definition: type_traits:78
constexpr error_type error_range(_S_error_range)
_GLIBCXX17_INLINE constexpr syntax_option_type awk
constexpr error_type error_badbrace(_S_error_badbrace)
_GLIBCXX17_INLINE constexpr syntax_option_type grep
_GLIBCXX17_INLINE constexpr syntax_option_type egrep
constexpr error_type error_paren(_S_error_paren)
constexpr error_type error_brack(_S_error_brack)
_GLIBCXX17_INLINE constexpr syntax_option_type basic