fork download
  1. #include <iostream>
  2. #include <regex>
  3. #include <string>
  4.  
  5. int main(){
  6. std::string input = "num i = 10;\nstr s = \"hello lol\";\n\nfnc fx(): num {\n print(\"lol\");\n ret 20;\n}\n\nnum x = fx();";
  7.  
  8. const std::regex lex("(\\s|;|\\(|\\)|{|})+(?=(?:[^\\'\"]*[\\'\"][^\\'\"]*[\\'\"])*[^\\'\"]*$)");
  9.  
  10. std::cout << "EzScript >" << std::endl;
  11.  
  12. std::string s1 = std::regex_replace(input, lex, "\n");
  13. std::string s2 = std::regex_replace(s1, "\n+", "\n");
  14.  
  15. std::cout << s2 << std::endl;
  16.  
  17. return 0;
  18. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:13:53: error: no matching function for call to ‘regex_replace(std::__cxx11::string&, const char [3], const char [2])’
  std::string s2 = std::regex_replace(s1, "\n+", "\n");
                                                     ^
In file included from /usr/include/c++/8/regex:62,
                 from prog.cpp:2:
/usr/include/c++/8/bits/regex.h:2331:5: note: candidate: ‘template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type, class _St, class _Sa> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, const std::__cxx11::basic_string<_Ch_type, _St, _Sa>&, std::regex_constants::match_flag_type)’
     regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
     ^~~~~~~~~~~~~
/usr/include/c++/8/bits/regex.h:2331:5: note:   template argument deduction/substitution failed:
prog.cpp:13:53: note:   candidate expects 6 arguments, 3 provided
  std::string s2 = std::regex_replace(s1, "\n+", "\n");
                                                     ^
In file included from /usr/include/c++/8/bits/regex.h:2839,
                 from /usr/include/c++/8/regex:62,
                 from prog.cpp:2:
/usr/include/c++/8/bits/regex.tcc:465:5: note: candidate: ‘template<class _Out_iter, class _Bi_iter, class _Rx_traits, class _Ch_type> _Out_iter std::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, const _Ch_type*, std::regex_constants::match_flag_type)’
     regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
     ^~~~~~~~~~~~~
/usr/include/c++/8/bits/regex.tcc:465:5: note:   template argument deduction/substitution failed:
prog.cpp:13:53: note:   candidate expects 6 arguments, 3 provided
  std::string s2 = std::regex_replace(s1, "\n+", "\n");
                                                     ^
In file included from /usr/include/c++/8/regex:62,
                 from prog.cpp:2:
/usr/include/c++/8/bits/regex.h:2376:5: note: candidate: ‘template<class _Rx_traits, class _Ch_type, class _St, class _Sa, class _Fst, class _Fsa> std::__cxx11::basic_string<_Ch_type, _St, _Sa> std::regex_replace(const std::__cxx11::basic_string<_Ch_type, _St, _Sa>&, const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, const std::__cxx11::basic_string<_Ch_type, _Fst, _Fsa>&, std::regex_constants::match_flag_type)’
     regex_replace(const basic_string<_Ch_type, _St, _Sa>& __s,
     ^~~~~~~~~~~~~
/usr/include/c++/8/bits/regex.h:2376:5: note:   template argument deduction/substitution failed:
prog.cpp:13:53: note:   mismatched types ‘const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>’ and ‘const char [3]’
  std::string s2 = std::regex_replace(s1, "\n+", "\n");
                                                     ^
In file included from /usr/include/c++/8/regex:62,
                 from prog.cpp:2:
/usr/include/c++/8/bits/regex.h:2402:5: note: candidate: ‘template<class _Rx_traits, class _Ch_type, class _St, class _Sa> std::__cxx11::basic_string<_Ch_type, _St, _Sa> std::regex_replace(const std::__cxx11::basic_string<_Ch_type, _St, _Sa>&, const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, const _Ch_type*, std::regex_constants::match_flag_type)’
     regex_replace(const basic_string<_Ch_type, _St, _Sa>& __s,
     ^~~~~~~~~~~~~
/usr/include/c++/8/bits/regex.h:2402:5: note:   template argument deduction/substitution failed:
prog.cpp:13:53: note:   mismatched types ‘const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>’ and ‘const char [3]’
  std::string s2 = std::regex_replace(s1, "\n+", "\n");
                                                     ^
In file included from /usr/include/c++/8/regex:62,
                 from prog.cpp:2:
/usr/include/c++/8/bits/regex.h:2428:5: note: candidate: ‘template<class _Rx_traits, class _Ch_type, class _St, class _Sa> std::__cxx11::basic_string<_Ch_type> std::regex_replace(const _Ch_type*, const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, const std::__cxx11::basic_string<_Ch_type, _St, _Sa>&, std::regex_constants::match_flag_type)’
     regex_replace(const _Ch_type* __s,
     ^~~~~~~~~~~~~
/usr/include/c++/8/bits/regex.h:2428:5: note:   template argument deduction/substitution failed:
prog.cpp:13:53: note:   mismatched types ‘const _Ch_type*’ and ‘std::__cxx11::basic_string<char>’
  std::string s2 = std::regex_replace(s1, "\n+", "\n");
                                                     ^
In file included from /usr/include/c++/8/regex:62,
                 from prog.cpp:2:
/usr/include/c++/8/bits/regex.h:2454:5: note: candidate: ‘template<class _Rx_traits, class _Ch_type> std::__cxx11::basic_string<_Ch_type> std::regex_replace(const _Ch_type*, const std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, const _Ch_type*, std::regex_constants::match_flag_type)’
     regex_replace(const _Ch_type* __s,
     ^~~~~~~~~~~~~
/usr/include/c++/8/bits/regex.h:2454:5: note:   template argument deduction/substitution failed:
prog.cpp:13:53: note:   mismatched types ‘const _Ch_type*’ and ‘std::__cxx11::basic_string<char>’
  std::string s2 = std::regex_replace(s1, "\n+", "\n");
                                                     ^
stdout
Standard output is empty