Commit Graph

483 Commits

Author SHA1 Message Date
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
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
Eric Vergnaud 559d526648 fix #3042 in Cpp runtime 2021-01-23 18:47:54 +08: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
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
Song Yang 575271020f Copy documentation to all non-Java languages 2020-03-17 16:03:29 -04:00
julibert b37d2e3815
Fix CMake packaging. 2020-02-09 20:01:24 +01:00
Steve Vinoski 38200b6e31 Fix #2727: improve setTokenFactory in Cpp target
Change the setTokenFactory template functions and the getTokenFactory
functions to use a plain pointer rather than a Ref. This makes the
caller of setTokenFactory responsible for managing the lifetime and
memory of the token factory instance they pass in. Change
CommonTokenFactory::DEFAULT to be a unique_ptr, and correct all places
using it as a Ref.
2020-01-24 08:11:41 -05:00
parrt 6ad9646382 update version in code to 4.8 2020-01-16 12:18:17 -08:00
Mike Lischke e47fd9d918 Brought back a lost comment and fixed a description. 2020-01-03 14:57:04 +01:00
Mike Lischke d295462e2e Doc update for C++ target and fixes for VS 2019 builds 2020-01-03 11:54:30 +01:00
Mike Lischke c487b1a580 Create pre-built binaries for VS 2017/19 instead of older VS versions 2020-01-03 09:01:13 +01:00
Markus Zancolo 1565143529
Merge branch 'master' into fix/CppEmscripten 2019-12-12 10:56:42 +01:00
Terence Parr 8be60804ab
Merge pull request #2532 from WalterCouto/test2
don't unnecessary fetch all tokens when grabbing an interval of text …
2019-12-11 08:48:54 -08:00
Felix Nieuwenhuizen 9029af3ef4 Fix for CMake 3.14 2019-11-17 14:09:35 +01:00
Gerasimos Dimitriadis 437c5a7b9a
Merge branch 'master' into master 2019-11-14 23:52:19 +02:00
jerry_liu fa4b498fc2 Add pretty print AST 2019-11-11 21:33:04 +08:00
Alexei Averchenko 4f86ad5c17
Merge branch 'master' into master 2019-10-31 18:15:30 +03:00