Merge branch 'master-upstream'

This commit is contained in:
Mike Lischke 2021-03-09 09:44:28 +01:00
commit faa64fdfa7
11 changed files with 45 additions and 39 deletions

View File

@ -55,7 +55,7 @@ import java.util.Set;
name = "antlr4",
defaultPhase = LifecyclePhase.GENERATE_SOURCES,
requiresDependencyResolution = ResolutionScope.COMPILE,
requiresProject = true)
requiresProject = true, threadSafe = true)
public class Antlr4Mojo extends AbstractMojo {
// First, let's deal with the options that the ANTLR tool itself

View File

@ -286,3 +286,7 @@ YYYY/MM/DD, github id, Full name, email
2020/12/03, electrum, David Phillips, david@acz.org
2021/01/25, l215884529, Qiheng Liu, 13607681+l215884529@users.noreply.github.com
2021/02/02, tsotnikov, Taras Sotnikov, taras.sotnikov@gmail.com
2021/02/21, namasikanam, Xingyu Xie, namasikanam@gmail.com
2021/02/27, khmarbaise, Karl Heinz Marbaise, github@soebes.com
2021/03/02, hackeris
2021/03/03, xTachyon, Damian Andrei, xTachyon@users.noreply.github.com

View File

@ -36,7 +36,7 @@ using Antlr4.Runtime.Tree;
public void MyParseMethod() {
String input = "your text to parse here";
ICharStream stream = CharStreams.fromstring(input);
ICharStream stream = CharStreams.fromString(input);
ITokenSource lexer = new MyGrammarLexer(stream);
ITokenStream tokens = new CommonTokenStream(lexer);
MyGrammarParser parser = new MyGrammarParser(tokens);

View File

@ -91,7 +91,7 @@ Now a fully functioning script might look like the following:
```javascript
import antlr4 from 'antlr4';
import MyGrammarLexer from './MyGrammarLexer.js');
import MyGrammarLexer from './MyGrammarLexer.js';
import MyGrammarParser from './MyGrammarParser.js';
import MyGrammarListener from './MyGrammarListener.js';

View File

@ -76,8 +76,13 @@ endif()
# Initialize CXXFLAGS.
if("${CMAKE_VERSION}" VERSION_GREATER 3.1.0)
set(CMAKE_CXX_STANDARD 11)
if(NOT DEFINED CMAKE_CXX_STANDARD)
# only set CMAKE_CXX_STANDARD if not already set
# this allows the standard to be set by the caller, for example with -DCMAKE_CXX_STANDARD:STRING=17
set(CMAKE_CXX_STANDARD 11)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11")

View File

@ -40,6 +40,7 @@ The minimum C++ version to compile the ANTLR C++ runtime with is C++11. The supp
Include the antlr4-runtime.h umbrella header in your target application to get everything needed to use the library.
If you are compiling with cmake, the minimum version required is cmake 2.8.
By default, the libraries produced by the CMake build target C++11. If you want to target a different C++ standard, you can explicitly pass the standard - e.g. `-DCMAKE_CXX_STANDARD=17`.
#### Compiling on Windows with Visual Studio using he Visual Studio projects
Simply open the VS project from the runtime folder (VS 2013+) and build it.
@ -69,5 +70,3 @@ If the CMake variable 'ANTLR4_INSTALL' is set, CMake Packages will be build and
They expose two packages: antlr4_runtime and antlr4_generator which can be referenced to ease up the use of the
ANTLR Generator and runtime.
Use and Sample can be found [here](cmake/Antlr4Package.md)

View File

@ -88,6 +88,8 @@ if(ANTLR4_ZIP_REPOSITORY)
CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DWITH_STATIC_CRT:BOOL=${ANTLR4_WITH_STATIC_CRT}
# -DCMAKE_CXX_STANDARD:STRING=17 # if desired, compile the runtime with a different C++ standard
# -DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD} # alternatively, compile the runtime with the same C++ standard as the outer project
INSTALL_COMMAND ""
EXCLUDE_FROM_ALL 1)
else()
@ -104,6 +106,8 @@ else()
CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DWITH_STATIC_CRT:BOOL=${ANTLR4_WITH_STATIC_CRT}
# -DCMAKE_CXX_STANDARD:STRING=17 # if desired, compile the runtime with a different C++ standard
# -DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD} # alternatively, compile the runtime with the same C++ standard as the outer project
INSTALL_COMMAND ""
EXCLUDE_FROM_ALL 1)
endif()

View File

@ -129,6 +129,8 @@ The ANTLR C++ runtime source is downloaded from GitHub by default. However, user
Visual C++ compiler users may want to additionally define `ANTLR4_WITH_STATIC_CRT` before including the file. Set `ANTLR4_WITH_STATIC_CRT` to true if ANTLR4 C++ runtime library should be compiled with `/MT` flag, otherwise will be compiled with `/MD` flag. This variable has a default value of `OFF`. Changing `ANTLR4_WITH_STATIC_CRT` after building the library may require reinitialization of CMake or `clean` for the library to get rebuilt.
You may need to modify your local copy of ExternalAntlr4Cpp.cpp to modify some build settings. For example, to specify the C++ standard to use when building the runtime, add `-DCMAKE_CXX_STANDARD:STRING=17` to `CMAKE_CACHE_ARGS`.
### Examples
To build and link ANTLR4 static library to a target one may call:

View File

@ -422,8 +422,7 @@ static std::vector\<uint16_t> _serializedATN;
// Constructs the serialized ATN and writes init code for static member vars.
SerializedATN(model) ::= <<
<if (rest(model.segments))>
<model.segments: {segment | static uint16_t serializedATNSegment<i0>[] = {
<model.segments: {segment | static const uint16_t serializedATNSegment<i0>[] = {
<segment; wrap={<\n> }>
\};}; separator="\n">
@ -431,13 +430,6 @@ SerializedATN(model) ::= <<
serializedATNSegment<i0> + sizeof(serializedATNSegment<i0>) / sizeof(serializedATNSegment<i0>[0]));
}>
<else>
<! only one segment, can be inlined !>
_serializedATN = {
<model.serialized; wrap = {<\n>}>
};
<endif>
atn::ATNDeserializer deserializer;
_atn = deserializer.deserialize(_serializedATN);