Commit Graph

496 Commits

Author SHA1 Message Date
Alexander Bigerl 49cf9d4fe2 C++ runtime: disable build of dep utf8cpp tests and samples 2021-04-24 18:55:46 +02:00
Matthew Paletta f901c8d39a Merge branch 'master' of https://github.com/antlr/antlr4 2021-04-09 19:12:33 +01:00
Mike Lischke 4b4ca4058a
Revert "Cpp target: No building tests/samples for external utfcpp" 2021-04-09 14:18:25 +02:00
Terence Parr 697074c3e9
Merge branch 'master' into master 2021-04-08 09:18:40 -07:00
Terence Parr eec33c5210
Merge branch 'master' into patch-1 2021-04-08 09:16:57 -07:00
Terence Parr 765de17f2a
Merge pull request #3073 from jirislaby/master
Cpp/runtime: use utfcpp from system if possible
2021-04-08 09:15:30 -07:00
Alexander Bigerl 3238961241
Merge branch 'master' into patch-1 2021-04-08 16:06:07 +02:00
b1f6c1c4 0172e8661f
Update ExternalAntlr4Cpp.cmake 2021-04-07 17:42:27 -04:00
Andrei DAMIAN e7bdb71a28 c++ finally don't use std::function 2021-04-03 18:22:17 +03:00
parrt cb4e59d420 bump version to 4.9.2 2021-03-11 14:10:44 -08:00
Mike Lischke 4431f1ff69 Small improvement 2021-03-10 13:21:54 +01:00
Mike Lischke ff629d543a Another build fix
C++ is not <any other language where you don't need a useless constructor>
2021-03-10 12:07:09 +01:00
Mike Lischke 9d1737f33b Build fix 2021-03-10 11:58:49 +01:00
Mike Lischke 5731e64e22 Added a sanity check for input size. 2021-03-10 11:49:22 +01:00
Mike Lischke 84d4ce73de More changes to the ANTLRInputStream and ANTLRFileStream classes
- Added a default c-tor to the input stream to avoid an ambiquity.
- Changed the input stream API so that it can take a string pointer + length and use that for UTF conversion, avoiding so unnecessary copies. Convenience methods exist to use a std::string or a std::string_view.
- With that only a single load() method is necessary.
- In ANTLRFileStream the other c-tors are now also deleted, as they make no sense there.
2021-03-10 11:21:04 +01:00
Mike Lischke 93c06214a6 Fixed C++ tests and build warnings 2021-03-09 11:01:57 +01:00
Mike Lischke faa64fdfa7 Merge branch 'master-upstream' 2021-03-09 09:44:28 +01:00
Mike Lischke 62a829fb65 Fixed ANTLRInputStream and ANTLRFileStream
A previous change to add std::string_view support to ANTLRInputStream for C++17 caused some trouble because of ABI changes. This has been changed to define 2 constructors, one for std::string_view (for C++17) and the original one for std::string.
This is turn caused an error in ANTLRFileStream, which also takes a string in the constructor (but handling it as file name instead of input). To make this clearer the c-tor taking a std::string has been deleted in ANTLRFileStream and the class now requires to load input via the loadFile() function. This might cause some trouble for those users who had used the std::string constructor of ANTLRFileStream, but I think the better error reporting outweighs the little annoyance.
2021-03-09 09:42:55 +01:00
Jiri Slaby 5a808b470e Cpp/runtime: use utf8cpp from system if possible
Try to find system's utf8cpp first, instead of downloading it from
github. utf8cpp 3 defines a cmake package, so we can use find_package.
Older utf8cpps don't, so we try also find_path. If all that fails, we
still fall back to github download.

This is needed as distributions cannot download stuff from their build
systems. And people want to use libraries/headers from the distribution
anyway.

