Added cmake target (Linux + OSX) + fixed a number of warnings.

- Compiling with cmake brought up quite a number of new warnings. Some of them have to be disabled yet (dollar in identifier, four char constant, overloaded virtual). The others have all been fixed.
- Updated the README to include build instruction.
This commit is contained in:
Mike Lischke 2016-05-06 16:48:59 +02:00
parent 297f00350c
commit 6c21223d2e
96 changed files with 506 additions and 549 deletions

126
runtime/Cpp/CMakeLists.txt Normal file
View File

@ -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=<mode> where <mode> 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=<path>")
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")

1
runtime/Cpp/VERSION Normal file
View File

@ -0,0 +1 @@
4.0.0

View File

@ -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
)

View File

@ -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

View File

@ -1,2 +0,0 @@
#include <bits/codecvt.h>
#include <locale.h>

View File

@ -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 <jmoyers@geeks.com>
# 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 <adrian@gimp.org> <adrian@redhat.com>
#
# <seh4@ix.netcom.com> (Scott Harrington)
# Much improved handling of compiler command line arguments.
# exec compiler when not colorizing to preserve STDOUT, STDERR.
# Fixed my STDIN kludge.
#
# <ecarotti@athena.polito.it> (Elias S. G. Carotti)
# Corrected handling of text like -DPACKAGE=\"Package\"
# Spotted return code bug.
#
# <erwin@erwin.andreasen.org> (Erwin S. Andreasen)
# <schurchi@ucsd.edu> (Steve Churchill)
# Return code bug fixes.
#
# <rik@kde.org> (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(<PREFS>)
{
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(<GCCOUT>)
{
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);

View File

@ -1 +0,0 @@
color-gcc.pl

View File

@ -0,0 +1,32 @@
//
// main.cpp
// antlr4-cpp-demo
//
// Created by Mike Lischke on 13.03.16.
//
#include <iostream>
#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::ParseTree> tree = parser.main();
std::cout << antlrcpp::ws2s(tree->toStringTree(&parser)) << std::endl;
return 0;
}

View File

@ -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. - 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. - 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. - 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 <antlr4-dir>/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=<antlr4-dir>/runtime/Cpp/run make install

View File

@ -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"
)

View File

