diff --git a/runtime/Cpp/CMakeLists.txt b/runtime/Cpp/CMakeLists.txt new file mode 100644 index 000000000..8b766ed1f --- /dev/null +++ b/runtime/Cpp/CMakeLists.txt @@ -0,0 +1,126 @@ +cmake_minimum_required (VERSION 2.8) +# 2.8 needed because of ExternalProject + +# Detect build type, fallback to release and throw a warning if use didn't specify any +if(NOT CMAKE_BUILD_TYPE) + message(WARNING "Build type not set, falling back to Release mode. + To specify build type use: + -DCMAKE_BUILD_TYPE= where is Debug or Release.") + set(CMAKE_BUILD_TYPE "Release" CACHE STRING + "Choose the type of build, options are: Debug Release." + FORCE) +endif(NOT CMAKE_BUILD_TYPE) + +if(NOT WITH_DEMO) + message(STATUS "Building without demo. To enable demo build use: -DWITH_DEMO=True") + set(WITH_DEMO False CACHE STRING + "Chose to build with or without demo executable" + FORCE) +endif(NOT WITH_DEMO) + +project(LIBANTLR4) + +if(CMAKE_VERSION VERSION_EQUAL "3.0.0" OR + CMAKE_VERSION VERSION_GREATER "3.0.0") + CMAKE_POLICY(SET CMP0026 OLD) + CMAKE_POLICY(SET CMP0045 OLD) + CMAKE_POLICY(SET CMP0042 OLD) + CMAKE_POLICY(SET CMP0059 OLD) +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Linux") + find_package(PkgConfig REQUIRED) + pkg_check_modules(UUID REQUIRED uuid) +endif() +if(APPLE) + find_library(COREFOUNDATION_LIBRARY CoreFoundation) +endif() + +find_package(Java REQUIRED) + +file(STRINGS "VERSION" ANTLR_VERSION) + +if (NOT ANTLR_JAR_LOCATION) + message(FATAL_ERROR "Missing antlr4.jar location. You can specify it's path using: -DANTLR_JAR_LOCATION=") +else() + get_filename_component(ANTLR_NAME ${ANTLR_JAR_LOCATION} NAME_WE) + if(NOT EXISTS "${ANTLR_JAR_LOCATION}") + message(FATAL_ERROR "Unable to find ${ANTLR_NAME} in ${ANTLR_JAR_LOCATION}") + else() + message(STATUS "Found ${ANTLR_NAME}: ${ANTLR_JAR_LOCATION}") + endif() +endif() +set(MY_CXX_WARNING_FLAGS " -Wall -pedantic -W") + +# Initialize CXXFLAGS. +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 ${MY_CXX_WARNING_FLAGS}") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -std=c++11 ${MY_CXX_WARNING_FLAGS}") +set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -DNDEBUG -std=c++11 ${MY_CXX_WARNING_FLAGS}") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG -std=c++11 ${MY_CXX_WARNING_FLGAS}") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g -std=c++11 ${MY_CXX_WARNING_FLAGS}") + +# Compiler-specific C++11 activation. +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + execute_process( + COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) + if (NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7)) + message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.7 or greater.") + endif () +elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND APPLE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") +elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_SYSTEM_NAME MATCHES "Linux") + execute_process( + COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CLANG_VERSION) + if (NOT (CLANG_VERSION VERSION_GREATER 4.2.1 OR CLANG_VERSION VERSION_EQUAL 4.2.1)) + message(FATAL_ERROR "${PROJECT_NAME} requires clang 4.2.1 or greater.") + endif () +else () + message(FATAL_ERROR "Your C++ compiler does not support C++11.") +endif () + + +#==== macro for pch creation +# taken from: https://cmake.org/pipermail/cmake/2006-December/012323.html +MACRO(ADD_PRECOMPILED_HEADER _targetName _input ) + GET_FILENAME_COMPONENT(_name ${_input} NAME) + SET(_source "${_input}") + SET(_outdir "${CMAKE_CURRENT_BINARY_DIR}/${_name}.gch") + MAKE_DIRECTORY(${_outdir}) + SET(_output "${_outdir}/${CMAKE_BUILD_TYPE}.c++") + STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name) + SET(_compiler_FLAGS ${${_flags_var_name}}) + + GET_DIRECTORY_PROPERTY(_directory_flags INCLUDE_DIRECTORIES) + FOREACH(item ${_directory_flags}) + LIST(APPEND _compiler_FLAGS "-I${item}") + ENDFOREACH(item) + + GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS) + LIST(APPEND _compiler_FLAGS ${_directory_flags}) + + SEPARATE_ARGUMENTS(_compiler_FLAGS) + ADD_CUSTOM_COMMAND( + OUTPUT ${_output} + COMMAND ${CMAKE_CXX_COMPILER} + ${_compiler_FLAGS} + -x c++-header + -o ${_output} ${_source} + DEPENDS ${_source} ) + ADD_CUSTOM_TARGET(${_targetName}_gch DEPENDS ${_output}) + ADD_DEPENDENCIES(${_targetName} ${_targetName}_gch) + #SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-include ${_name} -Winvalid-pch -H") + #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include ${_name} -Winvalid-pch") + SET_TARGET_PROPERTIES(${_targetName} PROPERTIES + COMPILE_FLAGS "-include ${_name} -Winvalid-pch" + ) + +ENDMACRO(ADD_PRECOMPILED_HEADER) +#==== end of macro for pch creation + +add_subdirectory(runtime) +if (WITH_DEMO) + add_subdirectory(demo) +endif(WITH_DEMO) + +install(FILES License.txt README.md VERSION + DESTINATION "share/doc/libantlr4") diff --git a/runtime/Cpp/VERSION b/runtime/Cpp/VERSION new file mode 100644 index 000000000..fcdb2e109 --- /dev/null +++ b/runtime/Cpp/VERSION @@ -0,0 +1 @@ +4.0.0 diff --git a/runtime/Cpp/demo/CMakeLists.txt b/runtime/Cpp/demo/CMakeLists.txt new file mode 100644 index 000000000..e158d7743 --- /dev/null +++ b/runtime/Cpp/demo/CMakeLists.txt @@ -0,0 +1,60 @@ +if(NOT UNIX) + message(FATAL "Unsupported operating system") +endif() + + +add_custom_target(GenerateParser + COMMAND + ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/demo/generated/ + COMMAND + "${Java_JAVA_EXECUTABLE}" -jar ${ANTLR_JAR_LOCATION} -Dlanguage=Cpp -listener -visitor -o ${PROJECT_SOURCE_DIR}/demo/generated/ -package antlrcpptest ${PROJECT_SOURCE_DIR}/demo/TLexer.g4 ${PROJECT_SOURCE_DIR}/demo/TParser.g4 + WORKING_DIRECTORY + "${CMAKE_BINARY_DIR}") + + + +include_directories( + ${PROJECT_SOURCE_DIR}/runtime/src + ${PROJECT_SOURCE_DIR}/runtime/src/misc + ${PROJECT_SOURCE_DIR}/runtime/src/atn + ${PROJECT_SOURCE_DIR}/runtime/src/dfa + ${PROJECT_SOURCE_DIR}/runtime/src/tree + ${PROJECT_SOURCE_DIR}/runtime/src/support + ${PROJECT_SOURCE_DIR}/demo/generated + ) + + +#file(GLOB antlr4-demo_SRC "${PROJECT_SOURCE_DIR}/demo/generated/*") +set(antlr4-demo_SRC + Linux/main.cpp + ${PROJECT_SOURCE_DIR}/demo/generated/TLexer.cpp + ${PROJECT_SOURCE_DIR}/demo/generated/TParser.cpp + ${PROJECT_SOURCE_DIR}/demo/generated/TParserBaseListener.cpp + ${PROJECT_SOURCE_DIR}/demo/generated/TParserBaseVisitor.cpp + ${PROJECT_SOURCE_DIR}/demo/generated/TParserListener.cpp + ${PROJECT_SOURCE_DIR}/demo/generated/TParserVisitor.cpp + ) + +add_executable(antlr4-demo + ${antlr4-demo_SRC} + ) +add_precompiled_header(antlr4-demo ${PROJECT_SOURCE_DIR}/runtime/src/antlrcpp-Prefix.h) + +add_dependencies(antlr4-demo GenerateParser) + +target_link_libraries(antlr4-demo antlr4_static) + +#foreach(src ${antlr4-demo_SRC}) +# get_source_file_property(old_compile_flags ${src} COMPILE_FLAGS) +# if(old_compile_flags STREQUAL "NOTFOUND") +# set(old_compile_flags "") +# endif() +# set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS +# "${old_compile_flags} -include \"${PROJECT_SOURCE_DIR}/runtime/src/antlrcpp-Prefix.h\"") +#endforeach() + +install(TARGETS antlr4-demo + DESTINATION "share" + COMPONENT dev + ) + diff --git a/runtime/Cpp/demo/Linux/Makefile b/runtime/Cpp/demo/Linux/Makefile deleted file mode 100644 index d42310b40..000000000 --- a/runtime/Cpp/demo/Linux/Makefile +++ /dev/null @@ -1,141 +0,0 @@ -# [The "BSD license"] -# Copyright (c) 2015 Dan McLaughlin -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. The name of the author may not be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -LINUXROT:= `pwd` # doh -RUNTIME := ../org/antlr/v4/runtime -OBJDIR := obj - -# Stop on any error or warning, comment out if you want to blast through -NUMERRORS := -Werror - -# Another possibility -# NUMERRORS := -fmax-errors=5 - -CC := ./g++ -CFLAGS := -fPIC -shared -g -O3 -Wall -std=c++11 $(NUMERRORS) -LDFLAGS := -IFLAGS :=-I../antlrcpp -I. -I $(RUNTIME) -I $(RUNTIME)/atn -I $(RUNTIME)/dfa \ - -I $(RUNTIME)/misc -I $(RUNTIME)/tree -I $(RUNTIME)/tree/pattern \ - -I $(RUNTIME)/tree/xpath -NAME := ANTLR4 -MAJOR := 0 -MINOR := 1 -VERSION := $(MAJOR).$(MINOR) - -DFA := $(RUNTIME)/dfa -MISC := $(RUNTIME)/misc -TREE := $(RUNTIME)/tree -TREEPAT := $(TREE)/pattern -XPATH := $(TREE)/xpath - -RUNTIMESRC := $(wildcard $(RUNTIME)/*.cpp) -RUNTIMEOBJ := $(patsubst %.cpp,%.o,$(RUNTIMESRC)) -DFASRC := $(wildcard $(DFA)/*.cpp) -DFAOBJ := $(patsubst %.cpp,%.o,$(DFASRC)) -MISCSRC := $(wildcard $(MISC)/*.cpp) -MISCOBJ := $(patsubst %.cpp,%.o,$(MISCSRC)) -TREESRC := $(wildcard $(TREE)/*.cpp) -TREEOBJ := $(patsubst %.cpp,%.o,$(TREESRC)) -TREEPATSRC := $(wildcard $(TREEPAT)/*.cpp) -TREEPATOBJ := $(patsubst %.cpp,%.o,$(TREEPATSRC)) -XPATHSRC := $(wildcard $(XPATH)/*.cpp) -XPATHOBJ := $(patsubst %.cpp,%.o,$(XPATHSRC)) - -OBJS := $(notdir $(RUNTIMEOBJ) $(DFAOBJ) $(MISCOBJ) $(TREEOBJ) \ - $(TREEPATOBJ) $(XPATHOBJ) ) - -OBJECTS := $(addprefix $(OBJDIR)/,$(OBJS)) - -SOURCES := $(RUNTIMESRC) $(DFASRC) $(MISCSRC) $(TREESRC) $(TREEPATSRC) $(XPATHSRC) - -LIB := lib$(NAME).so.$(VERSION) - -all: $(LIB) - -$(LIB): $(OBJECTS) - $(CC) -shared -Wl,-soname,lib$(NAME).so.$(MAJOR) $^ -o $@ - -# pull in dependency info for *existing* .o files --include $(OBJECTS:.o=.d) - -# TODO: Is there a way to collapse all these into one line? It doesn't -# work if I do so -$(OBJDIR)/%.o : $(RUNTIME)/%.cpp - @set -e; rm -f $@; \ - $(CC) $(IFLAGS) $(CFLAGS) -o $@ -c $< - $(CC) $(IFLAGS) $(CFLAGS) -o $(subst .o,.d,$@) -MM $< - sed -i '1s/^/obj\//' $(subst .o,.d,$@) -# This is the GNU makefile canonical way of adding the dependency file generation -# to include regenerating when any of the dependencies change. However in our -# solution the dependency is always generated whenever a compilation occurs (as it should) -# so this is un-necessary -# sed -i 's,\($*\)\.o[ :]*,\1.o $(subst .o,.d,$@) : ,g' $(subst .o,.d,$@) - -$(OBJDIR)/%.o : $(DFA)/%.cpp - @set -e; rm -f $@; \ - $(CC) $(IFLAGS) $(CFLAGS) -o $@ -c $< - $(CC) $(IFLAGS) $(CFLAGS) -o $(subst .o,.d,$@) -MM $< - sed -i '1s/^/obj\//' $(subst .o,.d,$@) -# sed -i 's,\($*\)\.o[ :]*,\1.o $(subst .o,.d,$@) : ,g' $(subst .o,.d,$@) - -$(OBJDIR)/%.o : $(MISC)/%.cpp - @set -e; rm -f $@; \ - $(CC) $(IFLAGS) $(CFLAGS) -o $@ -c $< - $(CC) $(IFLAGS) $(CFLAGS) -o $(subst .o,.d,$@) -MM $< - sed -i '1s/^/obj\//' $(subst .o,.d,$@) -# sed -i 's,\($*\)\.o[ :]*,\1.o $(subst .o,.d,$@) : ,g' $(subst .o,.d,$@) - -$(OBJDIR)/%.o : $(TREE)/%.cpp - @set -e; rm -f $@; \ - $(CC) $(IFLAGS) $(CFLAGS) -o $@ -c $< - $(CC) $(IFLAGS) $(CFLAGS) -o $(subst .o,.d,$@) -MM $< - sed -i '1s/^/obj\//' $(subst .o,.d,$@) -# sed -i 's,\($*\)\.o[ :]*,\1.o $(subst .o,.d,$@) : ,g' $(subst .o,.d,$@) - -$(OBJDIR)/%.o : $(TREEPAT)/%.cpp - @set -e; rm -f $@; \ - $(CC) $(IFLAGS) $(CFLAGS) -o $@ -c $< - $(CC) $(IFLAGS) $(CFLAGS) -o $(subst .o,.d,$@) -MM $< - sed -i '1s/^/obj\//' $(subst .o,.d,$@) -# sed -i 's,\($*\)\.o[ :]*,\1.o $(subst .o,.d,$@) : ,g' $(subst .o,.d,$@) - -$(OBJDIR)/%.o : $(XPATH)/%.cpp - @set -e; rm -f $@; \ - $(CC) $(IFLAGS) $(CFLAGS) -o $@ -c $< - $(CC) $(IFLAGS) $(CFLAGS) -o $(subst .o,.d,$@) -MM $< - sed -i '1s/^/obj\//' $(subst .o,.d,$@) -# sed -i 's,\($*\)\.o[ :]*,\1.o $(subst .o,.d,$@) : ,g' $(subst .o,.d,$@) - -$(OBJECTS): | $(OBJDIR)/ - -$(OBJDIR): FORCE - mkdir -p $(OBJDIR) - -FORCE: - -clean: - $(RM) $(NAME)_test *.so* -fr obj diff --git a/runtime/Cpp/demo/Linux/codecvt b/runtime/Cpp/demo/Linux/codecvt deleted file mode 100644 index a17a28234..000000000 --- a/runtime/Cpp/demo/Linux/codecvt +++ /dev/null @@ -1,2 +0,0 @@ -#include -#include \ No newline at end of file diff --git a/runtime/Cpp/demo/Linux/color-gcc.pl b/runtime/Cpp/demo/Linux/color-gcc.pl deleted file mode 100755 index 3cc789970..000000000 --- a/runtime/Cpp/demo/Linux/color-gcc.pl +++ /dev/null @@ -1,254 +0,0 @@ -#! /usr/bin/perl -w - -# -# colorgcc -# -# Version: 1.3.2 -# -# $Id: colorgcc,v 1.10 1999/04/29 17:15:52 jamoyers Exp $ -# -# A wrapper to colorize the output from compilers whose messages -# match the "gcc" format. -# -# Requires the ANSIColor module from CPAN. -# -# Usage: -# -# In a directory that occurs in your PATH _before_ the directory -# where the compiler lives, create a softlink to colorgcc for -# each compiler you want to colorize: -# -# g++ -> colorgcc -# gcc -> colorgcc -# cc -> colorgcc -# etc. -# -# That's it. When "g++" is invoked, colorgcc is run instead. -# colorgcc looks at the program name to figure out which compiler to run. -# -# The default settings can be overridden with ~/.colorgccrc. -# See the comments in the sample .colorgccrc for more information. -# -# Note: -# -# colorgcc will only emit color codes if: -# -# (1) Its STDOUT is a tty and -# (2) the value of $TERM is not listed in the "nocolor" option. -# -# If colorgcc colorizes the output, the compiler's STDERR will be -# combined with STDOUT. Otherwise, colorgcc just passes the output from -# the compiler through without modification. -# -# Author: Jamie Moyers -# Started: April 20, 1999 -# Licence: GNU Public License -# -# Credits: -# -# I got the idea for this from a script called "color_cvs": -# color_cvs .03 Adrian Likins -# -# (Scott Harrington) -# Much improved handling of compiler command line arguments. -# exec compiler when not colorizing to preserve STDOUT, STDERR. -# Fixed my STDIN kludge. -# -# (Elias S. G. Carotti) -# Corrected handling of text like -DPACKAGE=\"Package\" -# Spotted return code bug. -# -# (Erwin S. Andreasen) -# (Steve Churchill) -# Return code bug fixes. -# -# (Rik Hemsley) -# Found STDIN bug. -# -# Changes: -# -# 1.3.2 Better handling of command line arguments to compiler. -# -# If we aren't colorizing output, we just exec the compiler which -# preserves the original STDOUT and STDERR. -# -# Removed STDIN kludge. STDIN being passed correctly now. -# -# 1.3.1 Added kludge to copy STDIN to the compiler's STDIN. -# -# 1.3.0 Now correctly returns (I hope) the return code of the compiler -# process as its own. -# -# 1.2.1 Applied patch to handle text similar to -DPACKAGE=\"Package\". -# -# 1.2.0 Added tty check. If STDOUT is not a tty, don't do color. -# -# 1.1.0 Added the "nocolor" option to turn off the color if the terminal type -# ($TERM) is listed. -# -# 1.0.0 Initial Version - -use Term::ANSIColor; -use IPC::Open3; - -sub initDefaults -{ - $compilerPaths{"gcc"} = "/usr/bin/gcc"; - $compilerPaths{"g++"} = "/usr/bin/g++"; - $compilerPaths{"cc"} = "/usr/bin/cc"; - $compilerPaths{"c++"} = "/usr/bin/c++"; - - $nocolor{"dumb"} = "true"; - - $colors{"srcColor"} = color("cyan"); - $colors{"introColor"} = color("blue"); - - $colors{"warningFileNameColor"} = color("yellow"); - $colors{"warningNumberColor"} = color("yellow"); - $colors{"warningMessageColor"} = color("yellow"); - - $colors{"errorFileNameColor"} = color("bold red"); - $colors{"errorNumberColor"} = color("bold red"); - $colors{"errorMessageColor"} = color("bold red"); -} - -sub loadPreferences -{ -# Usage: loadPreferences("filename"); - - my($filename) = @_; - - open(PREFS, "<$filename") || return; - - while() - { - next if (m/^\#.*/); # It's a comment. - next if (!m/(.*):\s*(.*)/); # It's not of the form "foo: bar". - - $option = $1; - $value = $2; - - if ($option =~ m/cc|c\+\+|gcc|g\+\+/) - { - $compilerPaths{$option} = $value; - } - elsif ($option eq "nocolor") - { - # The nocolor option lists terminal types, separated by - # spaces, not to do color on. - foreach $termtype (split(/\s+/, $value)) - { - $nocolor{$termtype} = "true"; - } - } - else - { - $colors{$option} = color($value); - } - } - close(PREFS); -} - -sub srcscan -{ -# Usage: srcscan($text, $normalColor) -# $text -- the text to colorize -# $normalColor -- The escape sequence to use for non-source text. - -# Looks for text between ` and ', and colors it srcColor. - - my($line, $normalColor) = @_; - - my($srcon) = color("reset") . $colors{"srcColor"}; - my($srcoff) = color("reset") . $normalColor; - - $line = $normalColor . $line; - - # This substitute replaces `foo' with `AfooB' where A is the escape - # sequence that turns on the the desired source color, and B is the - # escape sequence that returns to $normalColor. - $line =~ s/\`(.*?)\'/\`$srcon$1$srcoff\'/g; - - print($line, color("reset")); -} - -# -# Main program -# - -# Set up default values for colors and compilers. -initDefaults(); - -# Read the configuration file, if there is one. -$configFile = $ENV{"HOME"} . "/.colorgccrc"; -if (-f $configFile) -{ - loadPreferences($configFile); -} - -# Figure out which compiler to invoke based on our program name. -$0 =~ m%.*/(.*)$%; -$progName = $1 || $0; - -$compiler = $compilerPaths{$progName} || $compilerPaths{"gcc"}; - -# Get the terminal type. -$terminal = $ENV{"TERM"} || "dumb"; - -# If it's in the list of terminal types not to color, or if -# we're writing to something that's not a tty, don't do color. -if (! -t STDOUT || $nocolor{$terminal}) -{ - exec $compiler, @ARGV - or die("Couldn't exec"); -} - -# Keep the pid of the compiler process so we can get its return -# code and use that as our return code. -$compiler_pid = open3('<&STDIN', \*GCCOUT, '', $compiler, @ARGV); - -# Colorize the output from the compiler. -while() -{ - if (m/^(.*?):([0-9]+):(.*)$/) # filename:lineno:message - { - $field1 = $1 || ""; - $field2 = $2 || ""; - $field3 = $3 || ""; - - if ($field3 =~ m/\s+warning:.*/) - { - # Warning - print($colors{"warningFileNameColor"}, "$field1:", color("reset")); - print($colors{"warningNumberColor"}, "$field2:", color("reset")); - srcscan($field3, $colors{"warningMessageColor"}); - } - else - { - # Error - print($colors{"errorFileNameColor"}, "$field1:", color("reset")); - print($colors{"errorNumberColor"}, "$field2:", color("reset")); - srcscan($field3, $colors{"errorMessageColor"}); - } - print("\n"); - } - elsif (m/^(.*?):(.+):$/) # filename:message: - { - # No line number, treat as an "introductory" line of text. - srcscan($_, $colors{"introColor"}); - } - else # Anything else. - { - # Doesn't seem to be a warning or an error. Print normally. - print(color("reset"), $_); - } -} - -# Get the return code of the compiler and exit with that. -waitpid($compiler_pid, 0); -exit ($? >> 8); - - - - - diff --git a/runtime/Cpp/demo/Linux/g++ b/runtime/Cpp/demo/Linux/g++ deleted file mode 120000 index 744feee96..000000000 --- a/runtime/Cpp/demo/Linux/g++ +++ /dev/null @@ -1 +0,0 @@ -color-gcc.pl \ No newline at end of file diff --git a/runtime/Cpp/demo/Linux/main.cpp b/runtime/Cpp/demo/Linux/main.cpp new file mode 100644 index 000000000..0d91591c0 --- /dev/null +++ b/runtime/Cpp/demo/Linux/main.cpp @@ -0,0 +1,32 @@ +// +// main.cpp +// antlr4-cpp-demo +// +// Created by Mike Lischke on 13.03.16. +// + +#include + +#include "ANTLRInputStream.h" +#include "CommonTokenStream.h" +#include "TLexer.h" +#include "TParser.h" + +#include "Strings.h" + +using namespace antlrcpptest; +using namespace org::antlr::v4::runtime; + +int main(int argc, const char * argv[]) { + + ANTLRInputStream input(L"(((x))) * y + z; a + (x * (y ? 0 : 1) + z);"); + TLexer lexer(&input); + CommonTokenStream tokens(&lexer); + + TParser parser(&tokens); + Ref tree = parser.main(); + + std::cout << antlrcpp::ws2s(tree->toStringTree(&parser)) << std::endl; + + return 0; +} diff --git a/runtime/Cpp/demo/README.md b/runtime/Cpp/demo/README.md index a51071688..b3d9ad25b 100644 --- a/runtime/Cpp/demo/README.md +++ b/runtime/Cpp/demo/README.md @@ -8,5 +8,20 @@ A few steps are necessary to get this to work: - Open the generation script for your platform (generate.cmd for Windows, generate.sh for *nix/OSX) and update the LOCATION var to the actual name of the jar you downloaded. - Run the generation script. This will generate a test parser + lexer, along with listener + visitor classes in a subfolder named "generated". This is where the demo application looks for these files. - Open the project in the folder that matches your system. -- Compile and run. +- Compile (see below) and run. +Compiling on Windows +==================== +Simply open the VS solution (VS 2013+) and build it. + +Compiling on OSX +================ +Either open the included XCode project and build that or use the cmake compilation as described for linux. + +Compiling on Linux +================== +- cd /runtime/Cpp +- mkdir build && mkdir run && cd build +- cmake ..-DANTLR_JAR_LOCATION=full/path/to/antlr4-4.5.4-SNAPSHOT.jar -DWITH_DEMO=True +- make +- DESTDIR=/runtime/Cpp/run make install diff --git a/runtime/Cpp/runtime/CMakeLists.txt b/runtime/Cpp/runtime/CMakeLists.txt new file mode 100644 index 000000000..454b60dcf --- /dev/null +++ b/runtime/Cpp/runtime/CMakeLists.txt @@ -0,0 +1,60 @@ +include_directories( + ${PROJECT_SOURCE_DIR}/runtime/src + ${PROJECT_SOURCE_DIR}/runtime/src/atn + ${PROJECT_SOURCE_DIR}/runtime/src/dfa + ${PROJECT_SOURCE_DIR}/runtime/src/misc + ${PROJECT_SOURCE_DIR}/runtime/src/support + ${PROJECT_SOURCE_DIR}/runtime/src/tree + ${PROJECT_SOURCE_DIR}/runtime/src/tree/pattern + ${PROJECT_SOURCE_DIR}/runtime/src/tree/xpath +) + + +file(GLOB libantlrcpp_SRC + "${PROJECT_SOURCE_DIR}/runtime/src/*.cpp" + "${PROJECT_SOURCE_DIR}/runtime/src/atn/*.cpp" + "${PROJECT_SOURCE_DIR}/runtime/src/dfa/*.cpp" + "${PROJECT_SOURCE_DIR}/runtime/src/misc/*.cpp" + "${PROJECT_SOURCE_DIR}/runtime/src/support/*.cpp" + "${PROJECT_SOURCE_DIR}/runtime/src/tree/*.cpp" + "${PROJECT_SOURCE_DIR}/runtime/src/tree/pattern/*.cpp" +) + +add_library(antlr4_shared SHARED ${libantlrcpp_SRC}) +add_library(antlr4_static STATIC ${libantlrcpp_SRC}) +add_precompiled_header(antlr4_shared ${PROJECT_SOURCE_DIR}/runtime/src/antlrcpp-Prefix.h) +add_precompiled_header(antlr4_static ${PROJECT_SOURCE_DIR}/runtime/src/antlrcpp-Prefix.h) + +if(CMAKE_SYSTEM_NAME MATCHES "Linux") + target_link_libraries(antlr4_shared ${UUID_LIBRARIES}) + target_link_libraries(antlr4_static ${UUID_LIBRARIES}) +elseif(APPLE) +# target_link_libraries(antlr4 "-framework CoreFoundation") + target_link_libraries(antlr4_shared ${COREFOUNDATION_LIBRARY}) + target_link_libraries(antlr4_static ${COREFOUNDATION_LIBRARY}) + +endif() + +set_target_properties(antlr4_shared + PROPERTIES VERSION ${ANTLR_VERSION} + SOVERSION ${ANTLR_VERSION} + OUTPUT_NAME antlr4) + +set_target_properties(antlr4_static + PROPERTIES VERSION ${ANTLR_VERSION} + SOVERSION ${ANTLR_VERSION} + OUTPUT_NAME antlr4) + +install(TARGETS antlr4_shared + DESTINATION lib) +install(TARGETS antlr4_static + ARCHIVE DESTINATION lib) + +install(DIRECTORY "${PROJECT_SOURCE_DIR}/runtime/src/" + DESTINATION "include" + COMPONENT dev + FILES_MATCHING PATTERN "*.h" + ) + + + diff --git a/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj b/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj index e85edde0b..4a8222be2 100644 --- a/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj +++ b/runtime/Cpp/runtime/antlrcpp.xcodeproj/project.pbxproj @@ -869,7 +869,7 @@ 276E5C1A1CDB57AA003FF4B4 /* ArrayPredictionContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayPredictionContext.h; sourceTree = ""; }; 276E5C1B1CDB57AA003FF4B4 /* ATN.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ATN.cpp; sourceTree = ""; }; 276E5C1C1CDB57AA003FF4B4 /* ATN.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ATN.h; sourceTree = ""; }; - 276E5C1D1CDB57AA003FF4B4 /* ATNConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ATNConfig.cpp; sourceTree = ""; }; + 276E5C1D1CDB57AA003FF4B4 /* ATNConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ATNConfig.cpp; sourceTree = ""; wrapsLines = 0; }; 276E5C1E1CDB57AA003FF4B4 /* ATNConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ATNConfig.h; sourceTree = ""; }; 276E5C1F1CDB57AA003FF4B4 /* ATNConfigSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ATNConfigSet.cpp; sourceTree = ""; }; 276E5C201CDB57AA003FF4B4 /* ATNConfigSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ATNConfigSet.h; sourceTree = ""; }; @@ -914,7 +914,7 @@ 276E5C471CDB57AA003FF4B4 /* LexerActionExecutor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerActionExecutor.h; sourceTree = ""; }; 276E5C481CDB57AA003FF4B4 /* LexerActionType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerActionType.cpp; sourceTree = ""; }; 276E5C491CDB57AA003FF4B4 /* LexerActionType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerActionType.h; sourceTree = ""; }; - 276E5C4A1CDB57AA003FF4B4 /* LexerATNConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerATNConfig.cpp; sourceTree = ""; }; + 276E5C4A1CDB57AA003FF4B4 /* LexerATNConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerATNConfig.cpp; sourceTree = ""; wrapsLines = 0; }; 276E5C4B1CDB57AA003FF4B4 /* LexerATNConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerATNConfig.h; sourceTree = ""; }; 276E5C4C1CDB57AA003FF4B4 /* LexerATNSimulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerATNSimulator.cpp; sourceTree = ""; }; 276E5C4D1CDB57AA003FF4B4 /* LexerATNSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerATNSimulator.h; sourceTree = ""; }; @@ -948,7 +948,7 @@ 276E5C6A1CDB57AA003FF4B4 /* OrderedATNConfigSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OrderedATNConfigSet.h; sourceTree = ""; }; 276E5C6B1CDB57AA003FF4B4 /* ParseInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParseInfo.cpp; sourceTree = ""; }; 276E5C6C1CDB57AA003FF4B4 /* ParseInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParseInfo.h; sourceTree = ""; }; - 276E5C6D1CDB57AA003FF4B4 /* ParserATNSimulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParserATNSimulator.cpp; sourceTree = ""; }; + 276E5C6D1CDB57AA003FF4B4 /* ParserATNSimulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParserATNSimulator.cpp; sourceTree = ""; wrapsLines = 0; }; 276E5C6E1CDB57AA003FF4B4 /* ParserATNSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParserATNSimulator.h; sourceTree = ""; }; 276E5C6F1CDB57AA003FF4B4 /* PlusBlockStartState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlusBlockStartState.cpp; sourceTree = ""; }; 276E5C701CDB57AA003FF4B4 /* PlusBlockStartState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlusBlockStartState.h; sourceTree = ""; }; @@ -966,7 +966,7 @@ 276E5C7C1CDB57AA003FF4B4 /* PredictionMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PredictionMode.h; sourceTree = ""; }; 276E5C7D1CDB57AA003FF4B4 /* ProfilingATNSimulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProfilingATNSimulator.cpp; sourceTree = ""; }; 276E5C7E1CDB57AA003FF4B4 /* ProfilingATNSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProfilingATNSimulator.h; sourceTree = ""; }; - 276E5C7F1CDB57AA003FF4B4 /* RangeTransition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RangeTransition.cpp; sourceTree = ""; }; + 276E5C7F1CDB57AA003FF4B4 /* RangeTransition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RangeTransition.cpp; sourceTree = ""; wrapsLines = 0; }; 276E5C801CDB57AA003FF4B4 /* RangeTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RangeTransition.h; sourceTree = ""; }; 276E5C811CDB57AA003FF4B4 /* RuleStartState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuleStartState.cpp; sourceTree = ""; }; 276E5C821CDB57AA003FF4B4 /* RuleStartState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuleStartState.h; sourceTree = ""; }; @@ -994,7 +994,7 @@ 276E5C981CDB57AA003FF4B4 /* WildcardTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WildcardTransition.h; sourceTree = ""; }; 276E5C991CDB57AA003FF4B4 /* BailErrorStrategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BailErrorStrategy.cpp; sourceTree = ""; }; 276E5C9A1CDB57AA003FF4B4 /* BailErrorStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BailErrorStrategy.h; sourceTree = ""; }; - 276E5C9B1CDB57AA003FF4B4 /* BaseErrorListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseErrorListener.cpp; sourceTree = ""; }; + 276E5C9B1CDB57AA003FF4B4 /* BaseErrorListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseErrorListener.cpp; sourceTree = ""; wrapsLines = 0; }; 276E5C9C1CDB57AA003FF4B4 /* BaseErrorListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseErrorListener.h; sourceTree = ""; }; 276E5C9D1CDB57AA003FF4B4 /* BufferedTokenStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BufferedTokenStream.cpp; sourceTree = ""; }; 276E5C9E1CDB57AA003FF4B4 /* BufferedTokenStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BufferedTokenStream.h; sourceTree = ""; }; @@ -1006,7 +1006,7 @@ 276E5CA41CDB57AA003FF4B4 /* CommonTokenFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonTokenFactory.h; sourceTree = ""; }; 276E5CA51CDB57AA003FF4B4 /* CommonTokenStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommonTokenStream.cpp; sourceTree = ""; }; 276E5CA61CDB57AA003FF4B4 /* CommonTokenStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonTokenStream.h; sourceTree = ""; }; - 276E5CA71CDB57AA003FF4B4 /* ConsoleErrorListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConsoleErrorListener.cpp; sourceTree = ""; }; + 276E5CA71CDB57AA003FF4B4 /* ConsoleErrorListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConsoleErrorListener.cpp; sourceTree = ""; wrapsLines = 0; }; 276E5CA81CDB57AA003FF4B4 /* ConsoleErrorListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConsoleErrorListener.h; sourceTree = ""; }; 276E5CA91CDB57AA003FF4B4 /* DefaultErrorStrategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DefaultErrorStrategy.cpp; sourceTree = ""; }; 276E5CAA1CDB57AA003FF4B4 /* DefaultErrorStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultErrorStrategy.h; sourceTree = ""; }; @@ -1031,7 +1031,7 @@ 276E5CBE1CDB57AA003FF4B4 /* IntStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntStream.cpp; sourceTree = ""; }; 276E5CBF1CDB57AA003FF4B4 /* IntStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntStream.h; sourceTree = ""; }; 276E5CC01CDB57AA003FF4B4 /* IRecognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IRecognizer.h; sourceTree = ""; }; - 276E5CC11CDB57AA003FF4B4 /* Lexer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Lexer.cpp; sourceTree = ""; }; + 276E5CC11CDB57AA003FF4B4 /* Lexer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Lexer.cpp; sourceTree = ""; wrapsLines = 0; }; 276E5CC21CDB57AA003FF4B4 /* Lexer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Lexer.h; sourceTree = ""; }; 276E5CC31CDB57AA003FF4B4 /* LexerInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerInterpreter.cpp; sourceTree = ""; }; 276E5CC41CDB57AA003FF4B4 /* LexerInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerInterpreter.h; sourceTree = ""; }; @@ -1084,7 +1084,7 @@ 276E5CF51CDB57AA003FF4B4 /* TokenStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TokenStream.cpp; sourceTree = ""; }; 276E5CF61CDB57AA003FF4B4 /* TokenStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TokenStream.h; sourceTree = ""; }; 276E5CF71CDB57AA003FF4B4 /* TokenStreamRewriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TokenStreamRewriter.cpp; sourceTree = ""; }; - 276E5CF81CDB57AA003FF4B4 /* TokenStreamRewriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TokenStreamRewriter.h; sourceTree = ""; }; + 276E5CF81CDB57AA003FF4B4 /* TokenStreamRewriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TokenStreamRewriter.h; sourceTree = ""; wrapsLines = 0; }; 276E5CFA1CDB57AA003FF4B4 /* AbstractParseTreeVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractParseTreeVisitor.h; sourceTree = ""; }; 276E5CFB1CDB57AA003FF4B4 /* ErrorNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorNode.h; sourceTree = ""; }; 276E5CFC1CDB57AA003FF4B4 /* ErrorNodeImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorNodeImpl.cpp; sourceTree = ""; }; @@ -1104,13 +1104,13 @@ 276E5D0B1CDB57AA003FF4B4 /* ParseTreePattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParseTreePattern.h; sourceTree = ""; }; 276E5D0C1CDB57AA003FF4B4 /* ParseTreePatternMatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParseTreePatternMatcher.cpp; sourceTree = ""; }; 276E5D0D1CDB57AA003FF4B4 /* ParseTreePatternMatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParseTreePatternMatcher.h; sourceTree = ""; }; - 276E5D0E1CDB57AA003FF4B4 /* RuleTagToken.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuleTagToken.cpp; sourceTree = ""; }; + 276E5D0E1CDB57AA003FF4B4 /* RuleTagToken.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuleTagToken.cpp; sourceTree = ""; wrapsLines = 0; }; 276E5D0F1CDB57AA003FF4B4 /* RuleTagToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuleTagToken.h; sourceTree = ""; }; 276E5D101CDB57AA003FF4B4 /* TagChunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TagChunk.cpp; sourceTree = ""; }; 276E5D111CDB57AA003FF4B4 /* TagChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagChunk.h; sourceTree = ""; }; 276E5D121CDB57AA003FF4B4 /* TextChunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextChunk.cpp; sourceTree = ""; }; 276E5D131CDB57AA003FF4B4 /* TextChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextChunk.h; sourceTree = ""; }; - 276E5D141CDB57AA003FF4B4 /* TokenTagToken.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TokenTagToken.cpp; sourceTree = ""; }; + 276E5D141CDB57AA003FF4B4 /* TokenTagToken.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TokenTagToken.cpp; sourceTree = ""; wrapsLines = 0; }; 276E5D151CDB57AA003FF4B4 /* TokenTagToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TokenTagToken.h; sourceTree = ""; }; 276E5D161CDB57AA003FF4B4 /* RuleNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuleNode.h; sourceTree = ""; }; 276E5D171CDB57AA003FF4B4 /* SyntaxTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SyntaxTree.h; sourceTree = ""; }; @@ -2634,6 +2634,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_ASSIGN_ENUM = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; @@ -2641,6 +2642,8 @@ CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; ENABLE_TESTABILITY = YES; @@ -2655,11 +2658,16 @@ ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_LABEL = YES; + GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( src/, @@ -2682,6 +2690,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_ASSIGN_ENUM = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; @@ -2689,6 +2698,8 @@ CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -2697,11 +2708,16 @@ GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_PREFIX_HEADER = "src/antlrcpp-Prefix.h"; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_SIGN_COMPARE = YES; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_LABEL = YES; + GCC_WARN_UNUSED_PARAMETER = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( src/, diff --git a/runtime/Cpp/runtime/src/ANTLRErrorListener.h b/runtime/Cpp/runtime/src/ANTLRErrorListener.h index 15bdf9a86..61aa247d9 100755 --- a/runtime/Cpp/runtime/src/ANTLRErrorListener.h +++ b/runtime/Cpp/runtime/src/ANTLRErrorListener.h @@ -45,6 +45,8 @@ namespace runtime { /// How to emit recognition errors (an interface in Java). class ANTLR4CPP_PUBLIC ANTLRErrorListener { public: + virtual ~ANTLRErrorListener() {}; + /// /// Upon syntax error, notify any interested parties. This is not how to /// recover from errors or compute error messages. diff --git a/runtime/Cpp/runtime/src/ANTLRFileStream.cpp b/runtime/Cpp/runtime/src/ANTLRFileStream.cpp index c6eb2d3ca..3f349840d 100755 --- a/runtime/Cpp/runtime/src/ANTLRFileStream.cpp +++ b/runtime/Cpp/runtime/src/ANTLRFileStream.cpp @@ -41,7 +41,8 @@ ANTLRFileStream::ANTLRFileStream(const std::string &fileName, const std::string load(fileName, encoding); } -void ANTLRFileStream::load(const std::string &fileName, const std::string &encoding) { +void ANTLRFileStream::load(const std::string &fileName, const std::string &/*encoding*/) { + _fileName = fileName; if (_fileName.empty()) { return; } diff --git a/runtime/Cpp/runtime/src/ANTLRInputStream.cpp b/runtime/Cpp/runtime/src/ANTLRInputStream.cpp index b59317614..982a30fb3 100755 --- a/runtime/Cpp/runtime/src/ANTLRInputStream.cpp +++ b/runtime/Cpp/runtime/src/ANTLRInputStream.cpp @@ -132,7 +132,7 @@ ssize_t ANTLRInputStream::mark() { return -1; } -void ANTLRInputStream::release(ssize_t marker) { +void ANTLRInputStream::release(ssize_t /* marker */) { } void ANTLRInputStream::seek(size_t index) { diff --git a/runtime/Cpp/runtime/src/BailErrorStrategy.cpp b/runtime/Cpp/runtime/src/BailErrorStrategy.cpp index 32e313e99..95ad1e1c3 100755 --- a/runtime/Cpp/runtime/src/BailErrorStrategy.cpp +++ b/runtime/Cpp/runtime/src/BailErrorStrategy.cpp @@ -83,5 +83,5 @@ Ref BailErrorStrategy::recoverInline(Parser *recognizer) { #endif } -void BailErrorStrategy::sync(Parser *recognizer) { +void BailErrorStrategy::sync(Parser */*recognizer*/) { } diff --git a/runtime/Cpp/runtime/src/BaseErrorListener.cpp b/runtime/Cpp/runtime/src/BaseErrorListener.cpp index 1ee1322d8..7e549420c 100755 --- a/runtime/Cpp/runtime/src/BaseErrorListener.cpp +++ b/runtime/Cpp/runtime/src/BaseErrorListener.cpp @@ -34,18 +34,18 @@ using namespace org::antlr::v4::runtime; -void BaseErrorListener::syntaxError(IRecognizer *recognizer, Ref offendingSymbol, size_t line, int charPositionInLine, - const std::wstring &msg, std::exception_ptr e) { +void BaseErrorListener::syntaxError(IRecognizer */*recognizer*/, Ref /*offendingSymbol*/, size_t /*line*/, + int /*charPositionInLine*/, const std::wstring &/*msg*/, std::exception_ptr /*e*/) { } -void BaseErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, - bool exact, const antlrcpp::BitSet &ambigAlts, Ref configs) { +void BaseErrorListener::reportAmbiguity(Parser */*recognizer*/, const dfa::DFA &/*dfa*/, size_t /*startIndex*/, + size_t /*stopIndex*/, bool /*exact*/, const antlrcpp::BitSet &/*ambigAlts*/, Ref /*configs*/) { } -void BaseErrorListener::reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, - size_t stopIndex, const antlrcpp::BitSet &conflictingAlts, Ref configs) { +void BaseErrorListener::reportAttemptingFullContext(Parser */*recognizer*/, const dfa::DFA &/*dfa*/, size_t /*startIndex*/, + size_t /*stopIndex*/, const antlrcpp::BitSet &/*conflictingAlts*/, Ref /*configs*/) { } -void BaseErrorListener::reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, - int prediction, Ref configs) { +void BaseErrorListener::reportContextSensitivity(Parser */*recognizer*/, const dfa::DFA &/*dfa*/, size_t /*startIndex*/, + size_t /*stopIndex*/, int /*prediction*/, Ref /*configs*/) { } diff --git a/runtime/Cpp/runtime/src/BufferedTokenStream.cpp b/runtime/Cpp/runtime/src/BufferedTokenStream.cpp index 220a0b5dc..b2c162133 100755 --- a/runtime/Cpp/runtime/src/BufferedTokenStream.cpp +++ b/runtime/Cpp/runtime/src/BufferedTokenStream.cpp @@ -57,7 +57,7 @@ ssize_t BufferedTokenStream::mark() { return 0; } -void BufferedTokenStream::release(ssize_t marker) { +void BufferedTokenStream::release(ssize_t /*marker*/) { // no resources to release } diff --git a/runtime/Cpp/runtime/src/ConsoleErrorListener.cpp b/runtime/Cpp/runtime/src/ConsoleErrorListener.cpp index 9503b3a11..fa2c1dc43 100755 --- a/runtime/Cpp/runtime/src/ConsoleErrorListener.cpp +++ b/runtime/Cpp/runtime/src/ConsoleErrorListener.cpp @@ -35,7 +35,7 @@ using namespace org::antlr::v4::runtime; ConsoleErrorListener ConsoleErrorListener::INSTANCE; -void ConsoleErrorListener::syntaxError(IRecognizer *recognizer, Ref offendingSymbol, - size_t line, int charPositionInLine, const std::wstring &msg, std::exception_ptr e) { +void ConsoleErrorListener::syntaxError(IRecognizer */*recognizer*/, Ref /*offendingSymbol*/, + size_t line, int charPositionInLine, const std::wstring &msg, std::exception_ptr /*e*/) { std::wcerr << L"line " << line << L":" << charPositionInLine << L" " << msg << std::endl; } diff --git a/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp b/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp index ac4f69390..438edba05 100755 --- a/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp +++ b/runtime/Cpp/runtime/src/DefaultErrorStrategy.cpp @@ -52,15 +52,15 @@ void DefaultErrorStrategy::reset(Parser *recognizer) { endErrorCondition(recognizer); } -void DefaultErrorStrategy::beginErrorCondition(Parser *recognizer) { +void DefaultErrorStrategy::beginErrorCondition(Parser */*recognizer*/) { errorRecoveryMode = true; } -bool DefaultErrorStrategy::inErrorRecoveryMode(Parser *recognizer) { +bool DefaultErrorStrategy::inErrorRecoveryMode(Parser */*recognizer*/) { return errorRecoveryMode; } -void DefaultErrorStrategy::endErrorCondition(Parser *recognizer) { +void DefaultErrorStrategy::endErrorCondition(Parser */*recognizer*/) { errorRecoveryMode = false; lastErrorIndex = -1; } @@ -92,7 +92,7 @@ void DefaultErrorStrategy::reportError(Parser *recognizer, const RecognitionExce } } -void DefaultErrorStrategy::recover(Parser *recognizer, const RecognitionException &e) { +void DefaultErrorStrategy::recover(Parser *recognizer, const RecognitionException &/*e*/) { if (lastErrorIndex == (int)recognizer->getInputStream()->index() && lastErrorStates.contains(recognizer->getState())) { diff --git a/runtime/Cpp/runtime/src/DiagnosticErrorListener.cpp b/runtime/Cpp/runtime/src/DiagnosticErrorListener.cpp index 98f250e72..b914ca47d 100755 --- a/runtime/Cpp/runtime/src/DiagnosticErrorListener.cpp +++ b/runtime/Cpp/runtime/src/DiagnosticErrorListener.cpp @@ -62,7 +62,7 @@ void DiagnosticErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA } void DiagnosticErrorListener::reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, - size_t stopIndex, const antlrcpp::BitSet &conflictingAlts, Ref configs) { + size_t stopIndex, const antlrcpp::BitSet &/*conflictingAlts*/, Ref /*configs*/) { std::wstring decision = getDecisionDescription(recognizer, dfa); std::wstring text = recognizer->getTokenStream()->getText(misc::Interval((int)startIndex, (int)stopIndex)); std::wstring message = L"reportAttemptingFullContext d = " + decision + L", input = '" + text + L"'"; @@ -70,7 +70,7 @@ void DiagnosticErrorListener::reportAttemptingFullContext(Parser *recognizer, co } void DiagnosticErrorListener::reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, - size_t stopIndex, int prediction, Ref configs) { + size_t stopIndex, int /*prediction*/, Ref /*configs*/) { std::wstring decision = getDecisionDescription(recognizer, dfa); std::wstring text = recognizer->getTokenStream()->getText(misc::Interval((int)startIndex, (int)stopIndex)); std::wstring message = L"reportContextSensitivity d = " + decision + L", input = '" + text + L"'"; diff --git a/runtime/Cpp/runtime/src/IRecognizer.h b/runtime/Cpp/runtime/src/IRecognizer.h index 1d532bd0d..738e9612d 100644 --- a/runtime/Cpp/runtime/src/IRecognizer.h +++ b/runtime/Cpp/runtime/src/IRecognizer.h @@ -38,6 +38,7 @@ namespace runtime { class ANTLR4CPP_PUBLIC IRecognizer { public: + virtual ~IRecognizer() {}; virtual int getState() = 0; diff --git a/runtime/Cpp/runtime/src/IntStream.h b/runtime/Cpp/runtime/src/IntStream.h index 552df4d8c..58164fc30 100755 --- a/runtime/Cpp/runtime/src/IntStream.h +++ b/runtime/Cpp/runtime/src/IntStream.h @@ -65,6 +65,8 @@ namespace runtime { /// static const std::string UNKNOWN_SOURCE_NAME; + virtual ~IntStream() {}; + /// /// Consumes the current symbol in the stream. This method has the following /// effects: diff --git a/runtime/Cpp/runtime/src/Lexer.cpp b/runtime/Cpp/runtime/src/Lexer.cpp index 3298294ed..6fbd902a8 100755 --- a/runtime/Cpp/runtime/src/Lexer.cpp +++ b/runtime/Cpp/runtime/src/Lexer.cpp @@ -252,7 +252,7 @@ std::vector> Lexer::getAllTokens() { return tokens; } -void Lexer::recover(const LexerNoViableAltException &e) { +void Lexer::recover(const LexerNoViableAltException &/*e*/) { if (_input->LA(1) != EOF) { // skip a char and try again getInterpreter()->consume(_input); @@ -264,7 +264,8 @@ void Lexer::notifyListeners(const LexerNoViableAltException &e) { std::wstring msg = std::wstring(L"token recognition error at: '") + getErrorDisplay(text) + std::wstring(L"'"); ProxyErrorListener &listener = getErrorListenerDispatch(); - listener.syntaxError(this, nullptr, (size_t)_tokenStartLine, _tokenStartCharPositionInLine, msg, std::make_exception_ptr(e)); + listener.syntaxError(this, nullptr, (size_t)_tokenStartLine, _tokenStartCharPositionInLine, msg, + std::make_exception_ptr(e)); } std::wstring Lexer::getErrorDisplay(const std::wstring &s) { @@ -302,7 +303,7 @@ std::wstring Lexer::getCharErrorDisplay(int c) { return std::wstring(L"'") + s + std::wstring(L"'"); } -void Lexer::recover(RecognitionException *re) { +void Lexer::recover(RecognitionException */*re*/) { // TO_DO: Do we lose character or line position information? _input->consume(); } diff --git a/runtime/Cpp/runtime/src/ListTokenSource.h b/runtime/Cpp/runtime/src/ListTokenSource.h index e9d950e49..508e41d61 100755 --- a/runtime/Cpp/runtime/src/ListTokenSource.h +++ b/runtime/Cpp/runtime/src/ListTokenSource.h @@ -89,9 +89,10 @@ namespace runtime { /// if {@code tokens} is {@code null} public: - template //where T1 : Token - ListTokenSource(std::vector tokens) //this(tokens, nullptr); - {} + template + ListTokenSource(std::vector tokens) : ListTokenSource(tokens, "") { + } + /// /// Constructs a new instance from the specified /// collection of objects and source name. @@ -104,9 +105,8 @@ namespace runtime { /// been reached). /// /// if {@code tokens} is {@code null} - - template //where T1 : Token - ListTokenSource(std::vector tokens, const std::string &sourceName) { + template + ListTokenSource(std::vector tokens, const std::string &/*sourceName*/) { InitializeInstanceFields(); if (tokens.empty()) { throw L"tokens cannot be null"; diff --git a/runtime/Cpp/runtime/src/Parser.cpp b/runtime/Cpp/runtime/src/Parser.cpp index cc300b11c..299cb4e0d 100755 --- a/runtime/Cpp/runtime/src/Parser.cpp +++ b/runtime/Cpp/runtime/src/Parser.cpp @@ -74,7 +74,7 @@ void Parser::TraceListener::visitTerminal(Ref node) { << std::endl; } -void Parser::TraceListener::visitErrorNode(Ref node) { +void Parser::TraceListener::visitErrorNode(Ref /*node*/) { } void Parser::TraceListener::exitEveryRule(Ref ctx) { @@ -87,13 +87,13 @@ void Parser::TraceListener::exitEveryRule(Ref ctx) { const Ref Parser::TrimToSizeListener::INSTANCE = std::make_shared(); -void Parser::TrimToSizeListener::enterEveryRule(Ref ctx) { +void Parser::TrimToSizeListener::enterEveryRule(Ref /*ctx*/) { } -void Parser::TrimToSizeListener::visitTerminal(Ref node) { +void Parser::TrimToSizeListener::visitTerminal(Ref /*node*/) { } -void Parser::TrimToSizeListener::visitErrorNode(Ref node) { +void Parser::TrimToSizeListener::visitErrorNode(Ref /*node*/) { } void Parser::TrimToSizeListener::exitEveryRule(Ref ctx) { @@ -351,7 +351,7 @@ void Parser::addContextToParseTree() { parent->addChild(_ctx); } -void Parser::enterRule(Ref localctx, int state, int ruleIndex) { +void Parser::enterRule(Ref localctx, int state, int /*ruleIndex*/) { setState(state); _ctx = localctx; _ctx->start = _input->LT(1); @@ -407,7 +407,7 @@ void Parser::enterRecursionRule(Ref localctx, int ruleIndex) enterRecursionRule(localctx, getATN().ruleToStartState[(size_t)ruleIndex]->stateNumber, ruleIndex, 0); } -void Parser::enterRecursionRule(Ref localctx, int state, int ruleIndex, int precedence) { +void Parser::enterRecursionRule(Ref localctx, int state, int /*ruleIndex*/, int precedence) { setState(state); _precedenceStack.push_back(precedence); _ctx = localctx; @@ -417,7 +417,7 @@ void Parser::enterRecursionRule(Ref localctx, int state, int } } -void Parser::pushNewRecursionContext(Ref localctx, int state, int ruleIndex) { +void Parser::pushNewRecursionContext(Ref localctx, int state, int /*ruleIndex*/) { Ref previous = _ctx; previous->parent = localctx; previous->invokingState = state; @@ -479,11 +479,11 @@ void Parser::setContext(Ref ctx) { _ctx = ctx; } -bool Parser::precpred(Ref localctx, int precedence) { +bool Parser::precpred(Ref /*localctx*/, int precedence) { return precedence >= _precedenceStack.back(); } -bool Parser::inContext(const std::wstring &context) { +bool Parser::inContext(const std::wstring &/*context*/) { // TO_DO: useful in parser? return false; } diff --git a/runtime/Cpp/runtime/src/Parser.h b/runtime/Cpp/runtime/src/Parser.h index 84df7e3b5..e09656a94 100755 --- a/runtime/Cpp/runtime/src/Parser.h +++ b/runtime/Cpp/runtime/src/Parser.h @@ -64,6 +64,8 @@ namespace runtime { public: static const Ref INSTANCE; + virtual ~TrimToSizeListener() {}; + virtual void enterEveryRule(Ref ctx) override; virtual void visitTerminal(Ref node) override; virtual void visitErrorNode(Ref node) override; diff --git a/runtime/Cpp/runtime/src/ParserRuleContext.cpp b/runtime/Cpp/runtime/src/ParserRuleContext.cpp index b8cdc5519..a8bd0af8f 100755 --- a/runtime/Cpp/runtime/src/ParserRuleContext.cpp +++ b/runtime/Cpp/runtime/src/ParserRuleContext.cpp @@ -56,10 +56,10 @@ ParserRuleContext::ParserRuleContext(std::weak_ptr parent, in : RuleContext(parent, invokingStateNumber) { } -void ParserRuleContext::enterRule(Ref listener) { +void ParserRuleContext::enterRule(Ref /*listener*/) { } -void ParserRuleContext::exitRule(Ref listener) { +void ParserRuleContext::exitRule(Ref /*listener*/) { } Ref ParserRuleContext::addChild(Ref t) { diff --git a/runtime/Cpp/runtime/src/RecognitionException.cpp b/runtime/Cpp/runtime/src/RecognitionException.cpp index 1d73d63fe..e603e6682 100755 --- a/runtime/Cpp/runtime/src/RecognitionException.cpp +++ b/runtime/Cpp/runtime/src/RecognitionException.cpp @@ -46,7 +46,7 @@ RecognitionException::RecognitionException(IRecognizer *recognizer, IntStream *i RecognitionException::RecognitionException(const std::string &message, IRecognizer *recognizer, IntStream *input, Ref ctx, Ref offendingToken) - : RuntimeException(message), _recognizer(recognizer), _input(input), _offendingToken(offendingToken), _ctx(ctx) { + : RuntimeException(message), _recognizer(recognizer), _input(input), _ctx(ctx), _offendingToken(offendingToken) { InitializeInstanceFields(); if (recognizer != nullptr) { _offendingState = recognizer->getState(); diff --git a/runtime/Cpp/runtime/src/Recognizer.cpp b/runtime/Cpp/runtime/src/Recognizer.cpp index 3c7a949a0..f1d398b48 100755 --- a/runtime/Cpp/runtime/src/Recognizer.cpp +++ b/runtime/Cpp/runtime/src/Recognizer.cpp @@ -167,15 +167,15 @@ ProxyErrorListener& Recognizer::getErrorListenerDispatch() { return _proxListener; } -bool Recognizer::sempred(Ref localctx, int ruleIndex, int actionIndex) { +bool Recognizer::sempred(Ref /*localctx*/, int /*ruleIndex*/, int /*actionIndex*/) { return true; } -bool Recognizer::precpred(Ref localctx, int precedence) { +bool Recognizer::precpred(Ref /*localctx*/, int /*precedence*/) { return true; } -void Recognizer::action(Ref localctx, int ruleIndex, int actionIndex) { +void Recognizer::action(Ref /*localctx*/, int /*ruleIndex*/, int /*actionIndex*/) { } int Recognizer::getState() { diff --git a/runtime/Cpp/runtime/src/Recognizer.h b/runtime/Cpp/runtime/src/Recognizer.h index ea8cd6c15..b358b406f 100755 --- a/runtime/Cpp/runtime/src/Recognizer.h +++ b/runtime/Cpp/runtime/src/Recognizer.h @@ -42,6 +42,7 @@ namespace runtime { class ANTLR4CPP_PUBLIC Recognizer : public IRecognizer { public: Recognizer(); + virtual ~Recognizer() {}; /** Used to print out token names like ID during debugging and * error reporting. The generated parsers implement a method diff --git a/runtime/Cpp/runtime/src/RuleContext.cpp b/runtime/Cpp/runtime/src/RuleContext.cpp index fccad4622..d188ef194 100755 --- a/runtime/Cpp/runtime/src/RuleContext.cpp +++ b/runtime/Cpp/runtime/src/RuleContext.cpp @@ -98,7 +98,7 @@ ssize_t RuleContext::getRuleIndex() const { return -1; } -Ref RuleContext::getChildReference(size_t i) { +Ref RuleContext::getChildReference(size_t /*i*/) { return Ref(); } @@ -107,7 +107,7 @@ int RuleContext::getAltNumber() const { return atn::ATN::INVALID_ALT_NUMBER; } -void RuleContext::setAltNumber(int altNumber) { +void RuleContext::setAltNumber(int /*altNumber*/) { } std::size_t RuleContext::getChildCount() { diff --git a/runtime/Cpp/runtime/src/Token.cpp b/runtime/Cpp/runtime/src/Token.cpp index 55f0cfd5b..dc37a552f 100755 --- a/runtime/Cpp/runtime/src/Token.cpp +++ b/runtime/Cpp/runtime/src/Token.cpp @@ -53,4 +53,4 @@ std::wstring Token::toString() { getCharPositionInLine() << L"}"; return ss.str(); -} \ No newline at end of file +} diff --git a/runtime/Cpp/runtime/src/TokenFactory.h b/runtime/Cpp/runtime/src/TokenFactory.h index 980d9898c..44ad989ad 100755 --- a/runtime/Cpp/runtime/src/TokenFactory.h +++ b/runtime/Cpp/runtime/src/TokenFactory.h @@ -41,12 +41,12 @@ namespace runtime { /// of a new factory means that it notifies it's token source and error strategy. template class ANTLR4CPP_PUBLIC TokenFactory { - /// + public: + virtual ~TokenFactory() {}; + /// This is the method used to create tokens in the lexer and in the /// error handling strategy. If text!=null, than the start and stop positions /// are wiped to -1 in the text override is set in the CommonToken. - /// - public: virtual Ref create(std::pair source, int type, const std::wstring &text, int channel, int start, int stop, int line, int charPositionInLine) = 0; diff --git a/runtime/Cpp/runtime/src/TokenSource.h b/runtime/Cpp/runtime/src/TokenSource.h index 93f31eec0..d0eadc368 100755 --- a/runtime/Cpp/runtime/src/TokenSource.h +++ b/runtime/Cpp/runtime/src/TokenSource.h @@ -54,13 +54,13 @@ namespace runtime { /// going, looking for a valid token. /// class ANTLR4CPP_PUBLIC TokenSource { - /// + public: + virtual ~TokenSource() {}; + /// Return a object from your input stream (usually a /// ). Do not fail/return upon lexing error; keep chewing /// on the characters until you get a good one; errors are not passed through /// to the parser. - /// - public: virtual Ref nextToken() = 0; /// @@ -101,7 +101,7 @@ namespace runtime { /// /// The to use for creating tokens. template - void setTokenFactory(TokenFactory *factory) {}; + void setTokenFactory(TokenFactory */*factory*/) {}; /// /// Gets the this token source is currently using for diff --git a/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp b/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp index 7f4127f82..e2f7fdcd1 100755 --- a/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp +++ b/runtime/Cpp/runtime/src/TokenStreamRewriter.cpp @@ -56,7 +56,7 @@ TokenStreamRewriter::RewriteOperation::RewriteOperation(TokenStreamRewriter *out this->text = text; } -size_t TokenStreamRewriter::RewriteOperation::execute(std::wstring *buf) { +size_t TokenStreamRewriter::RewriteOperation::execute(std::wstring */*buf*/) { return index; } diff --git a/runtime/Cpp/runtime/src/TokenStreamRewriter.h b/runtime/Cpp/runtime/src/TokenStreamRewriter.h index 38c5d3bff..8138be3f2 100755 --- a/runtime/Cpp/runtime/src/TokenStreamRewriter.h +++ b/runtime/Cpp/runtime/src/TokenStreamRewriter.h @@ -314,7 +314,7 @@ namespace runtime { /// /// Get all operations before an index of a particular kind template - std::vector getKindOfOps(std::vector rewrites, T *kind, size_t before) { + std::vector getKindOfOps(std::vector rewrites, T */*kind*/, size_t before) { std::vector ops = std::vector(); for (size_t i = 0; i < before && i < rewrites.size(); i++) { TokenStreamRewriter::RewriteOperation *op = dynamic_cast(rewrites[i]); diff --git a/runtime/Cpp/runtime/src/UnbufferedTokenStream.cpp b/runtime/Cpp/runtime/src/UnbufferedTokenStream.cpp index ae97c61f4..90487dab6 100755 --- a/runtime/Cpp/runtime/src/UnbufferedTokenStream.cpp +++ b/runtime/Cpp/runtime/src/UnbufferedTokenStream.cpp @@ -45,7 +45,7 @@ using namespace org::antlr::v4::runtime; UnbufferedTokenStream::UnbufferedTokenStream(TokenSource *tokenSource) : UnbufferedTokenStream(tokenSource, 256) { } -UnbufferedTokenStream::UnbufferedTokenStream(TokenSource *tokenSource, int bufferSize) : _tokenSource(tokenSource) +UnbufferedTokenStream::UnbufferedTokenStream(TokenSource *tokenSource, int /*bufferSize*/) : _tokenSource(tokenSource) { InitializeInstanceFields(); fill(1); // prime the pump diff --git a/runtime/Cpp/runtime/src/Vocabulary.h b/runtime/Cpp/runtime/src/Vocabulary.h index be6be2321..20a47cdb5 100755 --- a/runtime/Cpp/runtime/src/Vocabulary.h +++ b/runtime/Cpp/runtime/src/Vocabulary.h @@ -44,6 +44,8 @@ namespace dfa { /// @author Sam Harwell class ANTLR4CPP_PUBLIC Vocabulary { public: + virtual ~Vocabulary() {}; + /// /// Returns the highest token type value. It can be used to iterate from /// zero to that number, inclusively, thus querying all stored entries. diff --git a/runtime/Cpp/runtime/src/VocabularyImpl.h b/runtime/Cpp/runtime/src/VocabularyImpl.h index eca453dba..0be8993cc 100755 --- a/runtime/Cpp/runtime/src/VocabularyImpl.h +++ b/runtime/Cpp/runtime/src/VocabularyImpl.h @@ -43,6 +43,8 @@ namespace dfa { /// interface. class ANTLR4CPP_PUBLIC VocabularyImpl : public Vocabulary { public: + virtual ~VocabularyImpl() {}; + /// Gets an empty instance. /// /// diff --git a/runtime/Cpp/runtime/src/atn/ATN.h b/runtime/Cpp/runtime/src/atn/ATN.h index 9016686e4..84882122f 100755 --- a/runtime/Cpp/runtime/src/atn/ATN.h +++ b/runtime/Cpp/runtime/src/atn/ATN.h @@ -47,7 +47,7 @@ namespace atn { ATN(); ATN(ATN &&other); ATN(ATNType grammarType, size_t maxTokenType); - ~ATN(); + virtual ~ATN(); std::vector states; diff --git a/runtime/Cpp/runtime/src/atn/ATNConfig.cpp b/runtime/Cpp/runtime/src/atn/ATNConfig.cpp index 310c7b252..9bbde83fc 100755 --- a/runtime/Cpp/runtime/src/atn/ATNConfig.cpp +++ b/runtime/Cpp/runtime/src/atn/ATNConfig.cpp @@ -67,7 +67,8 @@ ATNConfig::ATNConfig(Ref c, ATNState *state, Ref c } ATNConfig::ATNConfig(Ref c, ATNState *state, Ref context, Ref semanticContext) - : state(state), alt(c->alt), context(context), semanticContext(semanticContext), reachesIntoOuterContext(c->reachesIntoOuterContext) { + : state(state), alt(c->alt), context(context), reachesIntoOuterContext(c->reachesIntoOuterContext), + semanticContext(semanticContext) { } ATNConfig::~ATNConfig() { diff --git a/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp b/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp index 3d667dddb..d26a136f9 100755 --- a/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp +++ b/runtime/Cpp/runtime/src/atn/ATNConfigSet.cpp @@ -275,7 +275,7 @@ std::wstring ATNConfigSet::toString() { return ss.str(); } -bool ATNConfigSet::remove(void *o) { +bool ATNConfigSet::remove(void */*o*/) { throw UnsupportedOperationException(); } diff --git a/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h b/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h index 7f67ae854..64773b92c 100755 --- a/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h +++ b/runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.h @@ -47,8 +47,8 @@ namespace atn { public: ATNDeserializationOptions(); - ATNDeserializationOptions(ATNDeserializationOptions *options); + virtual ~ATNDeserializationOptions() {}; static const ATNDeserializationOptions& getDefaultOptions(); diff --git a/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp b/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp index 75418bdc3..7368e1082 100755 --- a/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp +++ b/runtime/Cpp/runtime/src/atn/ATNDeserializer.cpp @@ -130,9 +130,9 @@ bool ATNDeserializer::isFeatureSupported(const Guid &feature, const Guid &actual ATN ATNDeserializer::deserialize(const std::wstring& input) { // Don't adjust the first value since that's the version number. std::vector data(input.size()); - data[0] = input[0]; + data[0] = (uint16_t)input[0]; for (size_t i = 1; i < input.size(); ++i) { - data[i] = input[i] - 2; + data[i] = (uint16_t)input[i] - 2; } int p = 0; @@ -617,7 +617,7 @@ Guid ATNDeserializer::toUUID(const unsigned short *data, int offset) { } /* mem check: all created instances are freed in the d-tor of the ATNState they are added to. */ -Transition *ATNDeserializer::edgeFactory(const ATN &atn, int type, int src, int trg, int arg1, int arg2, int arg3, +Transition *ATNDeserializer::edgeFactory(const ATN &atn, int type, int /*src*/, int trg, int arg1, int arg2, int arg3, const std::vector &sets) { ATNState *target = atn.states[(size_t)trg]; diff --git a/runtime/Cpp/runtime/src/atn/ATNDeserializer.h b/runtime/Cpp/runtime/src/atn/ATNDeserializer.h index 6eeea3988..f65d63c8e 100755 --- a/runtime/Cpp/runtime/src/atn/ATNDeserializer.h +++ b/runtime/Cpp/runtime/src/atn/ATNDeserializer.h @@ -50,6 +50,7 @@ namespace atn { ATNDeserializer(); ATNDeserializer(const ATNDeserializationOptions& dso); + virtual ~ATNDeserializer() {}; static Guid toUUID(const unsigned short *data, int offset); diff --git a/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp b/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp index d17efe13f..b82768639 100755 --- a/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp +++ b/runtime/Cpp/runtime/src/atn/ATNSerializer.cpp @@ -42,7 +42,7 @@ #include "SetTransition.h" #include "Token.h" #include "Interval.h" -#include "atn.h" +#include "ATN.h" #include "RuleTransition.h" #include "PrecedencePredicateTransition.h" @@ -73,7 +73,7 @@ ATNSerializer::ATNSerializer(ATN *atn) { this->atn = atn; } ATNSerializer::ATNSerializer(ATN *atn, const std::vector &tokenNames) { this->atn = atn; - this->tokenNames = tokenNames; + _tokenNames = tokenNames; } std::vector ATNSerializer::serialize() { @@ -396,11 +396,11 @@ std::wstring ATNSerializer::decode(const std::wstring &inpdata) { throw IllegalArgumentException("Not enough data to decode"); std::vector data(inpdata.size()); - data[0] = inpdata[0]; + data[0] = (uint16_t)inpdata[0]; // Don't adjust the first value since that's the version number. for (size_t i = 1; i < inpdata.size(); ++i) { - data[i] = inpdata[i] - 2; + data[i] = (uint16_t)inpdata[i] - 2; } std::wstring buf; @@ -600,8 +600,8 @@ std::wstring ATNSerializer::getTokenName(ssize_t t) { } } - if (tokenNames.size() > 0 && t >= 0 && t < (ssize_t)tokenNames.size()) { - return tokenNames[(size_t)t]; + if (_tokenNames.size() > 0 && t >= 0 && t < (ssize_t)_tokenNames.size()) { + return _tokenNames[(size_t)t]; } return std::to_wstring(t); diff --git a/runtime/Cpp/runtime/src/atn/ATNSerializer.h b/runtime/Cpp/runtime/src/atn/ATNSerializer.h index 29dd4f277..781bf7407 100755 --- a/runtime/Cpp/runtime/src/atn/ATNSerializer.h +++ b/runtime/Cpp/runtime/src/atn/ATNSerializer.h @@ -41,12 +41,9 @@ namespace atn { public: ATN *atn; - private: - std::vector tokenNames; - - public: ATNSerializer(ATN *atn); ATNSerializer(ATN *atn, const std::vector &tokenNames); + virtual ~ATNSerializer() {}; /// /// Serialize state descriptors, edge descriptors, and decision->state map @@ -85,6 +82,8 @@ namespace atn { static std::wstring getDecoded(ATN *atn, std::vector &tokenNames); private: + std::vector _tokenNames; + void serializeUUID(std::vector &data, Guid uuid); }; diff --git a/runtime/Cpp/runtime/src/atn/ATNState.cpp b/runtime/Cpp/runtime/src/atn/ATNState.cpp index 13df7f54a..02d02a228 100755 --- a/runtime/Cpp/runtime/src/atn/ATNState.cpp +++ b/runtime/Cpp/runtime/src/atn/ATNState.cpp @@ -48,9 +48,11 @@ ATNState::~ATNState() { } }; -const std::vector ATNState::serializationNames = { L"INVALID", L"BASIC", L"RULE_START", L"BLOCK_START", +const std::vector ATNState::serializationNames = { + L"INVALID", L"BASIC", L"RULE_START", L"BLOCK_START", L"PLUS_BLOCK_START", L"STAR_BLOCK_START", L"TOKEN_START", L"RULE_STOP", - L"BLOCK_END", L"STAR_LOOP_BACK", L"STAR_LOOP_ENTRY", L"PLUS_LOOP_BACK", L"LOOP_END" }; + L"BLOCK_END", L"STAR_LOOP_BACK", L"STAR_LOOP_ENTRY", L"PLUS_LOOP_BACK", L"LOOP_END" +}; size_t ATNState::hashCode() { return (size_t)stateNumber; diff --git a/runtime/Cpp/runtime/src/atn/ActionTransition.cpp b/runtime/Cpp/runtime/src/atn/ActionTransition.cpp index 1891cc9b0..512e1d4e0 100755 --- a/runtime/Cpp/runtime/src/atn/ActionTransition.cpp +++ b/runtime/Cpp/runtime/src/atn/ActionTransition.cpp @@ -49,7 +49,7 @@ bool ActionTransition::isEpsilon() const { return true; // we are to be ignored by analysis 'cept for predicates } -bool ActionTransition::matches(int symbol, int minVocabSymbol, int maxVocabSymbol) const { +bool ActionTransition::matches(int /*symbol*/, int /*minVocabSymbol*/, int /*maxVocabSymbol*/) const { return false; } diff --git a/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h b/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h index 1c69a591a..be461c420 100755 --- a/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h +++ b/runtime/Cpp/runtime/src/atn/ArrayPredictionContext.h @@ -55,6 +55,7 @@ namespace atn { ArrayPredictionContext(Ref a); ArrayPredictionContext(const std::vector> &parents, const std::vector &returnStates); + virtual ~ArrayPredictionContext() {}; virtual bool isEmpty() const override; virtual size_t size() const override; diff --git a/runtime/Cpp/runtime/src/atn/AtomTransition.cpp b/runtime/Cpp/runtime/src/atn/AtomTransition.cpp index 4ca3d99b4..8e76a5e01 100755 --- a/runtime/Cpp/runtime/src/atn/AtomTransition.cpp +++ b/runtime/Cpp/runtime/src/atn/AtomTransition.cpp @@ -48,7 +48,7 @@ IntervalSet AtomTransition::label() const { return IntervalSet::of(_label); } -bool AtomTransition::matches(int symbol, int minVocabSymbol, int maxVocabSymbol) const { +bool AtomTransition::matches(int symbol, int /*minVocabSymbol*/, int /*maxVocabSymbol*/) const { return _label == symbol; } diff --git a/runtime/Cpp/runtime/src/atn/ConfigLookup.h b/runtime/Cpp/runtime/src/atn/ConfigLookup.h index f035995d6..5807c9eef 100644 --- a/runtime/Cpp/runtime/src/atn/ConfigLookup.h +++ b/runtime/Cpp/runtime/src/atn/ConfigLookup.h @@ -67,6 +67,8 @@ namespace atn { protected: class ConfigLookupIteratorImpl { public: + virtual ~ConfigLookupIteratorImpl () {}; + virtual ConfigLookupIteratorImpl& operator ++ () = 0; virtual bool operator != (const ConfigLookupIteratorImpl&) const = 0; virtual Ref operator * () const = 0; diff --git a/runtime/Cpp/runtime/src/atn/DecisionState.cpp b/runtime/Cpp/runtime/src/atn/DecisionState.cpp index 5b1216014..57ee103f3 100755 --- a/runtime/Cpp/runtime/src/atn/DecisionState.cpp +++ b/runtime/Cpp/runtime/src/atn/DecisionState.cpp @@ -40,4 +40,4 @@ void DecisionState::InitializeInstanceFields() { std::wstring DecisionState::toString() const { return L"DECISION " + ATNState::toString(); -} \ No newline at end of file +} diff --git a/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp b/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp index 38d7a4a6a..61ded5031 100755 --- a/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp +++ b/runtime/Cpp/runtime/src/atn/EmptyPredictionContext.cpp @@ -44,11 +44,11 @@ size_t EmptyPredictionContext::size() const { return 1; } -std::weak_ptr EmptyPredictionContext::getParent(size_t index) const { +std::weak_ptr EmptyPredictionContext::getParent(size_t /*index*/) const { return std::weak_ptr(); } -int EmptyPredictionContext::getReturnState(size_t index) const { +int EmptyPredictionContext::getReturnState(size_t /*index*/) const { return returnState; } diff --git a/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp b/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp index f255804a1..3678a815a 100755 --- a/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp +++ b/runtime/Cpp/runtime/src/atn/EpsilonTransition.cpp @@ -52,7 +52,7 @@ bool EpsilonTransition::isEpsilon() const { return true; } -bool EpsilonTransition::matches(int symbol, int minVocabSymbol, int maxVocabSymbol) const { +bool EpsilonTransition::matches(int /*symbol*/, int /*minVocabSymbol*/, int /*maxVocabSymbol*/) const { return false; } diff --git a/runtime/Cpp/runtime/src/atn/LL1Analyzer.h b/runtime/Cpp/runtime/src/atn/LL1Analyzer.h index 68407ba4d..ee0bcda05 100755 --- a/runtime/Cpp/runtime/src/atn/LL1Analyzer.h +++ b/runtime/Cpp/runtime/src/atn/LL1Analyzer.h @@ -43,16 +43,15 @@ namespace runtime { namespace atn { class ANTLR4CPP_PUBLIC LL1Analyzer { - /// + public: /// Special value added to the lookahead sets to indicate that we hit /// a predicate during analysis if {@code seeThruPreds==false}. - /// - public: static const int HIT_PRED = Token::INVALID_TYPE; const atn::ATN &_atn; LL1Analyzer(const atn::ATN &atn); + virtual ~LL1Analyzer() {}; /// /// Calculates the SLL(1) expected lookahead set for each outgoing transition diff --git a/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp b/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp index d6525fff4..2f6f76888 100755 --- a/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +++ b/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp @@ -48,23 +48,23 @@ LexerATNConfig::LexerATNConfig(ATNState *state, int alt, Ref LexerATNConfig::LexerATNConfig(ATNState *state, int alt, Ref context, Ref lexerActionExecutor) - : ATNConfig(state, alt, context, SemanticContext::NONE), _passedThroughNonGreedyDecision(false), - _lexerActionExecutor(lexerActionExecutor) { + : ATNConfig(state, alt, context, SemanticContext::NONE), _lexerActionExecutor(lexerActionExecutor), + _passedThroughNonGreedyDecision(false) { } LexerATNConfig::LexerATNConfig(Ref c, ATNState *state) - : ATNConfig(c, state, c->context, c->semanticContext), _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)), - _lexerActionExecutor(c->_lexerActionExecutor) { + : ATNConfig(c, state, c->context, c->semanticContext), _lexerActionExecutor(c->_lexerActionExecutor), + _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)) { } LexerATNConfig::LexerATNConfig(Ref c, ATNState *state, Ref lexerActionExecutor) - : ATNConfig(c, state, c->context, c->semanticContext), _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)), - _lexerActionExecutor(lexerActionExecutor) { + : ATNConfig(c, state, c->context, c->semanticContext), _lexerActionExecutor(lexerActionExecutor), + _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)) { } LexerATNConfig::LexerATNConfig(Ref c, ATNState *state, Ref context) - : ATNConfig(c, state, context, c->semanticContext), _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)), - _lexerActionExecutor(c->_lexerActionExecutor) { + : ATNConfig(c, state, context, c->semanticContext), _lexerActionExecutor(c->_lexerActionExecutor), + _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)) { } Ref LexerATNConfig::getLexerActionExecutor() const { diff --git a/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp b/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp index 56c280a11..03af7bcab 100755 --- a/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +++ b/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp @@ -311,7 +311,7 @@ void LexerATNSimulator::getReachableConfigSet(CharStream *input, Ref lexerActionExecutor, int startIndex, +void LexerATNSimulator::accept(CharStream *input, Ref lexerActionExecutor, int /*startIndex*/, size_t index, size_t line, size_t charPos) { if (debug) { std::wcout << L"ACTION "; diff --git a/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h b/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h index 7b3a55afd..ca2868bff 100755 --- a/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +++ b/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h @@ -45,6 +45,9 @@ namespace atn { class ANTLR4CPP_PUBLIC LexerATNSimulator : public ATNSimulator { protected: class SimState { + public: + virtual ~SimState() {}; + protected: int index; size_t line; diff --git a/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h b/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h index 9c68602dc..45dbaef76 100755 --- a/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +++ b/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h @@ -52,6 +52,7 @@ namespace atn { /// Constructs an executor for a sequence of actions. /// The lexer actions to execute. LexerActionExecutor(const std::vector> &lexerActions); + virtual ~LexerActionExecutor() {}; /// /// Creates a which executes the actions for diff --git a/runtime/Cpp/runtime/src/atn/ParseInfo.h b/runtime/Cpp/runtime/src/atn/ParseInfo.h index 88958715d..116fb7991 100755 --- a/runtime/Cpp/runtime/src/atn/ParseInfo.h +++ b/runtime/Cpp/runtime/src/atn/ParseInfo.h @@ -46,6 +46,7 @@ namespace atn { class ANTLR4CPP_PUBLIC ParseInfo { public: ParseInfo(ProfilingATNSimulator *atnSimulator); + virtual ~ParseInfo() {}; /// /// Gets an array of instances containing the profiling diff --git a/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp b/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp index 6b9828c2e..20ed94726 100755 --- a/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp +++ b/runtime/Cpp/runtime/src/atn/ParserATNSimulator.cpp @@ -846,8 +846,8 @@ BitSet ParserATNSimulator::evalSemanticContext(std::vector pred, Ref parserCallStack, int alt, - bool fullCtx) { +bool ParserATNSimulator::evalSemanticContext(Ref pred, Ref parserCallStack, + int /*alt*/, bool /*fullCtx*/) { return pred->eval(parser, parserCallStack); } @@ -1270,7 +1270,7 @@ void ParserATNSimulator::reportContextSensitivity(dfa::DFA &dfa, int prediction, } } -void ParserATNSimulator::reportAmbiguity(dfa::DFA &dfa, dfa::DFAState *D, size_t startIndex, size_t stopIndex, +void ParserATNSimulator::reportAmbiguity(dfa::DFA &dfa, dfa::DFAState */*D*/, size_t startIndex, size_t stopIndex, bool exact, const antlrcpp::BitSet &ambigAlts, Ref configs) { if (debug || retry_debug) { misc::Interval interval = misc::Interval((int)startIndex, (int)stopIndex); diff --git a/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp b/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp index d2f43050f..9f1413612 100755 --- a/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp +++ b/runtime/Cpp/runtime/src/atn/PrecedencePredicateTransition.cpp @@ -44,7 +44,7 @@ bool PrecedencePredicateTransition::isEpsilon() const { return true; } -bool PrecedencePredicateTransition::matches(int symbol, int minVocabSymbol, int maxVocabSymbol) const { +bool PrecedencePredicateTransition::matches(int /*symbol*/, int /*minVocabSymbol*/, int /*maxVocabSymbol*/) const { return false; } diff --git a/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp b/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp index 2fec17b4a..795344adc 100755 --- a/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp +++ b/runtime/Cpp/runtime/src/atn/PredicateTransition.cpp @@ -44,7 +44,7 @@ bool PredicateTransition::isEpsilon() const { return true; } -bool PredicateTransition::matches(int symbol, int minVocabSymbol, int maxVocabSymbol) const { +bool PredicateTransition::matches(int /*symbol*/, int /*minVocabSymbol*/, int /*maxVocabSymbol*/) const { return false; } diff --git a/runtime/Cpp/runtime/src/atn/PredictionContext.cpp b/runtime/Cpp/runtime/src/atn/PredictionContext.cpp index a3989c425..9307d5489 100755 --- a/runtime/Cpp/runtime/src/atn/PredictionContext.cpp +++ b/runtime/Cpp/runtime/src/atn/PredictionContext.cpp @@ -555,7 +555,7 @@ std::wstring PredictionContext::toString() const { return antlrcpp::toString(this); } -std::wstring PredictionContext::toString(Recognizer *recog) const { +std::wstring PredictionContext::toString(Recognizer */*recog*/) const { return toString(); } diff --git a/runtime/Cpp/runtime/src/atn/RangeTransition.cpp b/runtime/Cpp/runtime/src/atn/RangeTransition.cpp index 25dee0018..6c1314818 100755 --- a/runtime/Cpp/runtime/src/atn/RangeTransition.cpp +++ b/runtime/Cpp/runtime/src/atn/RangeTransition.cpp @@ -47,7 +47,7 @@ misc::IntervalSet RangeTransition::label() const { return misc::IntervalSet::of(from, to); } -bool RangeTransition::matches(int symbol, int minVocabSymbol, int maxVocabSymbol) const { +bool RangeTransition::matches(int symbol, int /*minVocabSymbol*/, int /*maxVocabSymbol*/) const { return symbol >= from && symbol <= to; } diff --git a/runtime/Cpp/runtime/src/atn/RuleTransition.cpp b/runtime/Cpp/runtime/src/atn/RuleTransition.cpp index 7ac36d680..985c227a6 100755 --- a/runtime/Cpp/runtime/src/atn/RuleTransition.cpp +++ b/runtime/Cpp/runtime/src/atn/RuleTransition.cpp @@ -51,7 +51,7 @@ bool RuleTransition::isEpsilon() const { return true; } -bool RuleTransition::matches(int symbol, int minVocabSymbol, int maxVocabSymbol) const { +bool RuleTransition::matches(int /*symbol*/, int /*minVocabSymbol*/, int /*maxVocabSymbol*/) const { return false; } diff --git a/runtime/Cpp/runtime/src/atn/SemanticContext.cpp b/runtime/Cpp/runtime/src/atn/SemanticContext.cpp index c96b92188..507ea32ce 100755 --- a/runtime/Cpp/runtime/src/atn/SemanticContext.cpp +++ b/runtime/Cpp/runtime/src/atn/SemanticContext.cpp @@ -338,7 +338,7 @@ std::wstring SemanticContext::OR::toString() const { const Ref SemanticContext::NONE = std::make_shared(-1, -1, false); -Ref SemanticContext::evalPrecedence(Recognizer *parser, Ref parserCallStack) { +Ref SemanticContext::evalPrecedence(Recognizer */*parser*/, Ref /*parserCallStack*/) { return shared_from_this(); } diff --git a/runtime/Cpp/runtime/src/atn/SemanticContext.h b/runtime/Cpp/runtime/src/atn/SemanticContext.h index 975e4a4aa..3fd5a1516 100755 --- a/runtime/Cpp/runtime/src/atn/SemanticContext.h +++ b/runtime/Cpp/runtime/src/atn/SemanticContext.h @@ -54,6 +54,8 @@ namespace atn { */ static const Ref NONE; + virtual ~SemanticContext() {}; + virtual size_t hashCode() const = 0; virtual std::wstring toString() const = 0; virtual bool operator == (const SemanticContext &other) const = 0; diff --git a/runtime/Cpp/runtime/src/atn/SetTransition.cpp b/runtime/Cpp/runtime/src/atn/SetTransition.cpp index 413fe7bec..511ba0caa 100755 --- a/runtime/Cpp/runtime/src/atn/SetTransition.cpp +++ b/runtime/Cpp/runtime/src/atn/SetTransition.cpp @@ -49,7 +49,7 @@ misc::IntervalSet SetTransition::label() const { return set; } -bool SetTransition::matches(int symbol, int minVocabSymbol, int maxVocabSymbol) const { +bool SetTransition::matches(int symbol, int /*minVocabSymbol*/, int /*maxVocabSymbol*/) const { return set.contains(symbol); } diff --git a/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h b/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h index d74c607f1..62298db5a 100755 --- a/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h +++ b/runtime/Cpp/runtime/src/atn/SingletonPredictionContext.h @@ -50,6 +50,7 @@ namespace atn { const int returnState; SingletonPredictionContext(std::weak_ptr parent, int returnState); + virtual ~SingletonPredictionContext() {}; static Ref create(std::weak_ptr parent, int returnState); diff --git a/runtime/Cpp/runtime/src/dfa/DFA.cpp b/runtime/Cpp/runtime/src/dfa/DFA.cpp index 387be2956..6472c9a42 100755 --- a/runtime/Cpp/runtime/src/dfa/DFA.cpp +++ b/runtime/Cpp/runtime/src/dfa/DFA.cpp @@ -46,7 +46,7 @@ DFA::DFA(atn::DecisionState *atnStartState) : DFA(atnStartState, 0) { } DFA::DFA(atn::DecisionState *atnStartState, int decision) - : atnStartState(atnStartState), decision(decision), s0(nullptr) { + : atnStartState(atnStartState), s0(nullptr), decision(decision) { _precedenceDfa = false; if (is(atnStartState)) { diff --git a/runtime/Cpp/runtime/src/dfa/DFA.h b/runtime/Cpp/runtime/src/dfa/DFA.h index 7a2240511..24cbda2b0 100755 --- a/runtime/Cpp/runtime/src/dfa/DFA.h +++ b/runtime/Cpp/runtime/src/dfa/DFA.h @@ -52,7 +52,7 @@ namespace dfa { DFA(atn::DecisionState *atnStartState, int decision); DFA(const DFA &other); DFA(DFA &&other); - ~DFA(); + virtual ~DFA(); /** * Gets whether this DFA is a precedence DFA. Precedence DFAs use a special diff --git a/runtime/Cpp/runtime/src/dfa/DFASerializer.h b/runtime/Cpp/runtime/src/dfa/DFASerializer.h index 3f6081cd0..6c73d7310 100755 --- a/runtime/Cpp/runtime/src/dfa/DFASerializer.h +++ b/runtime/Cpp/runtime/src/dfa/DFASerializer.h @@ -45,6 +45,7 @@ namespace dfa { public: DFASerializer(const DFA *dfa, const std::vector& tnames); DFASerializer(const DFA *dfa, Ref vocabulary); + virtual ~DFASerializer() {}; virtual std::wstring toString() const; diff --git a/runtime/Cpp/runtime/src/dfa/DFAState.h b/runtime/Cpp/runtime/src/dfa/DFAState.h index 1c07a4e45..5fc68e020 100755 --- a/runtime/Cpp/runtime/src/dfa/DFAState.h +++ b/runtime/Cpp/runtime/src/dfa/DFAState.h @@ -68,7 +68,10 @@ namespace dfa { public: Ref pred; // never null; at least SemanticContext.NONE int alt; + PredPrediction(Ref pred, int alt); + virtual ~PredPrediction() {}; + virtual std::wstring toString(); private: @@ -123,7 +126,7 @@ namespace dfa { DFAState(); DFAState(int state); DFAState(Ref configs); - ~DFAState(); + virtual ~DFAState(); /// /// Get the set of all alts mentioned by all ATN configurations in this diff --git a/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h b/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h index 645b99bdd..17e3b727c 100755 --- a/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h +++ b/runtime/Cpp/runtime/src/dfa/LexerDFASerializer.h @@ -42,6 +42,7 @@ namespace dfa { class ANTLR4CPP_PUBLIC LexerDFASerializer : public DFASerializer { public: LexerDFASerializer(DFA *dfa); + virtual ~LexerDFASerializer() {}; protected: virtual std::wstring getEdgeLabel(size_t i) const override; diff --git a/runtime/Cpp/runtime/src/misc/Interval.h b/runtime/Cpp/runtime/src/misc/Interval.h index f3c98171f..4a2754375 100755 --- a/runtime/Cpp/runtime/src/misc/Interval.h +++ b/runtime/Cpp/runtime/src/misc/Interval.h @@ -52,6 +52,7 @@ namespace misc { Interval(); Interval(int a_, int b_); + virtual ~Interval() {}; /// /// return number of elements between a and b inclusively. x..x is length 1. diff --git a/runtime/Cpp/runtime/src/misc/MurmurHash.cpp b/runtime/Cpp/runtime/src/misc/MurmurHash.cpp index 91937052d..40cd0858f 100755 --- a/runtime/Cpp/runtime/src/misc/MurmurHash.cpp +++ b/runtime/Cpp/runtime/src/misc/MurmurHash.cpp @@ -157,4 +157,4 @@ size_t MurmurHash::finish(size_t hash, size_t entryCount) { return hash; } -#endif \ No newline at end of file +#endif diff --git a/runtime/Cpp/runtime/src/misc/Predicate.h b/runtime/Cpp/runtime/src/misc/Predicate.h index 0d5d3d82c..cc8ad94bb 100755 --- a/runtime/Cpp/runtime/src/misc/Predicate.h +++ b/runtime/Cpp/runtime/src/misc/Predicate.h @@ -40,6 +40,8 @@ namespace misc { template class ANTLR4CPP_PUBLIC Predicate { public: + virtual ~Predicate() {}; + virtual bool test(Ref t) = 0; }; diff --git a/runtime/Cpp/runtime/src/misc/TestRig.h b/runtime/Cpp/runtime/src/misc/TestRig.h index 1380fc19c..86ab5cd1d 100755 --- a/runtime/Cpp/runtime/src/misc/TestRig.h +++ b/runtime/Cpp/runtime/src/misc/TestRig.h @@ -53,6 +53,8 @@ namespace misc { public: static const std::wstring LEXER_START_RULE_NAME; + virtual ~TestRig() {}; + protected: std::wstring grammarName; std::wstring startRuleName; diff --git a/runtime/Cpp/runtime/src/support/Arrays.h b/runtime/Cpp/runtime/src/support/Arrays.h index be7f501ab..240cdfabd 100644 --- a/runtime/Cpp/runtime/src/support/Arrays.h +++ b/runtime/Cpp/runtime/src/support/Arrays.h @@ -129,4 +129,4 @@ namespace antlrcpp { template <> std::wstring Arrays::toString(const std::vector &source); -} \ No newline at end of file +} diff --git a/runtime/Cpp/runtime/src/support/CPPUtils.cpp b/runtime/Cpp/runtime/src/support/CPPUtils.cpp index 40eb7551d..778bd42be 100755 --- a/runtime/Cpp/runtime/src/support/CPPUtils.cpp +++ b/runtime/Cpp/runtime/src/support/CPPUtils.cpp @@ -160,4 +160,4 @@ namespace antlrcpp { return join(parts, L"\n"); } -} // namespace antlrcpp \ No newline at end of file +} // namespace antlrcpp diff --git a/runtime/Cpp/runtime/src/support/Strings.h b/runtime/Cpp/runtime/src/support/Strings.h index b4fe7b408..005f2a6d0 100644 --- a/runtime/Cpp/runtime/src/support/Strings.h +++ b/runtime/Cpp/runtime/src/support/Strings.h @@ -39,4 +39,4 @@ namespace antlrcpp { std::wstring wchar2wstring(const wchar_t & str); -} \ No newline at end of file +} diff --git a/runtime/Cpp/runtime/src/tree/ParseTreeListener.h b/runtime/Cpp/runtime/src/tree/ParseTreeListener.h index e5ce7a96c..18cf5bc68 100755 --- a/runtime/Cpp/runtime/src/tree/ParseTreeListener.h +++ b/runtime/Cpp/runtime/src/tree/ParseTreeListener.h @@ -50,6 +50,8 @@ namespace tree { */ class ANTLR4CPP_PUBLIC ParseTreeListener { public: + virtual ~ParseTreeListener() {}; + virtual void visitTerminal(Ref node) = 0; virtual void visitErrorNode(Ref node) = 0; virtual void enterEveryRule(Ref ctx) = 0; diff --git a/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h b/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h index 2654b421d..0a4f7b821 100755 --- a/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h +++ b/runtime/Cpp/runtime/src/tree/ParseTreeWalker.h @@ -41,6 +41,8 @@ namespace tree { public: static const Ref DEFAULT; + virtual ~ParseTreeWalker() {}; + virtual void walk(Ref listener, Ref t); /// diff --git a/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp b/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp index 81caa6b09..b2d0dae78 100755 --- a/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp +++ b/runtime/Cpp/runtime/src/tree/TerminalNodeImpl.cpp @@ -62,7 +62,7 @@ std::wstring TerminalNodeImpl::getText() { return symbol->getText(); } -std::wstring TerminalNodeImpl::toStringTree(Parser *parser) { +std::wstring TerminalNodeImpl::toStringTree(Parser */*parser*/) { return toString(); } @@ -81,6 +81,6 @@ std::weak_ptr TerminalNodeImpl::getParentReference() { return parent; } -Ref TerminalNodeImpl::getChildReference(size_t i) { +Ref TerminalNodeImpl::getChildReference(size_t /*i*/) { return Ref(); } diff --git a/runtime/Cpp/runtime/src/tree/Tree.h b/runtime/Cpp/runtime/src/tree/Tree.h index 6ef45d30c..ce2f4d8f3 100755 --- a/runtime/Cpp/runtime/src/tree/Tree.h +++ b/runtime/Cpp/runtime/src/tree/Tree.h @@ -42,11 +42,11 @@ namespace tree { /// It is the most abstract interface for all the trees used by ANTLR. /// class ANTLR4CPP_PUBLIC Tree { - /// + public: + virtual ~Tree() {}; + /// The parent of this node. If the return value is null, then this /// node is the root of the tree. - /// - public: std::weak_ptr getParent() { return getParentReference(); }; /// diff --git a/runtime/Cpp/runtime/src/tree/pattern/Chunk.h b/runtime/Cpp/runtime/src/tree/pattern/Chunk.h index 0e6f88502..41bb10de6 100755 --- a/runtime/Cpp/runtime/src/tree/pattern/Chunk.h +++ b/runtime/Cpp/runtime/src/tree/pattern/Chunk.h @@ -50,12 +50,12 @@ namespace pattern { /// regular tokens of the text surrounding the tags. /// class ANTLR4CPP_PUBLIC Chunk { - - /// + public: + virtual ~Chunk() {}; + /// This method returns a text representation of the tag chunk. Labeled tags /// are returned in the form {@code label:tag}, and unlabeled tags are /// returned as just the tag name. - /// virtual std::wstring toString() { std::wstring str; return str; diff --git a/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.h b/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.h index 957dace45..aac45aedd 100755 --- a/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.h +++ b/runtime/Cpp/runtime/src/tree/pattern/ParseTreeMatch.h @@ -71,7 +71,8 @@ namespace pattern { ParseTreeMatch(Ref tree, const ParseTreePattern &pattern, const std::map>> &labels, Ref mismatchedNode); - + virtual ~ParseTreeMatch() {}; + /// /// Get the last node associated with a specific {@code label}. ///

