Home | History | Annotate | Download | only in re.synopt
      1 // -*- C++ -*-
      2 //===----------------------------------------------------------------------===//
      3 //
      4 //                     The LLVM Compiler Infrastructure
      5 //
      6 // This file is dual licensed under the MIT and the University of Illinois Open
      7 // Source Licenses. See LICENSE.TXT for details.
      8 //
      9 //===----------------------------------------------------------------------===//
     10 
     11 // <regex>
     12 
     13 // namespace regex_constants
     14 // {
     15 //
     16 // emum syntax_option_type  // bitmask type
     17 // {
     18 //     icase      = unspecified,
     19 //     nosubs     = unspecified,
     20 //     optimize   = unspecified,
     21 //     collate    = unspecified,
     22 //     ECMAScript = unspecified,
     23 //     basic      = unspecified,
     24 //     extended   = unspecified,
     25 //     awk        = unspecified,
     26 //     grep       = unspecified,
     27 //     egrep      = unspecified
     28 // };
     29 //
     30 // }
     31 
     32 #include <regex>
     33 #include <cassert>
     34 
     35 int main()
     36 {
     37     assert(std::regex_constants::icase != 0);
     38     assert(std::regex_constants::nosubs != 0);
     39     assert(std::regex_constants::optimize != 0);
     40     assert(std::regex_constants::collate != 0);
     41     assert(std::regex_constants::ECMAScript == 0);
     42     assert(std::regex_constants::basic != 0);
     43     assert(std::regex_constants::extended != 0);
     44     assert(std::regex_constants::awk != 0);
     45     assert(std::regex_constants::grep != 0);
     46     assert(std::regex_constants::egrep != 0);
     47 
     48     assert((std::regex_constants::icase & std::regex_constants::nosubs) == 0);
     49     assert((std::regex_constants::icase & std::regex_constants::optimize) == 0);
     50     assert((std::regex_constants::icase & std::regex_constants::collate) == 0);
     51     assert((std::regex_constants::icase & std::regex_constants::ECMAScript) == 0);
     52     assert((std::regex_constants::icase & std::regex_constants::basic) == 0);
     53     assert((std::regex_constants::icase & std::regex_constants::extended) == 0);
     54     assert((std::regex_constants::icase & std::regex_constants::awk) == 0);
     55     assert((std::regex_constants::icase & std::regex_constants::grep) == 0);
     56     assert((std::regex_constants::icase & std::regex_constants::egrep) == 0);
     57 
     58     assert((std::regex_constants::nosubs & std::regex_constants::optimize) == 0);
     59     assert((std::regex_constants::nosubs & std::regex_constants::collate) == 0);
     60     assert((std::regex_constants::nosubs & std::regex_constants::ECMAScript) == 0);
     61     assert((std::regex_constants::nosubs & std::regex_constants::basic) == 0);
     62     assert((std::regex_constants::nosubs & std::regex_constants::extended) == 0);
     63     assert((std::regex_constants::nosubs & std::regex_constants::awk) == 0);
     64     assert((std::regex_constants::nosubs & std::regex_constants::grep) == 0);
     65     assert((std::regex_constants::nosubs & std::regex_constants::egrep) == 0);
     66 
     67     assert((std::regex_constants::optimize & std::regex_constants::collate) == 0);
     68     assert((std::regex_constants::optimize & std::regex_constants::ECMAScript) == 0);
     69     assert((std::regex_constants::optimize & std::regex_constants::basic) == 0);
     70     assert((std::regex_constants::optimize & std::regex_constants::extended) == 0);
     71     assert((std::regex_constants::optimize & std::regex_constants::awk) == 0);
     72     assert((std::regex_constants::optimize & std::regex_constants::grep) == 0);
     73     assert((std::regex_constants::optimize & std::regex_constants::egrep) == 0);
     74 
     75     assert((std::regex_constants::collate & std::regex_constants::ECMAScript) == 0);
     76     assert((std::regex_constants::collate & std::regex_constants::basic) == 0);
     77     assert((std::regex_constants::collate & std::regex_constants::extended) == 0);
     78     assert((std::regex_constants::collate & std::regex_constants::awk) == 0);
     79     assert((std::regex_constants::collate & std::regex_constants::grep) == 0);
     80     assert((std::regex_constants::collate & std::regex_constants::egrep) == 0);
     81 
     82     assert((std::regex_constants::ECMAScript & std::regex_constants::basic) == 0);
     83     assert((std::regex_constants::ECMAScript & std::regex_constants::extended) == 0);
     84     assert((std::regex_constants::ECMAScript & std::regex_constants::awk) == 0);
     85     assert((std::regex_constants::ECMAScript & std::regex_constants::grep) == 0);
     86     assert((std::regex_constants::ECMAScript & std::regex_constants::egrep) == 0);
     87 
     88     assert((std::regex_constants::basic & std::regex_constants::extended) == 0);
     89     assert((std::regex_constants::basic & std::regex_constants::awk) == 0);
     90     assert((std::regex_constants::basic & std::regex_constants::grep) == 0);
     91     assert((std::regex_constants::basic & std::regex_constants::egrep) == 0);
     92 
     93     assert((std::regex_constants::extended & std::regex_constants::awk) == 0);
     94     assert((std::regex_constants::extended & std::regex_constants::grep) == 0);
     95     assert((std::regex_constants::extended & std::regex_constants::egrep) == 0);
     96 
     97     assert((std::regex_constants::awk & std::regex_constants::grep) == 0);
     98     assert((std::regex_constants::awk & std::regex_constants::egrep) == 0);
     99 
    100     assert((std::regex_constants::grep & std::regex_constants::egrep) == 0);
    101 
    102     assert((std::regex_constants::icase | std::regex_constants::nosubs) != 0);
    103     assert((std::regex_constants::icase ^ std::regex_constants::nosubs) != 0);
    104 
    105     std::regex_constants::syntax_option_type e1 = std::regex_constants::icase;
    106     std::regex_constants::syntax_option_type e2 = std::regex_constants::nosubs;
    107     e1 = ~e1;
    108     e1 = e1 & e2;
    109     e1 = e1 | e2;
    110     e1 = e1 ^ e2;
    111     e1 &= e2;
    112     e1 |= e2;
    113     e1 ^= e2;
    114 }
    115