@ -869,7 +869,7 @@
276E5C1A1CDB57AA003FF4B4 /* ArrayPredictionContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayPredictionContext.h; sourceTree = "<group>"; }; 276E5C1A1CDB57AA003FF4B4 /* ArrayPredictionContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayPredictionContext.h; sourceTree = "<group>"; };
276E5C1B1CDB57AA003FF4B4 /* ATN.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ATN.cpp; sourceTree = "<group>"; }; 276E5C1B1CDB57AA003FF4B4 /* ATN.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ATN.cpp; sourceTree = "<group>"; };
276E5C1C1CDB57AA003FF4B4 /* ATN.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ATN.h; sourceTree = "<group>"; }; 276E5C1C1CDB57AA003FF4B4 /* ATN.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ATN.h; sourceTree = "<group>"; };
276E5C1D1CDB57AA003FF4B4 /* ATNConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ATNConfig.cpp; sourceTree = "<group>"; }; 276E5C1D1CDB57AA003FF4B4 /* ATNConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ATNConfig.cpp; sourceTree = "<group>"; wrapsLines = 0; };
276E5C1E1CDB57AA003FF4B4 /* ATNConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ATNConfig.h; sourceTree = "<group>"; }; 276E5C1E1CDB57AA003FF4B4 /* ATNConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ATNConfig.h; sourceTree = "<group>"; };
276E5C1F1CDB57AA003FF4B4 /* ATNConfigSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ATNConfigSet.cpp; sourceTree = "<group>"; }; 276E5C1F1CDB57AA003FF4B4 /* ATNConfigSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ATNConfigSet.cpp; sourceTree = "<group>"; };
276E5C201CDB57AA003FF4B4 /* ATNConfigSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ATNConfigSet.h; sourceTree = "<group>"; }; 276E5C201CDB57AA003FF4B4 /* ATNConfigSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ATNConfigSet.h; sourceTree = "<group>"; };
@ -914,7 +914,7 @@
276E5C471CDB57AA003FF4B4 /* LexerActionExecutor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerActionExecutor.h; sourceTree = "<group>"; }; 276E5C471CDB57AA003FF4B4 /* LexerActionExecutor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerActionExecutor.h; sourceTree = "<group>"; };
276E5C481CDB57AA003FF4B4 /* LexerActionType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerActionType.cpp; sourceTree = "<group>"; }; 276E5C481CDB57AA003FF4B4 /* LexerActionType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerActionType.cpp; sourceTree = "<group>"; };
276E5C491CDB57AA003FF4B4 /* LexerActionType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerActionType.h; sourceTree = "<group>"; }; 276E5C491CDB57AA003FF4B4 /* LexerActionType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerActionType.h; sourceTree = "<group>"; };
276E5C4A1CDB57AA003FF4B4 /* LexerATNConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerATNConfig.cpp; sourceTree = "<group>"; }; 276E5C4A1CDB57AA003FF4B4 /* LexerATNConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerATNConfig.cpp; sourceTree = "<group>"; wrapsLines = 0; };
276E5C4B1CDB57AA003FF4B4 /* LexerATNConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerATNConfig.h; sourceTree = "<group>"; }; 276E5C4B1CDB57AA003FF4B4 /* LexerATNConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerATNConfig.h; sourceTree = "<group>"; };
276E5C4C1CDB57AA003FF4B4 /* LexerATNSimulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerATNSimulator.cpp; sourceTree = "<group>"; }; 276E5C4C1CDB57AA003FF4B4 /* LexerATNSimulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerATNSimulator.cpp; sourceTree = "<group>"; };
276E5C4D1CDB57AA003FF4B4 /* LexerATNSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerATNSimulator.h; sourceTree = "<group>"; }; 276E5C4D1CDB57AA003FF4B4 /* LexerATNSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerATNSimulator.h; sourceTree = "<group>"; };
@ -948,7 +948,7 @@
276E5C6A1CDB57AA003FF4B4 /* OrderedATNConfigSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OrderedATNConfigSet.h; sourceTree = "<group>"; }; 276E5C6A1CDB57AA003FF4B4 /* OrderedATNConfigSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OrderedATNConfigSet.h; sourceTree = "<group>"; };
276E5C6B1CDB57AA003FF4B4 /* ParseInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParseInfo.cpp; sourceTree = "<group>"; }; 276E5C6B1CDB57AA003FF4B4 /* ParseInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParseInfo.cpp; sourceTree = "<group>"; };
276E5C6C1CDB57AA003FF4B4 /* ParseInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParseInfo.h; sourceTree = "<group>"; }; 276E5C6C1CDB57AA003FF4B4 /* ParseInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParseInfo.h; sourceTree = "<group>"; };
276E5C6D1CDB57AA003FF4B4 /* ParserATNSimulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParserATNSimulator.cpp; sourceTree = "<group>"; }; 276E5C6D1CDB57AA003FF4B4 /* ParserATNSimulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParserATNSimulator.cpp; sourceTree = "<group>"; wrapsLines = 0; };
276E5C6E1CDB57AA003FF4B4 /* ParserATNSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParserATNSimulator.h; sourceTree = "<group>"; }; 276E5C6E1CDB57AA003FF4B4 /* ParserATNSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParserATNSimulator.h; sourceTree = "<group>"; };
276E5C6F1CDB57AA003FF4B4 /* PlusBlockStartState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlusBlockStartState.cpp; sourceTree = "<group>"; }; 276E5C6F1CDB57AA003FF4B4 /* PlusBlockStartState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlusBlockStartState.cpp; sourceTree = "<group>"; };
276E5C701CDB57AA003FF4B4 /* PlusBlockStartState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlusBlockStartState.h; sourceTree = "<group>"; }; 276E5C701CDB57AA003FF4B4 /* PlusBlockStartState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlusBlockStartState.h; sourceTree = "<group>"; };
@ -966,7 +966,7 @@
276E5C7C1CDB57AA003FF4B4 /* PredictionMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PredictionMode.h; sourceTree = "<group>"; }; 276E5C7C1CDB57AA003FF4B4 /* PredictionMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PredictionMode.h; sourceTree = "<group>"; };
276E5C7D1CDB57AA003FF4B4 /* ProfilingATNSimulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProfilingATNSimulator.cpp; sourceTree = "<group>"; }; 276E5C7D1CDB57AA003FF4B4 /* ProfilingATNSimulator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProfilingATNSimulator.cpp; sourceTree = "<group>"; };
276E5C7E1CDB57AA003FF4B4 /* ProfilingATNSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProfilingATNSimulator.h; sourceTree = "<group>"; }; 276E5C7E1CDB57AA003FF4B4 /* ProfilingATNSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProfilingATNSimulator.h; sourceTree = "<group>"; };
276E5C7F1CDB57AA003FF4B4 /* RangeTransition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RangeTransition.cpp; sourceTree = "<group>"; }; 276E5C7F1CDB57AA003FF4B4 /* RangeTransition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RangeTransition.cpp; sourceTree = "<group>"; wrapsLines = 0; };
276E5C801CDB57AA003FF4B4 /* RangeTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RangeTransition.h; sourceTree = "<group>"; }; 276E5C801CDB57AA003FF4B4 /* RangeTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RangeTransition.h; sourceTree = "<group>"; };
276E5C811CDB57AA003FF4B4 /* RuleStartState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuleStartState.cpp; sourceTree = "<group>"; }; 276E5C811CDB57AA003FF4B4 /* RuleStartState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuleStartState.cpp; sourceTree = "<group>"; };
276E5C821CDB57AA003FF4B4 /* RuleStartState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuleStartState.h; sourceTree = "<group>"; }; 276E5C821CDB57AA003FF4B4 /* RuleStartState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuleStartState.h; sourceTree = "<group>"; };
@ -994,7 +994,7 @@
276E5C981CDB57AA003FF4B4 /* WildcardTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WildcardTransition.h; sourceTree = "<group>"; }; 276E5C981CDB57AA003FF4B4 /* WildcardTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WildcardTransition.h; sourceTree = "<group>"; };
276E5C991CDB57AA003FF4B4 /* BailErrorStrategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BailErrorStrategy.cpp; sourceTree = "<group>"; }; 276E5C991CDB57AA003FF4B4 /* BailErrorStrategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BailErrorStrategy.cpp; sourceTree = "<group>"; };
276E5C9A1CDB57AA003FF4B4 /* BailErrorStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BailErrorStrategy.h; sourceTree = "<group>"; }; 276E5C9A1CDB57AA003FF4B4 /* BailErrorStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BailErrorStrategy.h; sourceTree = "<group>"; };
276E5C9B1CDB57AA003FF4B4 /* BaseErrorListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseErrorListener.cpp; sourceTree = "<group>"; }; 276E5C9B1CDB57AA003FF4B4 /* BaseErrorListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseErrorListener.cpp; sourceTree = "<group>"; wrapsLines = 0; };
276E5C9C1CDB57AA003FF4B4 /* BaseErrorListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseErrorListener.h; sourceTree = "<group>"; }; 276E5C9C1CDB57AA003FF4B4 /* BaseErrorListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseErrorListener.h; sourceTree = "<group>"; };
276E5C9D1CDB57AA003FF4B4 /* BufferedTokenStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BufferedTokenStream.cpp; sourceTree = "<group>"; }; 276E5C9D1CDB57AA003FF4B4 /* BufferedTokenStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BufferedTokenStream.cpp; sourceTree = "<group>"; };
276E5C9E1CDB57AA003FF4B4 /* BufferedTokenStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BufferedTokenStream.h; sourceTree = "<group>"; }; 276E5C9E1CDB57AA003FF4B4 /* BufferedTokenStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BufferedTokenStream.h; sourceTree = "<group>"; };
@ -1006,7 +1006,7 @@
276E5CA41CDB57AA003FF4B4 /* CommonTokenFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonTokenFactory.h; sourceTree = "<group>"; }; 276E5CA41CDB57AA003FF4B4 /* CommonTokenFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonTokenFactory.h; sourceTree = "<group>"; };
276E5CA51CDB57AA003FF4B4 /* CommonTokenStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommonTokenStream.cpp; sourceTree = "<group>"; }; 276E5CA51CDB57AA003FF4B4 /* CommonTokenStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommonTokenStream.cpp; sourceTree = "<group>"; };
276E5CA61CDB57AA003FF4B4 /* CommonTokenStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonTokenStream.h; sourceTree = "<group>"; }; 276E5CA61CDB57AA003FF4B4 /* CommonTokenStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonTokenStream.h; sourceTree = "<group>"; };
276E5CA71CDB57AA003FF4B4 /* ConsoleErrorListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConsoleErrorListener.cpp; sourceTree = "<group>"; }; 276E5CA71CDB57AA003FF4B4 /* ConsoleErrorListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConsoleErrorListener.cpp; sourceTree = "<group>"; wrapsLines = 0; };
276E5CA81CDB57AA003FF4B4 /* ConsoleErrorListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConsoleErrorListener.h; sourceTree = "<group>"; }; 276E5CA81CDB57AA003FF4B4 /* ConsoleErrorListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConsoleErrorListener.h; sourceTree = "<group>"; };
276E5CA91CDB57AA003FF4B4 /* DefaultErrorStrategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DefaultErrorStrategy.cpp; sourceTree = "<group>"; }; 276E5CA91CDB57AA003FF4B4 /* DefaultErrorStrategy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DefaultErrorStrategy.cpp; sourceTree = "<group>"; };
276E5CAA1CDB57AA003FF4B4 /* DefaultErrorStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultErrorStrategy.h; sourceTree = "<group>"; }; 276E5CAA1CDB57AA003FF4B4 /* DefaultErrorStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultErrorStrategy.h; sourceTree = "<group>"; };
@ -1031,7 +1031,7 @@
276E5CBE1CDB57AA003FF4B4 /* IntStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntStream.cpp; sourceTree = "<group>"; }; 276E5CBE1CDB57AA003FF4B4 /* IntStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntStream.cpp; sourceTree = "<group>"; };
276E5CBF1CDB57AA003FF4B4 /* IntStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntStream.h; sourceTree = "<group>"; }; 276E5CBF1CDB57AA003FF4B4 /* IntStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntStream.h; sourceTree = "<group>"; };
276E5CC01CDB57AA003FF4B4 /* IRecognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IRecognizer.h; sourceTree = "<group>"; }; 276E5CC01CDB57AA003FF4B4 /* IRecognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IRecognizer.h; sourceTree = "<group>"; };
276E5CC11CDB57AA003FF4B4 /* Lexer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Lexer.cpp; sourceTree = "<group>"; }; 276E5CC11CDB57AA003FF4B4 /* Lexer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Lexer.cpp; sourceTree = "<group>"; wrapsLines = 0; };
276E5CC21CDB57AA003FF4B4 /* Lexer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Lexer.h; sourceTree = "<group>"; }; 276E5CC21CDB57AA003FF4B4 /* Lexer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Lexer.h; sourceTree = "<group>"; };
276E5CC31CDB57AA003FF4B4 /* LexerInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerInterpreter.cpp; sourceTree = "<group>"; }; 276E5CC31CDB57AA003FF4B4 /* LexerInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LexerInterpreter.cpp; sourceTree = "<group>"; };
276E5CC41CDB57AA003FF4B4 /* LexerInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerInterpreter.h; sourceTree = "<group>"; }; 276E5CC41CDB57AA003FF4B4 /* LexerInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LexerInterpreter.h; sourceTree = "<group>"; };
@ -1084,7 +1084,7 @@
276E5CF51CDB57AA003FF4B4 /* TokenStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TokenStream.cpp; sourceTree = "<group>"; }; 276E5CF51CDB57AA003FF4B4 /* TokenStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TokenStream.cpp; sourceTree = "<group>"; };
276E5CF61CDB57AA003FF4B4 /* TokenStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TokenStream.h; sourceTree = "<group>"; }; 276E5CF61CDB57AA003FF4B4 /* TokenStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TokenStream.h; sourceTree = "<group>"; };
276E5CF71CDB57AA003FF4B4 /* TokenStreamRewriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TokenStreamRewriter.cpp; sourceTree = "<group>"; }; 276E5CF71CDB57AA003FF4B4 /* TokenStreamRewriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TokenStreamRewriter.cpp; sourceTree = "<group>"; };
276E5CF81CDB57AA003FF4B4 /* TokenStreamRewriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TokenStreamRewriter.h; sourceTree = "<group>"; }; 276E5CF81CDB57AA003FF4B4 /* TokenStreamRewriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TokenStreamRewriter.h; sourceTree = "<group>"; wrapsLines = 0; };
276E5CFA1CDB57AA003FF4B4 /* AbstractParseTreeVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractParseTreeVisitor.h; sourceTree = "<group>"; }; 276E5CFA1CDB57AA003FF4B4 /* AbstractParseTreeVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractParseTreeVisitor.h; sourceTree = "<group>"; };
276E5CFB1CDB57AA003FF4B4 /* ErrorNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorNode.h; sourceTree = "<group>"; }; 276E5CFB1CDB57AA003FF4B4 /* ErrorNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorNode.h; sourceTree = "<group>"; };
276E5CFC1CDB57AA003FF4B4 /* ErrorNodeImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorNodeImpl.cpp; sourceTree = "<group>"; }; 276E5CFC1CDB57AA003FF4B4 /* ErrorNodeImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorNodeImpl.cpp; sourceTree = "<group>"; };
@ -1104,13 +1104,13 @@
276E5D0B1CDB57AA003FF4B4 /* ParseTreePattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParseTreePattern.h; sourceTree = "<group>"; }; 276E5D0B1CDB57AA003FF4B4 /* ParseTreePattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParseTreePattern.h; sourceTree = "<group>"; };
276E5D0C1CDB57AA003FF4B4 /* ParseTreePatternMatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParseTreePatternMatcher.cpp; sourceTree = "<group>"; }; 276E5D0C1CDB57AA003FF4B4 /* ParseTreePatternMatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParseTreePatternMatcher.cpp; sourceTree = "<group>"; };
276E5D0D1CDB57AA003FF4B4 /* ParseTreePatternMatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParseTreePatternMatcher.h; sourceTree = "<group>"; }; 276E5D0D1CDB57AA003FF4B4 /* ParseTreePatternMatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParseTreePatternMatcher.h; sourceTree = "<group>"; };
276E5D0E1CDB57AA003FF4B4 /* RuleTagToken.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuleTagToken.cpp; sourceTree = "<group>"; }; 276E5D0E1CDB57AA003FF4B4 /* RuleTagToken.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuleTagToken.cpp; sourceTree = "<group>"; wrapsLines = 0; };
276E5D0F1CDB57AA003FF4B4 /* RuleTagToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuleTagToken.h; sourceTree = "<group>"; }; 276E5D0F1CDB57AA003FF4B4 /* RuleTagToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuleTagToken.h; sourceTree = "<group>"; };
276E5D101CDB57AA003FF4B4 /* TagChunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TagChunk.cpp; sourceTree = "<group>"; }; 276E5D101CDB57AA003FF4B4 /* TagChunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TagChunk.cpp; sourceTree = "<group>"; };
276E5D111CDB57AA003FF4B4 /* TagChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagChunk.h; sourceTree = "<group>"; }; 276E5D111CDB57AA003FF4B4 /* TagChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagChunk.h; sourceTree = "<group>"; };
276E5D121CDB57AA003FF4B4 /* TextChunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextChunk.cpp; sourceTree = "<group>"; }; 276E5D121CDB57AA003FF4B4 /* TextChunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextChunk.cpp; sourceTree = "<group>"; };
276E5D131CDB57AA003FF4B4 /* TextChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextChunk.h; sourceTree = "<group>"; }; 276E5D131CDB57AA003FF4B4 /* TextChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextChunk.h; sourceTree = "<group>"; };
276E5D141CDB57AA003FF4B4 /* TokenTagToken.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TokenTagToken.cpp; sourceTree = "<group>"; }; 276E5D141CDB57AA003FF4B4 /* TokenTagToken.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TokenTagToken.cpp; sourceTree = "<group>"; wrapsLines = 0; };
276E5D151CDB57AA003FF4B4 /* TokenTagToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TokenTagToken.h; sourceTree = "<group>"; }; 276E5D151CDB57AA003FF4B4 /* TokenTagToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TokenTagToken.h; sourceTree = "<group>"; };
276E5D161CDB57AA003FF4B4 /* RuleNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuleNode.h; sourceTree = "<group>"; }; 276E5D161CDB57AA003FF4B4 /* RuleNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuleNode.h; sourceTree = "<group>"; };
276E5D171CDB57AA003FF4B4 /* SyntaxTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SyntaxTree.h; sourceTree = "<group>"; }; 276E5D171CDB57AA003FF4B4 /* SyntaxTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SyntaxTree.h; sourceTree = "<group>"; };
@ -2634,6 +2634,7 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_ASSIGN_ENUM = YES;
CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
@ -2641,6 +2642,8 @@
CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
@ -2655,11 +2658,16 @@
); );
GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 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_SIGN_COMPARE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
src/, src/,
@ -2682,6 +2690,7 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_ASSIGN_ENUM = YES;
CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
@ -2689,6 +2698,8 @@
CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
@ -2697,11 +2708,16 @@
GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_PREFIX_HEADER = "src/antlrcpp-Prefix.h"; GCC_PREFIX_HEADER = "src/antlrcpp-Prefix.h";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 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_SIGN_COMPARE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
src/, src/,

View File

@ -45,6 +45,8 @@ namespace runtime {
/// How to emit recognition errors (an interface in Java). /// How to emit recognition errors (an interface in Java).
class ANTLR4CPP_PUBLIC ANTLRErrorListener { class ANTLR4CPP_PUBLIC ANTLRErrorListener {
public: public:
virtual ~ANTLRErrorListener() {};
/// <summary> /// <summary>
/// Upon syntax error, notify any interested parties. This is not how to /// Upon syntax error, notify any interested parties. This is not how to
/// recover from errors or compute error messages. <seealso cref="ANTLRErrorStrategy"/> /// recover from errors or compute error messages. <seealso cref="ANTLRErrorStrategy"/>

View File

@ -41,7 +41,8 @@ ANTLRFileStream::ANTLRFileStream(const std::string &fileName, const std::string
load(fileName, encoding); 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()) { if (_fileName.empty()) {
return; return;
} }

View File

@ -132,7 +132,7 @@ ssize_t ANTLRInputStream::mark() {
return -1; return -1;
} }
void ANTLRInputStream::release(ssize_t marker) { void ANTLRInputStream::release(ssize_t /* marker */) {
} }
void ANTLRInputStream::seek(size_t index) { void ANTLRInputStream::seek(size_t index) {

View File

@ -83,5 +83,5 @@ Ref<Token> BailErrorStrategy::recoverInline(Parser *recognizer) {
#endif #endif
} }
void BailErrorStrategy::sync(Parser *recognizer) { void BailErrorStrategy::sync(Parser */*recognizer*/) {
} }

View File

@ -34,18 +34,18 @@
using namespace org::antlr::v4::runtime; using namespace org::antlr::v4::runtime;
void BaseErrorListener::syntaxError(IRecognizer *recognizer, Ref<Token> offendingSymbol, size_t line, int charPositionInLine, void BaseErrorListener::syntaxError(IRecognizer */*recognizer*/, Ref<Token> /*offendingSymbol*/, size_t /*line*/,
const std::wstring &msg, std::exception_ptr e) { 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, void BaseErrorListener::reportAmbiguity(Parser */*recognizer*/, const dfa::DFA &/*dfa*/, size_t /*startIndex*/,
bool exact, const antlrcpp::BitSet &ambigAlts, Ref<atn::ATNConfigSet> configs) { size_t /*stopIndex*/, bool /*exact*/, const antlrcpp::BitSet &/*ambigAlts*/, Ref<atn::ATNConfigSet> /*configs*/) {
} }
void BaseErrorListener::reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, void BaseErrorListener::reportAttemptingFullContext(Parser */*recognizer*/, const dfa::DFA &/*dfa*/, size_t /*startIndex*/,
size_t stopIndex, const antlrcpp::BitSet &conflictingAlts, Ref<atn::ATNConfigSet> configs) { size_t /*stopIndex*/, const antlrcpp::BitSet &/*conflictingAlts*/, Ref<atn::ATNConfigSet> /*configs*/) {
} }
void BaseErrorListener::reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, void BaseErrorListener::reportContextSensitivity(Parser */*recognizer*/, const dfa::DFA &/*dfa*/, size_t /*startIndex*/,
int prediction, Ref<atn::ATNConfigSet> configs) { size_t /*stopIndex*/, int /*prediction*/, Ref<atn::ATNConfigSet> /*configs*/) {
} }