diff --git a/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.h b/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.h index 999e80a63..5c3afb7d0 100755 --- a/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.h +++ b/runtime/Cpp/runtime/src/tree/pattern/ParseTreePattern.h @@ -55,6 +55,7 @@ namespace pattern { /// The tree pattern in form. ParseTreePattern(ParseTreePatternMatcher *matcher, const std::wstring &pattern, int patternRuleIndex, Ref patternTree); + virtual ~ParseTreePattern() {}; ///

/// Match a specific parse tree against this tree pattern. diff --git a/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.h b/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.h index 9d14df81f..474323d5b 100755 --- a/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.h +++ b/runtime/Cpp/runtime/src/tree/pattern/ParseTreePatternMatcher.h @@ -114,6 +114,7 @@ namespace pattern { /// the tree patterns. The parser is used as a convenient mechanism to get /// the grammar name, plus token, rule names. ParseTreePatternMatcher(Lexer *lexer, Parser *parser); + virtual ~ParseTreePatternMatcher() {}; /// /// Set the delimiters used for marking rule and token tags within concrete diff --git a/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.cpp b/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.cpp index 27da4f49e..b1bcbb313 100755 --- a/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.cpp +++ b/runtime/Cpp/runtime/src/tree/pattern/RuleTagToken.cpp @@ -35,10 +35,11 @@ using namespace org::antlr::v4::runtime::tree::pattern; -RuleTagToken::RuleTagToken(const std::wstring &ruleName, int _bypassTokenType) : bypassTokenType(_bypassTokenType) { +RuleTagToken::RuleTagToken(const std::wstring &/*ruleName*/, int _bypassTokenType) : bypassTokenType(_bypassTokenType) { } -RuleTagToken::RuleTagToken(const std::wstring &ruleName, int bypassTokenType, const std::wstring &label) : ruleName(ruleName), bypassTokenType(bypassTokenType), label(label) { +RuleTagToken::RuleTagToken(const std::wstring &ruleName, int bypassTokenType, const std::wstring &label) + : ruleName(ruleName), bypassTokenType(bypassTokenType), label(label) { if (ruleName.empty()) { throw IllegalArgumentException("ruleName cannot be null or empty."); } diff --git a/runtime/Cpp/runtime/src/tree/pattern/TagChunk.h b/runtime/Cpp/runtime/src/tree/pattern/TagChunk.h index ea485b22a..8f57d97ec 100755 --- a/runtime/Cpp/runtime/src/tree/pattern/TagChunk.h +++ b/runtime/Cpp/runtime/src/tree/pattern/TagChunk.h @@ -55,16 +55,6 @@ namespace pattern { /// from ensuring that the tag is a non-null, non-empty string. /// class ANTLR4CPP_PUBLIC TagChunk : public Chunk { - /// - /// This is the backing field for . - /// - private: - const std::wstring _tag; - /// - /// This is the backing field for . - /// - const std::wstring _label; - public: /// /// Construct a new instance of using the specified tag and @@ -76,6 +66,7 @@ namespace pattern { /// if {@code tag} is {@code null} or /// empty. TagChunk(const std::wstring &tag); + virtual ~TagChunk() {}; /// /// Construct a new instance of using the specified label @@ -109,6 +100,14 @@ namespace pattern { /// returned as just the tag name. /// virtual std::wstring toString(); + + private: + /// This is the backing field for . + const std::wstring _tag; + /// + /// This is the backing field for . + /// + const std::wstring _label; }; } // namespace pattern diff --git a/runtime/Cpp/runtime/src/tree/pattern/TextChunk.h b/runtime/Cpp/runtime/src/tree/pattern/TextChunk.h index 7d42f80e4..ddb62e18b 100755 --- a/runtime/Cpp/runtime/src/tree/pattern/TextChunk.h +++ b/runtime/Cpp/runtime/src/tree/pattern/TextChunk.h @@ -45,10 +45,10 @@ namespace pattern { /// pattern string. /// class ANTLR4CPP_PUBLIC TextChunk : public Chunk { + private: /// /// This is the backing field for . /// - private: const std::wstring text; /// @@ -58,6 +58,7 @@ namespace pattern { /// if {@code text} is {@code null}. public: TextChunk(const std::wstring &text); + virtual ~TextChunk() {}; /// /// Gets the raw text of this chunk. diff --git a/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.cpp b/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.cpp index 24b71ec14..434707d8e 100755 --- a/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.cpp +++ b/runtime/Cpp/runtime/src/tree/pattern/TokenTagToken.cpp @@ -33,12 +33,12 @@ using namespace org::antlr::v4::runtime::tree::pattern; -TokenTagToken::TokenTagToken(const std::wstring &tokenName, int type) : -CommonToken(type), tokenName(L""), label(L"") { +TokenTagToken::TokenTagToken(const std::wstring &/*tokenName*/, int type) + : CommonToken(type), tokenName(L""), label(L"") { } -TokenTagToken::TokenTagToken(const std::wstring &tokenName, int type, const std::wstring &label) : -CommonToken(type), tokenName(tokenName), label(label) { +TokenTagToken::TokenTagToken(const std::wstring &tokenName, int type, const std::wstring &label) + : CommonToken(type), tokenName(tokenName), label(label) { } std::wstring TokenTagToken::getTokenName() { diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg index 21c77ffe1..385846cde 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/Cpp/Cpp.stg @@ -902,13 +902,13 @@ TokenDecl(t) ::= "" TokenTypeDeclHeader(t) ::= "" TokenTypeDecl(t) ::= "ssize_t ;" -TokenListDeclHeader(t) ::= "std::vector\> ;" +TokenListDeclHeader(t) ::= "std::vector\> " TokenListDecl(t) ::= "" -RuleContextDeclHeader(r) ::= "Ref\<::> ;" +RuleContextDeclHeader(r) ::= "Ref\<::> " RuleContextDecl(r) ::= "" -RuleContextListDeclHeader(rdecl) ::= "std::vector\>> ;" +RuleContextListDeclHeader(rdecl) ::= "std::vector\>> " RuleContextListDecl(rdecl) ::= "" ContextTokenGetterDeclHeader(t) ::= "Ref\ ();"