Commit Graph

463 Commits

Author SHA1 Message Date
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
Mike Lischke 3ae5d90296 Fixed an error regarding wrong unique_ptr usage
Also added VS 2019 project files.
2019-10-30 13:35:22 +01:00
Mike Lischke 4d649fbf71 Another attempt at solving this issue
There was already a patch to fix this issue, but it had some problems and was closed by the author after a while.
2019-10-11 14:47:39 +02:00
Mike Lischke 9723e4b9c9 C++ code cleanup
Converted back all TO_DO items to TODO (they were renamed ANTLR4 TODO items, but I had some for C++ which I all wanted to fix).
Also removed some default copy assignment operators which clang warned about.
2019-10-11 14:44:53 +02:00
Mike Lischke 91a50749f9 Added cmake build informations as reported in antlr4/#2606 2019-08-21 10:34:21 +02:00
Mike Lischke d93857c8fe Applied recommended settings after XCode upgrade. 2019-08-18 12:27:50 +02:00
Mike Lischke 8651498f41 Merge branch 'master-upstream' 2019-08-18 11:18:41 +02:00
olowo726 06cee866d2 Made converters thread_local instead of local to function for performance 2019-07-11 19:20:20 +02:00
Thomas c57996e589 Fix formating 2019-05-14 08:56:48 +02:00
Thomas 264db10290 Revert "Typo fix in XPath #2464"
This reverts commit d9c51b1525.
2019-05-13 22:38:49 +02:00
Thomas f3184e9c8d Align overlap condition on java implementation 2019-05-13 22:19:19 +02:00
Thomas d9c51b1525 Typo fix in XPath #2464 2019-05-08 15:01:31 +02:00
WalterCouto 31f4dcc7cf don't unnecessary fetch all tokens when grabbing an interval of text (match C# logic)
When an exception is thrown, it calls getText to get the text of the tokens invloved but the current C++ and Java implemention first fetches the rest of the tokens instead of  just using the tokens it already has.  C#'s version is correct (fill() is called only when asking for the entire stream's text).
2019-04-17 20:10:37 -04:00
Alexei Averchenko 4cf4883514 Fixed -Wreorder warning 2019-04-09 09:20:04 +03:00
Gerasimos Dimitriadis d69e7c4d0f Avoid double deletion when NoViableAltException is thrown
When ownership of the configurations set is passed to a NoViableAltException,
it get deleted more than once if the exception happens to get copied.
2019-02-23 20:31:19 +02:00
Markus Zancolò 4fec5f9f7c fix cpp cmake for emscripten
Emscripten can do C++11. added it to the compilercheck in CMakeLists
2019-01-16 14:55:03 +01:00
Mike Lischke ec665c1b90 A small fix in the C++ documentation. 2019-01-03 10:39:59 +01:00
Terence Parr 6808f9c4b4
Merge pull request #2447 from WalterCouto/test2
Change bitset upperbound to another higher arbitrary value to allow f…
2018-12-26 09:26:13 -07:00
Terence Parr fa19ded837
Merge pull request #2446 from WalterCouto/test
C++ avoid warning in visual studio build due to clang specific directive
2018-12-21 12:01:22 -07:00
Terence Parr fa466c42a1
Merge pull request #2445 from WalterCouto/master
C++: fix bug in PredictionContext::mergeArrays
2018-12-21 12:01:08 -07:00