View File

@ -57,7 +57,7 @@ ssize_t BufferedTokenStream::mark() {
return 0; return 0;
} }
void BufferedTokenStream::release(ssize_t marker) { void BufferedTokenStream::release(ssize_t /*marker*/) {
// no resources to release // no resources to release
} }

View File

@ -35,7 +35,7 @@ using namespace org::antlr::v4::runtime;
ConsoleErrorListener ConsoleErrorListener::INSTANCE; ConsoleErrorListener ConsoleErrorListener::INSTANCE;
void ConsoleErrorListener::syntaxError(IRecognizer *recognizer, Ref<Token> offendingSymbol, void ConsoleErrorListener::syntaxError(IRecognizer */*recognizer*/, Ref<Token> /*offendingSymbol*/,
size_t line, int charPositionInLine, const std::wstring &msg, std::exception_ptr e) { size_t line, int charPositionInLine, const std::wstring &msg, std::exception_ptr /*e*/) {
std::wcerr << L"line " << line << L":" << charPositionInLine << L" " << msg << std::endl; std::wcerr << L"line " << line << L":" << charPositionInLine << L" " << msg << std::endl;
} }

View File

@ -52,15 +52,15 @@ void DefaultErrorStrategy::reset(Parser *recognizer) {
endErrorCondition(recognizer); endErrorCondition(recognizer);
} }
void DefaultErrorStrategy::beginErrorCondition(Parser *recognizer) { void DefaultErrorStrategy::beginErrorCondition(Parser */*recognizer*/) {
errorRecoveryMode = true; errorRecoveryMode = true;
} }
bool DefaultErrorStrategy::inErrorRecoveryMode(Parser *recognizer) { bool DefaultErrorStrategy::inErrorRecoveryMode(Parser */*recognizer*/) {
return errorRecoveryMode; return errorRecoveryMode;
} }
void DefaultErrorStrategy::endErrorCondition(Parser *recognizer) { void DefaultErrorStrategy::endErrorCondition(Parser */*recognizer*/) {
errorRecoveryMode = false; errorRecoveryMode = false;
lastErrorIndex = -1; 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() && if (lastErrorIndex == (int)recognizer->getInputStream()->index() &&
lastErrorStates.contains(recognizer->getState())) { lastErrorStates.contains(recognizer->getState())) {

View File

@ -62,7 +62,7 @@ void DiagnosticErrorListener::reportAmbiguity(Parser *recognizer, const dfa::DFA
} }
void DiagnosticErrorListener::reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, void DiagnosticErrorListener::reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex,
size_t stopIndex, const antlrcpp::BitSet &conflictingAlts, Ref<atn::ATNConfigSet> configs) { size_t stopIndex, const antlrcpp::BitSet &/*conflictingAlts*/, Ref<atn::ATNConfigSet> /*configs*/) {
std::wstring decision = getDecisionDescription(recognizer, dfa); std::wstring decision = getDecisionDescription(recognizer, dfa);
std::wstring text = recognizer->getTokenStream()->getText(misc::Interval((int)startIndex, (int)stopIndex)); std::wstring text = recognizer->getTokenStream()->getText(misc::Interval((int)startIndex, (int)stopIndex));
std::wstring message = L"reportAttemptingFullContext d = " + decision + L", input = '" + text + L"'"; 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, void DiagnosticErrorListener::reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex,
size_t stopIndex, int prediction, Ref<atn::ATNConfigSet> configs) { size_t stopIndex, int /*prediction*/, Ref<atn::ATNConfigSet> /*configs*/) {
std::wstring decision = getDecisionDescription(recognizer, dfa); std::wstring decision = getDecisionDescription(recognizer, dfa);
std::wstring text = recognizer->getTokenStream()->getText(misc::Interval((int)startIndex, (int)stopIndex)); std::wstring text = recognizer->getTokenStream()->getText(misc::Interval((int)startIndex, (int)stopIndex));
std::wstring message = L"reportContextSensitivity d = " + decision + L", input = '" + text + L"'"; std::wstring message = L"reportContextSensitivity d = " + decision + L", input = '" + text + L"'";

View File

@ -38,6 +38,7 @@ namespace runtime {
class ANTLR4CPP_PUBLIC IRecognizer { class ANTLR4CPP_PUBLIC IRecognizer {
public: public:
virtual ~IRecognizer() {};
virtual int getState() = 0; virtual int getState() = 0;

View File

@ -65,6 +65,8 @@ namespace runtime {
/// </summary> /// </summary>
static const std::string UNKNOWN_SOURCE_NAME; static const std::string UNKNOWN_SOURCE_NAME;
virtual ~IntStream() {};
/// <summary> /// <summary>
/// Consumes the current symbol in the stream. This method has the following /// Consumes the current symbol in the stream. This method has the following
/// effects: /// effects:

View File

@ -252,7 +252,7 @@ std::vector<Ref<Token>> Lexer::getAllTokens() {
return tokens; return tokens;
} }
void Lexer::recover(const LexerNoViableAltException &e) { void Lexer::recover(const LexerNoViableAltException &/*e*/) {
if (_input->LA(1) != EOF) { if (_input->LA(1) != EOF) {
// skip a char and try again // skip a char and try again
getInterpreter<atn::LexerATNSimulator>()->consume(_input); getInterpreter<atn::LexerATNSimulator>()->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"'"); std::wstring msg = std::wstring(L"token recognition error at: '") + getErrorDisplay(text) + std::wstring(L"'");
ProxyErrorListener &listener = getErrorListenerDispatch(); 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) { 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"'"); 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? // TO_DO: Do we lose character or line position information?
_input->consume(); _input->consume();
} }

View File

@ -89,9 +89,10 @@ namespace runtime {
/// <exception cref="NullPointerException"> if {@code tokens} is {@code null} </exception> /// <exception cref="NullPointerException"> if {@code tokens} is {@code null} </exception>
public: public:
template<typename T1> //where T1 : Token template<typename T1>
ListTokenSource(std::vector<T1> tokens) //this(tokens, nullptr); ListTokenSource(std::vector<T1> tokens) : ListTokenSource(tokens, "") {
{} }
/// <summary> /// <summary>
/// Constructs a new <seealso cref="ListTokenSource"/> instance from the specified /// Constructs a new <seealso cref="ListTokenSource"/> instance from the specified
/// collection of <seealso cref="Token"/> objects and source name. /// collection of <seealso cref="Token"/> objects and source name.
@ -104,9 +105,8 @@ namespace runtime {
/// been reached). /// been reached).
/// </param> /// </param>
/// <exception cref="NullPointerException"> if {@code tokens} is {@code null} </exception> /// <exception cref="NullPointerException"> if {@code tokens} is {@code null} </exception>
template<typename T1>
template<typename T1> //where T1 : Token ListTokenSource(std::vector<T1> tokens, const std::string &/*sourceName*/) {
ListTokenSource(std::vector<T1> tokens, const std::string &sourceName) {
InitializeInstanceFields(); InitializeInstanceFields();
if (tokens.empty()) { if (tokens.empty()) {
throw L"tokens cannot be null"; throw L"tokens cannot be null";

View File

@ -74,7 +74,7 @@ void Parser::TraceListener::visitTerminal(Ref<tree::TerminalNode> node) {
<< std::endl; << std::endl;
} }
void Parser::TraceListener::visitErrorNode(Ref<tree::ErrorNode> node) { void Parser::TraceListener::visitErrorNode(Ref<tree::ErrorNode> /*node*/) {
} }
void Parser::TraceListener::exitEveryRule(Ref<ParserRuleContext> ctx) { void Parser::TraceListener::exitEveryRule(Ref<ParserRuleContext> ctx) {
@ -87,13 +87,13 @@ void Parser::TraceListener::exitEveryRule(Ref<ParserRuleContext> ctx) {
const Ref<Parser::TrimToSizeListener> Parser::TrimToSizeListener::INSTANCE = const Ref<Parser::TrimToSizeListener> Parser::TrimToSizeListener::INSTANCE =
std::make_shared<Parser::TrimToSizeListener>(); std::make_shared<Parser::TrimToSizeListener>();
void Parser::TrimToSizeListener::enterEveryRule(Ref<ParserRuleContext> ctx) { void Parser::TrimToSizeListener::enterEveryRule(Ref<ParserRuleContext> /*ctx*/) {
} }
void Parser::TrimToSizeListener::visitTerminal(Ref<tree::TerminalNode> node) { void Parser::TrimToSizeListener::visitTerminal(Ref<tree::TerminalNode> /*node*/) {
} }
void Parser::TrimToSizeListener::visitErrorNode(Ref<tree::ErrorNode> node) { void Parser::TrimToSizeListener::visitErrorNode(Ref<tree::ErrorNode> /*node*/) {
} }
void Parser::TrimToSizeListener::exitEveryRule(Ref<ParserRuleContext> ctx) { void Parser::TrimToSizeListener::exitEveryRule(Ref<ParserRuleContext> ctx) {
@ -351,7 +351,7 @@ void Parser::addContextToParseTree() {
parent->addChild(_ctx); parent->addChild(_ctx);
} }
void Parser::enterRule(Ref<ParserRuleContext> localctx, int state, int ruleIndex) { void Parser::enterRule(Ref<ParserRuleContext> localctx, int state, int /*ruleIndex*/) {
setState(state); setState(state);
_ctx = localctx; _ctx = localctx;
_ctx->start = _input->LT(1); _ctx->start = _input->LT(1);
@ -407,7 +407,7 @@ void Parser::enterRecursionRule(Ref<ParserRuleContext> localctx, int ruleIndex)
enterRecursionRule(localctx, getATN().ruleToStartState[(size_t)ruleIndex]->stateNumber, ruleIndex, 0); enterRecursionRule(localctx, getATN().ruleToStartState[(size_t)ruleIndex]->stateNumber, ruleIndex, 0);
} }
void Parser::enterRecursionRule(Ref<ParserRuleContext> localctx, int state, int ruleIndex, int precedence) { void Parser::enterRecursionRule(Ref<ParserRuleContext> localctx, int state, int /*ruleIndex*/, int precedence) {
setState(state); setState(state);
_precedenceStack.push_back(precedence); _precedenceStack.push_back(precedence);
_ctx = localctx; _ctx = localctx;
@ -417,7 +417,7 @@ void Parser::enterRecursionRule(Ref<ParserRuleContext> localctx, int state, int
} }
} }
void Parser::pushNewRecursionContext(Ref<ParserRuleContext> localctx, int state, int ruleIndex) { void Parser::pushNewRecursionContext(Ref<ParserRuleContext> localctx, int state, int /*ruleIndex*/) {
Ref<ParserRuleContext> previous = _ctx; Ref<ParserRuleContext> previous = _ctx;
previous->parent = localctx; previous->parent = localctx;
previous->invokingState = state; previous->invokingState = state;
@ -479,11 +479,11 @@ void Parser::setContext(Ref<ParserRuleContext> ctx) {
_ctx = ctx; _ctx = ctx;
} }
bool Parser::precpred(Ref<RuleContext> localctx, int precedence) { bool Parser::precpred(Ref<RuleContext> /*localctx*/, int precedence) {
return precedence >= _precedenceStack.back(); return precedence >= _precedenceStack.back();
} }
bool Parser::inContext(const std::wstring &context) { bool Parser::inContext(const std::wstring &/*context*/) {
// TO_DO: useful in parser? // TO_DO: useful in parser?
return false; return false;
} }

View File

@ -64,6 +64,8 @@ namespace runtime {
public: public:
static const Ref<TrimToSizeListener> INSTANCE; static const Ref<TrimToSizeListener> INSTANCE;
virtual ~TrimToSizeListener() {};
virtual void enterEveryRule(Ref<ParserRuleContext> ctx) override; virtual void enterEveryRule(Ref<ParserRuleContext> ctx) override;
virtual void visitTerminal(Ref<tree::TerminalNode> node) override; virtual void visitTerminal(Ref<tree::TerminalNode> node) override;
virtual void visitErrorNode(Ref<tree::ErrorNode> node) override; virtual void visitErrorNode(Ref<tree::ErrorNode> node) override;

View File

@ -56,10 +56,10 @@ ParserRuleContext::ParserRuleContext(std::weak_ptr<ParserRuleContext> parent, in
: RuleContext(parent, invokingStateNumber) { : RuleContext(parent, invokingStateNumber) {
} }
void ParserRuleContext::enterRule(Ref<tree::ParseTreeListener> listener) { void ParserRuleContext::enterRule(Ref<tree::ParseTreeListener> /*listener*/) {
} }
void ParserRuleContext::exitRule(Ref<tree::ParseTreeListener> listener) { void ParserRuleContext::exitRule(Ref<tree::ParseTreeListener> /*listener*/) {
} }
Ref<tree::TerminalNode> ParserRuleContext::addChild(Ref<tree::TerminalNode> t) { Ref<tree::TerminalNode> ParserRuleContext::addChild(Ref<tree::TerminalNode> t) {

View File

@ -46,7 +46,7 @@ RecognitionException::RecognitionException(IRecognizer *recognizer, IntStream *i
RecognitionException::RecognitionException(const std::string &message, IRecognizer *recognizer, IntStream *input, RecognitionException::RecognitionException(const std::string &message, IRecognizer *recognizer, IntStream *input,
Ref<ParserRuleContext> ctx, Ref<Token> offendingToken) Ref<ParserRuleContext> ctx, Ref<Token> offendingToken)
: RuntimeException(message), _recognizer(recognizer), _input(input), _offendingToken(offendingToken), _ctx(ctx) { : RuntimeException(message), _recognizer(recognizer), _input(input), _ctx(ctx), _offendingToken(offendingToken) {
InitializeInstanceFields(); InitializeInstanceFields();
if (recognizer != nullptr) { if (recognizer != nullptr) {
_offendingState = recognizer->getState(); _offendingState = recognizer->getState();

View File

@ -167,15 +167,15 @@ ProxyErrorListener& Recognizer::getErrorListenerDispatch() {
return _proxListener; return _proxListener;
} }
bool Recognizer::sempred(Ref<RuleContext> localctx, int ruleIndex, int actionIndex) { bool Recognizer::sempred(Ref<RuleContext> /*localctx*/, int /*ruleIndex*/, int /*actionIndex*/) {
return true; return true;
} }
bool Recognizer::precpred(Ref<RuleContext> localctx, int precedence) { bool Recognizer::precpred(Ref<RuleContext> /*localctx*/, int /*precedence*/) {
return true; return true;
} }
void Recognizer::action(Ref<RuleContext> localctx, int ruleIndex, int actionIndex) { void Recognizer::action(Ref<RuleContext> /*localctx*/, int /*ruleIndex*/, int /*actionIndex*/) {
} }
int Recognizer::getState() { int Recognizer::getState() {

View File

@ -42,6 +42,7 @@ namespace runtime {
class ANTLR4CPP_PUBLIC Recognizer : public IRecognizer { class ANTLR4CPP_PUBLIC Recognizer : public IRecognizer {
public: public:
Recognizer(); Recognizer();
virtual ~Recognizer() {};
/** Used to print out token names like ID during debugging and /** Used to print out token names like ID during debugging and
* error reporting. The generated parsers implement a method * error reporting. The generated parsers implement a method

View File

@ -98,7 +98,7 @@ ssize_t RuleContext::getRuleIndex() const {
return -1; return -1;
} }
Ref<tree::Tree> RuleContext::getChildReference(size_t i) { Ref<tree::Tree> RuleContext::getChildReference(size_t /*i*/) {
return Ref<tree::Tree>(); return Ref<tree::Tree>();
} }
@ -107,7 +107,7 @@ int RuleContext::getAltNumber() const {
return atn::ATN::INVALID_ALT_NUMBER; return atn::ATN::INVALID_ALT_NUMBER;
} }
void RuleContext::setAltNumber(int altNumber) { void RuleContext::setAltNumber(int /*altNumber*/) {
} }
std::size_t RuleContext::getChildCount() { std::size_t RuleContext::getChildCount() {

View File

@ -41,12 +41,12 @@ namespace runtime {
/// of a new factory means that it notifies it's token source and error strategy. /// of a new factory means that it notifies it's token source and error strategy.
template<typename Symbol> template<typename Symbol>
class ANTLR4CPP_PUBLIC TokenFactory { class ANTLR4CPP_PUBLIC TokenFactory {
/// <summary> public:
virtual ~TokenFactory() {};
/// This is the method used to create tokens in the lexer and in the /// 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 /// 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. /// are wiped to -1 in the text override is set in the CommonToken.
/// </summary>
public:
virtual Ref<Symbol> create(std::pair<TokenSource*, CharStream*> source, int type, const std::wstring &text, virtual Ref<Symbol> create(std::pair<TokenSource*, CharStream*> source, int type, const std::wstring &text,
int channel, int start, int stop, int line, int charPositionInLine) = 0; int channel, int start, int stop, int line, int charPositionInLine) = 0;

View File

@ -54,13 +54,13 @@ namespace runtime {
/// going, looking for a valid token. /// going, looking for a valid token.
/// </summary> /// </summary>
class ANTLR4CPP_PUBLIC TokenSource { class ANTLR4CPP_PUBLIC TokenSource {
/// <summary> public:
virtual ~TokenSource() {};
/// Return a <seealso cref="Token"/> object from your input stream (usually a /// Return a <seealso cref="Token"/> object from your input stream (usually a
/// <seealso cref="CharStream"/>). Do not fail/return upon lexing error; keep chewing /// <seealso cref="CharStream"/>). Do not fail/return upon lexing error; keep chewing
/// on the characters until you get a good one; errors are not passed through /// on the characters until you get a good one; errors are not passed through
/// to the parser. /// to the parser.
/// </summary>
public:
virtual Ref<Token> nextToken() = 0; virtual Ref<Token> nextToken() = 0;
/// <summary> /// <summary>
@ -101,7 +101,7 @@ namespace runtime {
/// </summary> /// </summary>
/// <param name="factory"> The <seealso cref="TokenFactory"/> to use for creating tokens. </param> /// <param name="factory"> The <seealso cref="TokenFactory"/> to use for creating tokens. </param>
template<typename T1> template<typename T1>
void setTokenFactory(TokenFactory<T1> *factory) {}; void setTokenFactory(TokenFactory<T1> */*factory*/) {};
/// <summary> /// <summary>
/// Gets the <seealso cref="TokenFactory"/> this token source is currently using for /// Gets the <seealso cref="TokenFactory"/> this token source is currently using for

View File

@ -56,7 +56,7 @@ TokenStreamRewriter::RewriteOperation::RewriteOperation(TokenStreamRewriter *out
this->text = text; this->text = text;
} }
size_t TokenStreamRewriter::RewriteOperation::execute(std::wstring *buf) { size_t TokenStreamRewriter::RewriteOperation::execute(std::wstring */*buf*/) {
return index; return index;
} }

View File

@ -314,7 +314,7 @@ namespace runtime {
/// <summary> /// <summary>
/// Get all operations before an index of a particular kind </summary> /// Get all operations before an index of a particular kind </summary>
template <typename T, typename T1> template <typename T, typename T1>
std::vector<T*> getKindOfOps(std::vector<T1*> rewrites, T *kind, size_t before) { std::vector<T*> getKindOfOps(std::vector<T1*> rewrites, T */*kind*/, size_t before) {
std::vector<T*> ops = std::vector<T*>(); std::vector<T*> ops = std::vector<T*>();
for (size_t i = 0; i < before && i < rewrites.size(); i++) { for (size_t i = 0; i < before && i < rewrites.size(); i++) {
TokenStreamRewriter::RewriteOperation *op = dynamic_cast<RewriteOperation*>(rewrites[i]); TokenStreamRewriter::RewriteOperation *op = dynamic_cast<RewriteOperation*>(rewrites[i]);

View File

@ -45,7 +45,7 @@ using namespace org::antlr::v4::runtime;
UnbufferedTokenStream::UnbufferedTokenStream(TokenSource *tokenSource) : UnbufferedTokenStream(tokenSource, 256) { UnbufferedTokenStream::UnbufferedTokenStream(TokenSource *tokenSource) : UnbufferedTokenStream(tokenSource, 256) {
} }
UnbufferedTokenStream::UnbufferedTokenStream(TokenSource *tokenSource, int bufferSize) : _tokenSource(tokenSource) UnbufferedTokenStream::UnbufferedTokenStream(TokenSource *tokenSource, int /*bufferSize*/) : _tokenSource(tokenSource)
{ {
InitializeInstanceFields(); InitializeInstanceFields();
fill(1); // prime the pump fill(1); // prime the pump

View File

@ -44,6 +44,8 @@ namespace dfa {
/// @author Sam Harwell </seealso> /// @author Sam Harwell </seealso>
class ANTLR4CPP_PUBLIC Vocabulary { class ANTLR4CPP_PUBLIC Vocabulary {
public: public:
virtual ~Vocabulary() {};
/// <summary> /// <summary>
/// Returns the highest token type value. It can be used to iterate from /// Returns the highest token type value. It can be used to iterate from
/// zero to that number, inclusively, thus querying all stored entries. </summary> /// zero to that number, inclusively, thus querying all stored entries. </summary>

View File

@ -43,6 +43,8 @@ namespace dfa {
/// interface. /// interface.
class ANTLR4CPP_PUBLIC VocabularyImpl : public Vocabulary { class ANTLR4CPP_PUBLIC VocabularyImpl : public Vocabulary {
public: public:
virtual ~VocabularyImpl() {};
/// Gets an empty <seealso cref="Vocabulary"/> instance. /// Gets an empty <seealso cref="Vocabulary"/> instance.
/// ///
/// <para> /// <para>

View File

@ -47,7 +47,7 @@ namespace atn {
ATN(); ATN();
ATN(ATN &&other); ATN(ATN &&other);
ATN(ATNType grammarType, size_t maxTokenType); ATN(ATNType grammarType, size_t maxTokenType);
~ATN(); virtual ~ATN();
std::vector<ATNState *> states; std::vector<ATNState *> states;

View File

@ -67,7 +67,8 @@ ATNConfig::ATNConfig(Ref<ATNConfig> c, ATNState *state, Ref<PredictionContext> c
} }
ATNConfig::ATNConfig(Ref<ATNConfig> c, ATNState *state, Ref<PredictionContext> context, Ref<SemanticContext> semanticContext) ATNConfig::ATNConfig(Ref<ATNConfig> c, ATNState *state, Ref<PredictionContext> context, Ref<SemanticContext> 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() { ATNConfig::~ATNConfig() {

View File

@ -275,7 +275,7 @@ std::wstring ATNConfigSet::toString() {
return ss.str(); return ss.str();
} }
bool ATNConfigSet::remove(void *o) { bool ATNConfigSet::remove(void */*o*/) {
throw UnsupportedOperationException(); throw UnsupportedOperationException();
} }

View File

@ -47,8 +47,8 @@ namespace atn {
public: public:
ATNDeserializationOptions(); ATNDeserializationOptions();
ATNDeserializationOptions(ATNDeserializationOptions *options); ATNDeserializationOptions(ATNDeserializationOptions *options);
virtual ~ATNDeserializationOptions() {};
static const ATNDeserializationOptions& getDefaultOptions(); static const ATNDeserializationOptions& getDefaultOptions();

View File

@ -130,9 +130,9 @@ bool ATNDeserializer::isFeatureSupported(const Guid &feature, const Guid &actual
ATN ATNDeserializer::deserialize(const std::wstring& input) { ATN ATNDeserializer::deserialize(const std::wstring& input) {
// Don't adjust the first value since that's the version number. // Don't adjust the first value since that's the version number.
std::vector<uint16_t> data(input.size()); std::vector<uint16_t> data(input.size());
data[0] = input[0]; data[0] = (uint16_t)input[0];
for (size_t i = 1; i < input.size(); ++i) { for (size_t i = 1; i < input.size(); ++i) {
data[i] = input[i] - 2; data[i] = (uint16_t)input[i] - 2;
} }
int p = 0; 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. */ /* 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<misc::IntervalSet> &sets) { const std::vector<misc::IntervalSet> &sets) {
ATNState *target = atn.states[(size_t)trg]; ATNState *target = atn.states[(size_t)trg];

View File

@ -50,6 +50,7 @@ namespace atn {
ATNDeserializer(); ATNDeserializer();
ATNDeserializer(const ATNDeserializationOptions& dso); ATNDeserializer(const ATNDeserializationOptions& dso);
virtual ~ATNDeserializer() {};
static Guid toUUID(const unsigned short *data, int offset); static Guid toUUID(const unsigned short *data, int offset);

View File

@ -42,7 +42,7 @@
#include "SetTransition.h" #include "SetTransition.h"
#include "Token.h" #include "Token.h"
#include "Interval.h" #include "Interval.h"
#include "atn.h" #include "ATN.h"
#include "RuleTransition.h" #include "RuleTransition.h"
#include "PrecedencePredicateTransition.h" #include "PrecedencePredicateTransition.h"
@ -73,7 +73,7 @@ ATNSerializer::ATNSerializer(ATN *atn) { this->atn = atn; }
ATNSerializer::ATNSerializer(ATN *atn, const std::vector<std::wstring> &tokenNames) { ATNSerializer::ATNSerializer(ATN *atn, const std::vector<std::wstring> &tokenNames) {
this->atn = atn; this->atn = atn;
this->tokenNames = tokenNames; _tokenNames = tokenNames;
} }
std::vector<size_t> ATNSerializer::serialize() { std::vector<size_t> ATNSerializer::serialize() {
@ -396,11 +396,11 @@ std::wstring ATNSerializer::decode(const std::wstring &inpdata) {
throw IllegalArgumentException("Not enough data to decode"); throw IllegalArgumentException("Not enough data to decode");
std::vector<uint16_t> data(inpdata.size()); std::vector<uint16_t> 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. // Don't adjust the first value since that's the version number.
for (size_t i = 1; i < inpdata.size(); ++i) { for (size_t i = 1; i < inpdata.size(); ++i) {
data[i] = inpdata[i] - 2; data[i] = (uint16_t)inpdata[i] - 2;
} }
std::wstring buf; 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()) { if (_tokenNames.size() > 0 && t >= 0 && t < (ssize_t)_tokenNames.size()) {
return tokenNames[(size_t)t]; return _tokenNames[(size_t)t];
} }
return std::to_wstring(t); return std::to_wstring(t);

View File

@ -41,12 +41,9 @@ namespace atn {
public: public:
ATN *atn; ATN *atn;
private:
std::vector<std::wstring> tokenNames;
public:
ATNSerializer(ATN *atn); ATNSerializer(ATN *atn);
ATNSerializer(ATN *atn, const std::vector<std::wstring> &tokenNames); ATNSerializer(ATN *atn, const std::vector<std::wstring> &tokenNames);
virtual ~ATNSerializer() {};
/// <summary> /// <summary>
/// Serialize state descriptors, edge descriptors, and decision->state map /// Serialize state descriptors, edge descriptors, and decision->state map
@ -85,6 +82,8 @@ namespace atn {
static std::wstring getDecoded(ATN *atn, std::vector<std::wstring> &tokenNames); static std::wstring getDecoded(ATN *atn, std::vector<std::wstring> &tokenNames);
private: private:
std::vector<std::wstring> _tokenNames;
void serializeUUID(std::vector<size_t> &data, Guid uuid); void serializeUUID(std::vector<size_t> &data, Guid uuid);
}; };

View File

@ -48,9 +48,11 @@ ATNState::~ATNState() {
} }
}; };
const std::vector<std::wstring> ATNState::serializationNames = { L"INVALID", L"BASIC", L"RULE_START", L"BLOCK_START", const std::vector<std::wstring> 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"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() { size_t ATNState::hashCode() {
return (size_t)stateNumber; return (size_t)stateNumber;

View File

@ -49,7 +49,7 @@ bool ActionTransition::isEpsilon() const {
return true; // we are to be ignored by analysis 'cept for predicates 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; return false;
} }

View File

@ -55,6 +55,7 @@ namespace atn {
ArrayPredictionContext(Ref<SingletonPredictionContext> a); ArrayPredictionContext(Ref<SingletonPredictionContext> a);
ArrayPredictionContext(const std::vector<std::weak_ptr<PredictionContext>> &parents, ArrayPredictionContext(const std::vector<std::weak_ptr<PredictionContext>> &parents,
const std::vector<int> &returnStates); const std::vector<int> &returnStates);
virtual ~ArrayPredictionContext() {};
virtual bool isEmpty() const override; virtual bool isEmpty() const override;
virtual size_t size() const override; virtual size_t size() const override;

View File

@ -48,7 +48,7 @@ IntervalSet AtomTransition::label() const {
return IntervalSet::of(_label); 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; return _label == symbol;
} }

View File

@ -67,6 +67,8 @@ namespace atn {
protected: protected:
class ConfigLookupIteratorImpl { class ConfigLookupIteratorImpl {
public: public:
virtual ~ConfigLookupIteratorImpl () {};
virtual ConfigLookupIteratorImpl& operator ++ () = 0; virtual ConfigLookupIteratorImpl& operator ++ () = 0;
virtual bool operator != (const ConfigLookupIteratorImpl&) const = 0; virtual bool operator != (const ConfigLookupIteratorImpl&) const = 0;
virtual Ref<ATNConfig> operator * () const = 0; virtual Ref<ATNConfig> operator * () const = 0;

View File

@ -44,11 +44,11 @@ size_t EmptyPredictionContext::size() const {
return 1; return 1;
} }
std::weak_ptr<PredictionContext> EmptyPredictionContext::getParent(size_t index) const { std::weak_ptr<PredictionContext> EmptyPredictionContext::getParent(size_t /*index*/) const {
return std::weak_ptr<PredictionContext>(); return std::weak_ptr<PredictionContext>();
} }
int EmptyPredictionContext::getReturnState(size_t index) const { int EmptyPredictionContext::getReturnState(size_t /*index*/) const {
return returnState; return returnState;
} }

View File

@ -52,7 +52,7 @@ bool EpsilonTransition::isEpsilon() const {
return true; return true;
} }
bool EpsilonTransition::matches(int symbol, int minVocabSymbol, int maxVocabSymbol) const { bool EpsilonTransition::matches(int /*symbol*/, int /*minVocabSymbol*/, int /*maxVocabSymbol*/) const {
return false; return false;
} }

View File

@ -43,16 +43,15 @@ namespace runtime {
namespace atn { namespace atn {
class ANTLR4CPP_PUBLIC LL1Analyzer { class ANTLR4CPP_PUBLIC LL1Analyzer {
/// <summary> public:
/// Special value added to the lookahead sets to indicate that we hit /// Special value added to the lookahead sets to indicate that we hit
/// a predicate during analysis if {@code seeThruPreds==false}. /// a predicate during analysis if {@code seeThruPreds==false}.
/// </summary>
public:
static const int HIT_PRED = Token::INVALID_TYPE; static const int HIT_PRED = Token::INVALID_TYPE;
const atn::ATN &_atn; const atn::ATN &_atn;
LL1Analyzer(const atn::ATN &atn); LL1Analyzer(const atn::ATN &atn);
virtual ~LL1Analyzer() {};
/// <summary> /// <summary>
/// Calculates the SLL(1) expected lookahead set for each outgoing transition /// Calculates the SLL(1) expected lookahead set for each outgoing transition

View File

@ -48,23 +48,23 @@ LexerATNConfig::LexerATNConfig(ATNState *state, int alt, Ref<PredictionContext>
LexerATNConfig::LexerATNConfig(ATNState *state, int alt, Ref<PredictionContext> context, LexerATNConfig::LexerATNConfig(ATNState *state, int alt, Ref<PredictionContext> context,
Ref<LexerActionExecutor> lexerActionExecutor) Ref<LexerActionExecutor> lexerActionExecutor)
: ATNConfig(state, alt, context, SemanticContext::NONE), _passedThroughNonGreedyDecision(false), : ATNConfig(state, alt, context, SemanticContext::NONE), _lexerActionExecutor(lexerActionExecutor),
_lexerActionExecutor(lexerActionExecutor) { _passedThroughNonGreedyDecision(false) {
} }
LexerATNConfig::LexerATNConfig(Ref<LexerATNConfig> c, ATNState *state) LexerATNConfig::LexerATNConfig(Ref<LexerATNConfig> c, ATNState *state)
: ATNConfig(c, state, c->context, c->semanticContext), _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)), : ATNConfig(c, state, c->context, c->semanticContext), _lexerActionExecutor(c->_lexerActionExecutor),
_lexerActionExecutor(c->_lexerActionExecutor) { _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)) {
} }
LexerATNConfig::LexerATNConfig(Ref<LexerATNConfig> c, ATNState *state, Ref<LexerActionExecutor> lexerActionExecutor) LexerATNConfig::LexerATNConfig(Ref<LexerATNConfig> c, ATNState *state, Ref<LexerActionExecutor> lexerActionExecutor)
: ATNConfig(c, state, c->context, c->semanticContext), _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)), : ATNConfig(c, state, c->context, c->semanticContext), _lexerActionExecutor(lexerActionExecutor),
_lexerActionExecutor(lexerActionExecutor) { _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)) {
} }
LexerATNConfig::LexerATNConfig(Ref<LexerATNConfig> c, ATNState *state, Ref<PredictionContext> context) LexerATNConfig::LexerATNConfig(Ref<LexerATNConfig> c, ATNState *state, Ref<PredictionContext> context)
: ATNConfig(c, state, context, c->semanticContext), _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)), : ATNConfig(c, state, context, c->semanticContext), _lexerActionExecutor(c->_lexerActionExecutor),
_lexerActionExecutor(c->_lexerActionExecutor) { _passedThroughNonGreedyDecision(checkNonGreedyDecision(c, state)) {
} }
Ref<LexerActionExecutor> LexerATNConfig::getLexerActionExecutor() const { Ref<LexerActionExecutor> LexerATNConfig::getLexerActionExecutor() const {

View File

@ -311,7 +311,7 @@ void LexerATNSimulator::getReachableConfigSet(CharStream *input, Ref<ATNConfigSe
} }
} }
void LexerATNSimulator::accept(CharStream *input, Ref<LexerActionExecutor> lexerActionExecutor, int startIndex, void LexerATNSimulator::accept(CharStream *input, Ref<LexerActionExecutor> lexerActionExecutor, int /*startIndex*/,
size_t index, size_t line, size_t charPos) { size_t index, size_t line, size_t charPos) {
if (debug) { if (debug) {
std::wcout << L"ACTION "; std::wcout << L"ACTION ";

View File

@ -45,6 +45,9 @@ namespace atn {
class ANTLR4CPP_PUBLIC LexerATNSimulator : public ATNSimulator { class ANTLR4CPP_PUBLIC LexerATNSimulator : public ATNSimulator {
protected: protected:
class SimState { class SimState {
public:
virtual ~SimState() {};
protected: protected:
int index; int index;
size_t line; size_t line;

View File

@ -52,6 +52,7 @@ namespace atn {
/// Constructs an executor for a sequence of <seealso cref="LexerAction"/> actions. </summary> /// Constructs an executor for a sequence of <seealso cref="LexerAction"/> actions. </summary>
/// <param name="lexerActions"> The lexer actions to execute. </param> /// <param name="lexerActions"> The lexer actions to execute. </param>
LexerActionExecutor(const std::vector<Ref<LexerAction>> &lexerActions); LexerActionExecutor(const std::vector<Ref<LexerAction>> &lexerActions);
virtual ~LexerActionExecutor() {};
/// <summary> /// <summary>
/// Creates a <seealso cref="LexerActionExecutor"/> which executes the actions for /// Creates a <seealso cref="LexerActionExecutor"/> which executes the actions for

View File

@ -46,6 +46,7 @@ namespace atn {
class ANTLR4CPP_PUBLIC ParseInfo { class ANTLR4CPP_PUBLIC ParseInfo {
public: public:
ParseInfo(ProfilingATNSimulator *atnSimulator); ParseInfo(ProfilingATNSimulator *atnSimulator);
virtual ~ParseInfo() {};
/// <summary> /// <summary>
/// Gets an array of <seealso cref="DecisionInfo"/> instances containing the profiling /// Gets an array of <seealso cref="DecisionInfo"/> instances containing the profiling

View File

@ -846,8 +846,8 @@ BitSet ParserATNSimulator::evalSemanticContext(std::vector<dfa::DFAState::PredPr
return predictions; return predictions;
} }
bool ParserATNSimulator::evalSemanticContext(Ref<SemanticContext> pred, Ref<ParserRuleContext> parserCallStack, int alt, bool ParserATNSimulator::evalSemanticContext(Ref<SemanticContext> pred, Ref<ParserRuleContext> parserCallStack,
bool fullCtx) { int /*alt*/, bool /*fullCtx*/) {
return pred->eval(parser, parserCallStack); 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<ATNConfigSet> configs) { bool exact, const antlrcpp::BitSet &ambigAlts, Ref<ATNConfigSet> configs) {
if (debug || retry_debug) { if (debug || retry_debug) {
misc::Interval interval = misc::Interval((int)startIndex, (int)stopIndex); misc::Interval interval = misc::Interval((int)startIndex, (int)stopIndex);

View File

@ -44,7 +44,7 @@ bool PrecedencePredicateTransition::isEpsilon() const {
return true; return true;
} }
bool PrecedencePredicateTransition::matches(int symbol, int minVocabSymbol, int maxVocabSymbol) const { bool PrecedencePredicateTransition::matches(int /*symbol*/, int /*minVocabSymbol*/, int /*maxVocabSymbol*/) const {
return false; return false;
} }

View File

@ -44,7 +44,7 @@ bool PredicateTransition::isEpsilon() const {
return true; return true;
} }
bool PredicateTransition::matches(int symbol, int minVocabSymbol, int maxVocabSymbol) const { bool PredicateTransition::matches(int /*symbol*/, int /*minVocabSymbol*/, int /*maxVocabSymbol*/) const {
return false; return false;
} }

View File

@ -555,7 +555,7 @@ std::wstring PredictionContext::toString() const {
return antlrcpp::toString(this); return antlrcpp::toString(this);
} }
std::wstring PredictionContext::toString(Recognizer *recog) const { std::wstring PredictionContext::toString(Recognizer */*recog*/) const {
return toString(); return toString();
} }

View File

@ -47,7 +47,7 @@ misc::IntervalSet RangeTransition::label() const {
return misc::IntervalSet::of(from, to); 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; return symbol >= from && symbol <= to;
} }

View File

@ -51,7 +51,7 @@ bool RuleTransition::isEpsilon() const {
return true; return true;
} }
bool RuleTransition::matches(int symbol, int minVocabSymbol, int maxVocabSymbol) const { bool RuleTransition::matches(int /*symbol*/, int /*minVocabSymbol*/, int /*maxVocabSymbol*/) const {
return false; return false;
} }

View File

@ -338,7 +338,7 @@ std::wstring SemanticContext::OR::toString() const {
const Ref<SemanticContext> SemanticContext::NONE = std::make_shared<Predicate>(-1, -1, false); const Ref<SemanticContext> SemanticContext::NONE = std::make_shared<Predicate>(-1, -1, false);
Ref<SemanticContext> SemanticContext::evalPrecedence(Recognizer *parser, Ref<RuleContext> parserCallStack) { Ref<SemanticContext> SemanticContext::evalPrecedence(Recognizer */*parser*/, Ref<RuleContext> /*parserCallStack*/) {
return shared_from_this(); return shared_from_this();
} }

View File

@ -54,6 +54,8 @@ namespace atn {
*/ */
static const Ref<SemanticContext> NONE; static const Ref<SemanticContext> NONE;
virtual ~SemanticContext() {};
virtual size_t hashCode() const = 0; virtual size_t hashCode() const = 0;
virtual std::wstring toString() const = 0; virtual std::wstring toString() const = 0;
virtual bool operator == (const SemanticContext &other) const = 0; virtual bool operator == (const SemanticContext &other) const = 0;

View File

@ -49,7 +49,7 @@ misc::IntervalSet SetTransition::label() const {
return set; 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); return set.contains(symbol);
} }

View File

@ -50,6 +50,7 @@ namespace atn {
const int returnState; const int returnState;
SingletonPredictionContext(std::weak_ptr<PredictionContext> parent, int returnState); SingletonPredictionContext(std::weak_ptr<PredictionContext> parent, int returnState);
virtual ~SingletonPredictionContext() {};
static Ref<SingletonPredictionContext> create(std::weak_ptr<PredictionContext> parent, int returnState); static Ref<SingletonPredictionContext> create(std::weak_ptr<PredictionContext> parent, int returnState);

View File

@ -46,7 +46,7 @@ DFA::DFA(atn::DecisionState *atnStartState) : DFA(atnStartState, 0) {
} }
DFA::DFA(atn::DecisionState *atnStartState, int decision) DFA::DFA(atn::DecisionState *atnStartState, int decision)
: atnStartState(atnStartState), decision(decision), s0(nullptr) { : atnStartState(atnStartState), s0(nullptr), decision(decision) {
_precedenceDfa = false; _precedenceDfa = false;
if (is<atn::StarLoopEntryState *>(atnStartState)) { if (is<atn::StarLoopEntryState *>(atnStartState)) {

View File

@ -52,7 +52,7 @@ namespace dfa {
DFA(atn::DecisionState *atnStartState, int decision); DFA(atn::DecisionState *atnStartState, int decision);
DFA(const DFA &other); DFA(const DFA &other);
DFA(DFA &&other); DFA(DFA &&other);
~DFA(); virtual ~DFA();
/** /**
* Gets whether this DFA is a precedence DFA. Precedence DFAs use a special * Gets whether this DFA is a precedence DFA. Precedence DFAs use a special

View File

@ -45,6 +45,7 @@ namespace dfa {
public: public:
DFASerializer(const DFA *dfa, const std::vector<std::wstring>& tnames); DFASerializer(const DFA *dfa, const std::vector<std::wstring>& tnames);
DFASerializer(const DFA *dfa, Ref<Vocabulary> vocabulary); DFASerializer(const DFA *dfa, Ref<Vocabulary> vocabulary);
virtual ~DFASerializer() {};
virtual std::wstring toString() const; virtual std::wstring toString() const;

View File

@ -68,7 +68,10 @@ namespace dfa {
public: public:
Ref<atn::SemanticContext> pred; // never null; at least SemanticContext.NONE Ref<atn::SemanticContext> pred; // never null; at least SemanticContext.NONE
int alt; int alt;
PredPrediction(Ref<atn::SemanticContext> pred, int alt); PredPrediction(Ref<atn::SemanticContext> pred, int alt);
virtual ~PredPrediction() {};
virtual std::wstring toString(); virtual std::wstring toString();
private: private:
@ -123,7 +126,7 @@ namespace dfa {
DFAState(); DFAState();
DFAState(int state); DFAState(int state);
DFAState(Ref<atn::ATNConfigSet> configs); DFAState(Ref<atn::ATNConfigSet> configs);
~DFAState(); virtual ~DFAState();
/// <summary> /// <summary>
/// Get the set of all alts mentioned by all ATN configurations in this /// Get the set of all alts mentioned by all ATN configurations in this

View File

@ -42,6 +42,7 @@ namespace dfa {
class ANTLR4CPP_PUBLIC LexerDFASerializer : public DFASerializer { class ANTLR4CPP_PUBLIC LexerDFASerializer : public DFASerializer {
public: public:
LexerDFASerializer(DFA *dfa); LexerDFASerializer(DFA *dfa);
virtual ~LexerDFASerializer() {};
protected: protected:
virtual std::wstring getEdgeLabel(size_t i) const override; virtual std::wstring getEdgeLabel(size_t i) const override;

View File

@ -52,6 +52,7 @@ namespace misc {
Interval(); Interval();
Interval(int a_, int b_); Interval(int a_, int b_);
virtual ~Interval() {};
/// <summary> /// <summary>
/// return number of elements between a and b inclusively. x..x is length 1. /// return number of elements between a and b inclusively. x..x is length 1.

View File

@ -40,6 +40,8 @@ namespace misc {
template<typename T> template<typename T>
class ANTLR4CPP_PUBLIC Predicate { class ANTLR4CPP_PUBLIC Predicate {
public: public:
virtual ~Predicate() {};
virtual bool test(Ref<T> t) = 0; virtual bool test(Ref<T> t) = 0;
}; };

View File

@ -53,6 +53,8 @@ namespace misc {
public: public:
static const std::wstring LEXER_START_RULE_NAME; static const std::wstring LEXER_START_RULE_NAME;
virtual ~TestRig() {};
protected: protected:
std::wstring grammarName; std::wstring grammarName;
std::wstring startRuleName; std::wstring startRuleName;

View File

@ -50,6 +50,8 @@ namespace tree {
*/ */
class ANTLR4CPP_PUBLIC ParseTreeListener { class ANTLR4CPP_PUBLIC ParseTreeListener {
public: public:
virtual ~ParseTreeListener() {};
virtual void visitTerminal(Ref<TerminalNode> node) = 0; virtual void visitTerminal(Ref<TerminalNode> node) = 0;
virtual void visitErrorNode(Ref<ErrorNode> node) = 0; virtual void visitErrorNode(Ref<ErrorNode> node) = 0;
virtual void enterEveryRule(Ref<ParserRuleContext> ctx) = 0; virtual void enterEveryRule(Ref<ParserRuleContext> ctx) = 0;

View File

@ -41,6 +41,8 @@ namespace tree {
public: public:
static const Ref<ParseTreeWalker> DEFAULT; static const Ref<ParseTreeWalker> DEFAULT;
virtual ~ParseTreeWalker() {};
virtual void walk(Ref<ParseTreeListener> listener, Ref<ParseTree> t); virtual void walk(Ref<ParseTreeListener> listener, Ref<ParseTree> t);
/// <summary> /// <summary>

View File

@ -62,7 +62,7 @@ std::wstring TerminalNodeImpl::getText() {
return symbol->getText(); return symbol->getText();
} }
std::wstring TerminalNodeImpl::toStringTree(Parser *parser) { std::wstring TerminalNodeImpl::toStringTree(Parser */*parser*/) {
return toString(); return toString();
} }
@ -81,6 +81,6 @@ std::weak_ptr<Tree> TerminalNodeImpl::getParentReference() {
return parent; return parent;
} }
Ref<Tree> TerminalNodeImpl::getChildReference(size_t i) { Ref<Tree> TerminalNodeImpl::getChildReference(size_t /*i*/) {
return Ref<Tree>(); return Ref<Tree>();
} }

View File

@ -42,11 +42,11 @@ namespace tree {
/// It is the most abstract interface for all the trees used by ANTLR. /// It is the most abstract interface for all the trees used by ANTLR.
/// </summary> /// </summary>
class ANTLR4CPP_PUBLIC Tree { class ANTLR4CPP_PUBLIC Tree {
/// <summary> public:
virtual ~Tree() {};
/// The parent of this node. If the return value is null, then this /// The parent of this node. If the return value is null, then this
/// node is the root of the tree. /// node is the root of the tree.
/// </summary>
public:
std::weak_ptr<Tree> getParent() { return getParentReference(); }; std::weak_ptr<Tree> getParent() { return getParentReference(); };
/// <summary> /// <summary>

View File

@ -50,12 +50,12 @@ namespace pattern {
/// regular tokens of the text surrounding the tags. /// regular tokens of the text surrounding the tags.
/// </summary> /// </summary>
class ANTLR4CPP_PUBLIC Chunk { class ANTLR4CPP_PUBLIC Chunk {
public:
virtual ~Chunk() {};
/// <summary>
/// This method returns a text representation of the tag chunk. Labeled tags /// This method returns a text representation of the tag chunk. Labeled tags
/// are returned in the form {@code label:tag}, and unlabeled tags are /// are returned in the form {@code label:tag}, and unlabeled tags are
/// returned as just the tag name. /// returned as just the tag name.
/// </summary>
virtual std::wstring toString() { virtual std::wstring toString() {
std::wstring str; std::wstring str;
return str; return str;

View File

@ -71,6 +71,7 @@ namespace pattern {
ParseTreeMatch(Ref<ParseTree> tree, const ParseTreePattern &pattern, ParseTreeMatch(Ref<ParseTree> tree, const ParseTreePattern &pattern,
const std::map<std::wstring, std::vector<Ref<ParseTree>>> &labels, const std::map<std::wstring, std::vector<Ref<ParseTree>>> &labels,
Ref<ParseTree> mismatchedNode); Ref<ParseTree> mismatchedNode);
virtual ~ParseTreeMatch() {};
/// <summary> /// <summary>
/// Get the last node associated with a specific {@code label}. /// Get the last node associated with a specific {@code label}.

View File

@ -55,6 +55,7 @@ namespace pattern {
/// <param name="patternTree"> The tree pattern in <seealso cref="ParseTree"/> form. </param> /// <param name="patternTree"> The tree pattern in <seealso cref="ParseTree"/> form. </param>
ParseTreePattern(ParseTreePatternMatcher *matcher, const std::wstring &pattern, int patternRuleIndex, ParseTreePattern(ParseTreePatternMatcher *matcher, const std::wstring &pattern, int patternRuleIndex,
Ref<ParseTree> patternTree); Ref<ParseTree> patternTree);
virtual ~ParseTreePattern() {};
/// <summary> /// <summary>
/// Match a specific parse tree against this tree pattern. /// Match a specific parse tree against this tree pattern.

View File

@ -114,6 +114,7 @@ namespace pattern {
/// the tree patterns. The parser is used as a convenient mechanism to get /// the tree patterns. The parser is used as a convenient mechanism to get
/// the grammar name, plus token, rule names. /// the grammar name, plus token, rule names.
ParseTreePatternMatcher(Lexer *lexer, Parser *parser); ParseTreePatternMatcher(Lexer *lexer, Parser *parser);
virtual ~ParseTreePatternMatcher() {};
/// <summary> /// <summary>
/// Set the delimiters used for marking rule and token tags within concrete /// Set the delimiters used for marking rule and token tags within concrete

View File

@ -35,10 +35,11 @@
using namespace org::antlr::v4::runtime::tree::pattern; 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()) { if (ruleName.empty()) {
throw IllegalArgumentException("ruleName cannot be null or empty."); throw IllegalArgumentException("ruleName cannot be null or empty.");
} }

View File

@ -55,16 +55,6 @@ namespace pattern {
/// from ensuring that the tag is a non-null, non-empty string. /// from ensuring that the tag is a non-null, non-empty string.
/// </summary> /// </summary>
class ANTLR4CPP_PUBLIC TagChunk : public Chunk { class ANTLR4CPP_PUBLIC TagChunk : public Chunk {
/// <summary>
/// This is the backing field for <seealso cref="#getTag"/>.
/// </summary>
private:
const std::wstring _tag;
/// <summary>
/// This is the backing field for <seealso cref="#getLabel"/>.
/// </summary>
const std::wstring _label;
public: public:
/// <summary> /// <summary>
/// Construct a new instance of <seealso cref="TagChunk"/> using the specified tag and /// Construct a new instance of <seealso cref="TagChunk"/> using the specified tag and
@ -76,6 +66,7 @@ namespace pattern {
/// <exception cref="IllegalArgumentException"> if {@code tag} is {@code null} or /// <exception cref="IllegalArgumentException"> if {@code tag} is {@code null} or
/// empty. </exception> /// empty. </exception>
TagChunk(const std::wstring &tag); TagChunk(const std::wstring &tag);
virtual ~TagChunk() {};
/// <summary> /// <summary>
/// Construct a new instance of <seealso cref="TagChunk"/> using the specified label /// Construct a new instance of <seealso cref="TagChunk"/> using the specified label
@ -109,6 +100,14 @@ namespace pattern {
/// returned as just the tag name. /// returned as just the tag name.
/// </summary> /// </summary>
virtual std::wstring toString(); virtual std::wstring toString();
private:
/// This is the backing field for <seealso cref="#getTag"/>.
const std::wstring _tag;
/// <summary>
/// This is the backing field for <seealso cref="#getLabel"/>.
/// </summary>
const std::wstring _label;
}; };
} // namespace pattern } // namespace pattern

View File

@ -45,10 +45,10 @@ namespace pattern {
/// pattern string. /// pattern string.
/// </summary> /// </summary>
class ANTLR4CPP_PUBLIC TextChunk : public Chunk { class ANTLR4CPP_PUBLIC TextChunk : public Chunk {
private:
/// <summary> /// <summary>
/// This is the backing field for <seealso cref="#getText"/>. /// This is the backing field for <seealso cref="#getText"/>.
/// </summary> /// </summary>
private:
const std::wstring text; const std::wstring text;
/// <summary> /// <summary>
@ -58,6 +58,7 @@ namespace pattern {
/// <exception cref="IllegalArgumentException"> if {@code text} is {@code null}. </exception> /// <exception cref="IllegalArgumentException"> if {@code text} is {@code null}. </exception>
public: public:
TextChunk(const std::wstring &text); TextChunk(const std::wstring &text);
virtual ~TextChunk() {};
/// <summary> /// <summary>
/// Gets the raw text of this chunk. /// Gets the raw text of this chunk.

View File

@ -33,12 +33,12 @@
using namespace org::antlr::v4::runtime::tree::pattern; using namespace org::antlr::v4::runtime::tree::pattern;
TokenTagToken::TokenTagToken(const std::wstring &tokenName, int type) : TokenTagToken::TokenTagToken(const std::wstring &/*tokenName*/, int type)
CommonToken(type), tokenName(L""), label(L"") { : CommonToken(type), tokenName(L""), label(L"") {
} }
TokenTagToken::TokenTagToken(const std::wstring &tokenName, int type, const std::wstring &label) : TokenTagToken::TokenTagToken(const std::wstring &tokenName, int type, const std::wstring &label)
CommonToken(type), tokenName(tokenName), label(label) { : CommonToken(type), tokenName(tokenName), label(label) {
} }
std::wstring TokenTagToken::getTokenName() { std::wstring TokenTagToken::getTokenName() {

View File

@ -902,13 +902,13 @@ TokenDecl(t) ::= "<! Variable Declaration !>"
TokenTypeDeclHeader(t) ::= "<! Local Variable !>" TokenTypeDeclHeader(t) ::= "<! Local Variable !>"
TokenTypeDecl(t) ::= "ssize_t <t.name>;" TokenTypeDecl(t) ::= "ssize_t <t.name>;"
TokenListDeclHeader(t) ::= "std::vector\<Ref\<Token>> <t.name>;" TokenListDeclHeader(t) ::= "std::vector\<Ref\<Token>> <t.name>"
TokenListDecl(t) ::= "<! Variable Declaration !>" TokenListDecl(t) ::= "<! Variable Declaration !>"
RuleContextDeclHeader(r) ::= "Ref\<<parser.name>::<r.ctxName>> <r.name>;" RuleContextDeclHeader(r) ::= "Ref\<<parser.name>::<r.ctxName>> <r.name>"
RuleContextDecl(r) ::= "<! Variable Declaration !>" RuleContextDecl(r) ::= "<! Variable Declaration !>"
RuleContextListDeclHeader(rdecl) ::= "std::vector\<Ref\<<rdecl.ctxName>>> <rdecl.name>;" RuleContextListDeclHeader(rdecl) ::= "std::vector\<Ref\<<rdecl.ctxName>>> <rdecl.name>"
RuleContextListDecl(rdecl) ::= "<! Variable Declaration !>" RuleContextListDecl(rdecl) ::= "<! Variable Declaration !>"
ContextTokenGetterDeclHeader(t) ::= "Ref\<tree::TerminalNode> <t.name>();" ContextTokenGetterDeclHeader(t) ::= "Ref\<tree::TerminalNode> <t.name>();"