Skip to content

Commit

Permalink
Merge pull request #3889 from 1sand0s/Fixing_Reserve_Word_NULL_for_Cp…
Browse files Browse the repository at this point in the history
…p_Targets

Fixing reserve word NULL for cpp targets
  • Loading branch information
parrt authored Oct 13, 2022
2 parents 2703a85 + 8951b56 commit d685f7b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[notes]
https://github.com/antlr/antlr4/pull/3889

[type]
Lexer

[grammar]
lexer grammar L;

NULL : ('N' | 'n')('U' | 'u')('L' | 'l')('L' | 'l') ;

[input]
NULL

[output]
[@0,0:3='NULL',<1>,1:0]
[@1,4:3='<EOF>',<-1>,1:4]
4 changes: 2 additions & 2 deletions runtime/Cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ The C++ target has been the work of the following people:

### Build + Usage Notes

The minimum C++ version to compile the ANTLR C++ runtime with is C++11. The supplied projects can built the runtime either as static or dynamic library, as both 32bit and 64bit arch. The macOS project contains a target for iOS and can also be built using cmake (instead of XCode).
The minimum C++ version to compile the ANTLR C++ runtime with is C++17. The supplied projects can built the runtime either as static or dynamic library, as both 32bit and 64bit arch. The macOS project contains a target for iOS and can also be built using cmake (instead of XCode).

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`.
By default, the libraries produced by the CMake build target C++17. 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 2019+) and build it.
Expand Down
2 changes: 1 addition & 1 deletion tool/src/org/antlr/v4/codegen/Target.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ protected void genFile(Grammar g, ST outputFileST, String fileName)
* to a token type in the generated code.
*/
public String getTokenTypeAsTargetLabel(Grammar g, int ttype) {
String name = g.getTokenName(ttype);
String name = this.escapeIfNeeded(g.getTokenName(ttype));
// If name is not valid, return the token type instead
if ( Grammar.INVALID_TOKEN_NAME.equals(name) ) {
return String.valueOf(ttype);
Expand Down
2 changes: 1 addition & 1 deletion tool/src/org/antlr/v4/codegen/model/Recognizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Recognizer(OutputModelFactory factory) {
for (Map.Entry<String, Integer> entry : g.tokenNameToTypeMap.entrySet()) {
Integer ttype = entry.getValue();
if ( ttype>0 ) {
tokens.put(entry.getKey(), ttype);
tokens.put(gen.getTarget().escapeIfNeeded(entry.getKey()), ttype);
}
}

Expand Down
4 changes: 2 additions & 2 deletions tool/src/org/antlr/v4/codegen/target/CppTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public class CppTarget extends Target {
"double", "dynamic_cast", "else", "enum", "explicit", "export",
"extern", "false", "float", "for", "friend", "goto", "if",
"inline", "int", "long", "mutable", "namespace", "new",
"noexcept", "not", "not_eq", "nullptr", "operator", "or",
"noexcept", "not", "not_eq", "nullptr", "NULL", "operator", "or",
"or_eq", "private", "protected", "public", "register",
"reinterpret_cast", "requires", "return", "short", "signed",
"sizeof", "static", "static_assert", "static_cast", "struct",
"switch", "template", "this", "thread_local", "throw", "true",
"try", "typedef", "typeid", "typename", "union", "unsigned",
"using", "virtual", "void", "volatile", "wchar_t", "while",
"xor", "xor_eq",
"xor", "xor_eq",

"rule", "parserRule"
));
Expand Down

0 comments on commit d685f7b

Please sign in to comment.