I had to reorder the file a bit, so that the libraries are defined
through the utf8cpp detection
2021-02-23 08:19:40 +01:00
Felix Nieuwenhuizen a08edf89ce add hints about C++ standard to readmes 2021-02-15 19:57:36 +01:00
Felix Nieuwenhuizen 03ee69bc3f add example showing how to compile Cpp runtime with a different standard 2021-02-15 18:50:29 +01:00
Felix Nieuwenhuizen 98a3f7d640 allow override of CMAKE_CXX_STANDARD 2021-02-15 18:50:29 +01:00
Felix Nieuwenhuizen 66bf523beb whitespace cleanup 2021-02-15 18:50:29 +01:00
Alexander Bigerl ed2631b2d0
Merge branch 'master' into patch-1 2021-02-01 08:38:46 +01:00
Eric Vergnaud 559d526648 fix #3042 in Cpp runtime 2021-01-23 18:47:54 +08:00
Alexander Bigerl 680a42e023
No building tests/samples for external utfcpp 2021-01-19 09:06:21 +01:00
parrt eaa976e425 Bump version to 4.9.1 2021-01-03 10:13:19 -08:00
Felix Nieuwenhuizen 8f7faab0ee revert change of Vocabulary constructor from PR #2839 to fix build error in Cpp runtime test 2020-12-01 17:52:46 +01:00
parrt d27e6cad09 Update to version num 4.9 in code / projects 2020-11-24 11:42:42 -08:00
Terence Parr 7f5848305c
Merge branch 'master' into master 2020-11-24 10:36:57 -08:00
Markus Trenkwalder d735386bf2 Fix linker issue when compiling with CMake and MSVC on Windows by setting gtest_force_shared_crt=ON 2020-09-16 08:37:14 +02:00
Charles Ruan 734d18cb35 Add missing const in StringUtils.h 2020-09-12 23:13:52 +08:00
Charles Ruan ae0c7a31f8 Implement USE_UTF8_INSTEAD_OF_CODECVT macro in CMakeLists.txt in another way. 2020-09-12 21:32:06 +08:00
Charles Ruan 73f157fb91 Add utfcpp include paths in project.pbxproj for macOS compilation. 2020-09-12 20:51:09 +08:00
Charles Ruan 4bacd99255 add prompt for USE_UTF8_INSTEAD_OF_CODECVT macro in CMakeLists.txt. 2020-09-12 20:41:02 +08:00
Charles Ruan 2d86b34c40 Compile with utf8 on macOS. 2020-09-12 20:35:08 +08:00
Charles Ruan 72d86f91ed 1. Revert change: downgrade gcc version from 5 to 4.9.
2. Add macro USE_UTF8_INSTEAD_OF_CODECVT to judge use codecvt or utf8.
2020-09-12 01:30:14 +08:00
Charles Ruan 2dc9fb50be 1. remove wstring_convert and codecvt
2. let clang::fallthrough and throw_with_nested be compatible to gcc 4.9
3. downgrade gcc version from 5 to 4.9
2020-09-12 01:30:14 +08:00
Terence Parr 1ac3593fc4
Merge pull request #2848 from nburles/fix_static_const_odr_violations
[C++ runtime] Fix static const ODR violations
2020-09-11 08:58:45 -07:00
Terence Parr 168882d942
Merge branch 'master' into master 2020-09-10 12:56:08 -07:00
Terence Parr fb2a34d5be
Merge branch 'master' into cpp_vocabulary_cleanup 2020-09-10 10:54:44 -07:00
Terence Parr 9a646e0367
Merge pull request #2847 from nburles/antlrinputstream_from_stringview
[C++ runtime] Add AntlrInputStream(std::string_view) constructor
2020-09-10 10:53:55 -07:00
Kilian Kilger 19adda3a58 Add thread_local again in StringUtils.h due to better performance 2020-09-10 18:33:08 +02:00
ArthurSonzogni f68c47a988 Fix clang compile error with --stdlib=libc++
On linux. Most users haven't installed libc++-dev, but ANTLR is passing
the "--stdlib=libc++" argument. As a result, this won't compile. Users
will see:
```
/tmp/antlr4/runtime/Cpp/runtime/src/antlr4-common.h:8:10: fatal error:
'algorithm' file not found
```

This is caused by the "WITH_LIBCXX" option.
It was introduced by:
d46ef90aa0

It causes the option "--stdlib=libc++" to be appended by default.

I believe its default value should have been left as "Off".

With "off" by default, clang will use its default C++ library, which is
always available.

The WITH_LIBCXX option is kept, being able to change the C++ library
might be useful?

BUG=https://github.com/antlr/antlr4/issues/2898
2020-09-06 15:30:54 +02:00
Matthew Paletta 0daa97a5f0 Added templated move support for antlrcpp::Any 2020-06-15 16:52:47 -07:00
Nathan Burles 254b144bf2 Add AntlrInputStream(std::string_view) constructor
Guarded by the __cplusplus macro so it is only available in C++17 or
newer.
2020-06-15 12:11:44 +01:00
Nathan Burles a1d2d47da8 Avoid defining static const members in headers
Defining a static const member in a header breaks ODR, as the object will be
defined in every translation unit that includes the header.

Instead, the members should either be declared `inline` (which is
implicitly the case for `constexpr` members) or initialized in a cpp.
Alternatively, using an anonymous enum allows the definition to remain
inside the header meaning that the compiler can still choose to inline
values.
2020-06-15 08:40:57 +01:00
irabeson 3c0dbd83dd [C++ runtime] Optimizations of Vocabulary::fromTokenNames
This commit doesn't change the behavior, it contains few small improvements:
- prevent useless copy when creating the variable tokenName
- avoid to check if tokenName is empty twice
- use std::string::empty() instead of creating an empty string to compare with
- use std::string::clear() instead of assigning an empty C string to clear a string
2020-06-04 23:25:12 -04:00
Kilian Kilger 88dffba62e Improve coding style of auto usages 2020-06-03 20:48:19 +02:00
Song Yang 0b980e93b3 Change to c++ block comments 2020-03-18 15:10:45 -04:00