Commit 93ece491 authored by Mickaël Turnel's avatar Mickaël Turnel
Browse files

Antlr3 is now integrated and compiled by bellesip

In order to generate bellesip grammars sources,
you have to call the script 'generate_grammars_sources.py' in src/antlr3c
parent 768bf9b8
......@@ -80,12 +80,6 @@ cmake_pop_check_state()
find_package(Threads)
find_package(Zlib)
find_package(Antlr3 REQUIRED)
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_INCLUDES ${ANTLR3C_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${ANTLR3C_LIBRARIES})
check_symbol_exists("antlr3StringStreamNew" "antlr3.h" HAVE_ANTLR_STRING_STREAM_NEW)
cmake_pop_check_state()
if(ENABLE_RTP_MAP_ALWAYS_IN_SDP)
set(BELLE_SDP_FORCE_RTP_MAP 1)
......@@ -130,8 +124,6 @@ set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${prefix}/bin)
set(libdir ${prefix}/lib)
set(includedir ${prefix}/include)
get_filename_component(antlr3c_library_path "${ANTLR3C_LIBRARIES}" PATH)
set(LIBS_PRIVATE "-L${antlr3c_library_path} -lantlr3c")
get_filename_component(bctoolbox_library_path "${BCTOOLBOX_CORE_LIBRARIES}" PATH)
set(LIBS_PRIVATE "${LIBS_PRIVATE} -L${bctoolbox_library_path} -lbctoolbox")
if(ZLIB_FOUND)
......
......@@ -34,9 +34,6 @@
#cmakedefine HAVE_RESINIT
#cmakedefine HAVE_ANTLR3_H
#cmakedefine HAVE_ANTLR_STRING_STREAM_NEW
#cmakedefine HAVE_TUNNEL
#cmakedefine HAVE_ZLIB
......
......@@ -35,11 +35,12 @@ function(require_c99 target)
endif()
endfunction()
set(INCLUDES ${ANTLR3C_INCLUDE_DIRS})
set(LIBS ${ANTLR3C_LIBRARIES})
list(APPEND INCLUDES ${BCTOOLBOX_CORE_INCLUDE_DIR})
list(APPEND LIBS ${BCTOOLBOX_CORE_LIBRARIES})
set(PUBLIC_INCLUDE_DIRS
${BCTOOLBOX_CORE_INCLUDE_DIR}
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
set(LIBS ${BCTOOLBOX_CORE_LIBRARIES})
if(Threads_FOUND)
if(CMAKE_USE_PTHREADS_INIT AND NOT CMAKE_SYSTEM_NAME MATCHES "QNX" AND NOT ANDROID)
......@@ -66,30 +67,17 @@ if(WIN32)
endif()
set(SDP_GENERATED_SOURCE_FILES_C
${CMAKE_CURRENT_BINARY_DIR}/grammars/belle_sdpLexer.c
${CMAKE_CURRENT_BINARY_DIR}/grammars/belle_sdpLexer.h
${CMAKE_CURRENT_BINARY_DIR}/grammars/belle_sdpParser.c
${CMAKE_CURRENT_BINARY_DIR}/grammars/belle_sdpParser.h
grammars/belle_sdpLexer.c
grammars/belle_sdpLexer.h
grammars/belle_sdpParser.c
grammars/belle_sdpParser.h
)
add_custom_command(
OUTPUT ${SDP_GENERATED_SOURCE_FILES_C}
COMMAND ${ANTLR3_COMMAND} -make -Xmultithreaded -Xconversiontimeout 10000 -fo ${CMAKE_CURRENT_BINARY_DIR}/grammars ${CMAKE_CURRENT_SOURCE_DIR}/grammars/belle_sdp.g
DEPENDS grammars/belle_sdp.g
)
set(SIP_MESSAGE_GENERATED_SOURCE_FILES_C
${CMAKE_CURRENT_BINARY_DIR}/grammars/belle_sip_messageLexer.c
${CMAKE_CURRENT_BINARY_DIR}/grammars/belle_sip_messageLexer.h
${CMAKE_CURRENT_BINARY_DIR}/grammars/belle_sip_messageParser.c
${CMAKE_CURRENT_BINARY_DIR}/grammars/belle_sip_messageParser.h
grammars/belle_sip_messageLexer.c
grammars/belle_sip_messageLexer.h
grammars/belle_sip_messageParser.c
grammars/belle_sip_messageParser.h
)
add_custom_command(
OUTPUT ${SIP_MESSAGE_GENERATED_SOURCE_FILES_C}
COMMAND ${ANTLR3_COMMAND} -make -Xmultithreaded -Xconversiontimeout 10000 -fo ${CMAKE_CURRENT_BINARY_DIR}/grammars ${CMAKE_CURRENT_SOURCE_DIR}/grammars/belle_sip_message.g
DEPENDS grammars/belle_sip_message.g
)
set_source_files_properties(${SDP_GENERATED_SOURCE_FILES_C} ${SIP_MESSAGE_GENERATED_SOURCE_FILES_C} PROPERTIES GENERATED TRUE)
if(ENABLE_TUNNEL)
set(TUNNEL_SOURCE_FILES_C
......@@ -102,6 +90,8 @@ if(ENABLE_TUNNEL)
list(APPEND LIBS ${TUNNEL_LIBRARIES})
endif()
add_subdirectory(antlr3c)
set(BELLE_SIP_SOURCE_FILES_C
auth_event.c
auth_helper.c
......@@ -204,9 +194,9 @@ endif()
string(REPLACE ";" " " LINK_FLAGS_STR "${LINK_FLAGS}")
if(ENABLE_STATIC)
add_library(bellesip-static STATIC ${BELLE_SIP_HEADER_FILES} ${BELLE_SIP_SOURCE_FILES_C} ${BELLE_SIP_SOURCE_FILES_CXX} ${BELLE_SIP_SOURCE_FILES_OBJC})
add_library(bellesip-static STATIC ${BELLE_SIP_HEADER_FILES} ${BELLE_SIP_SOURCE_FILES_C} ${BELLE_SIP_SOURCE_FILES_CXX} ${BELLE_SIP_SOURCE_FILES_OBJC} ${ANTLR3C_SOURCE_FILES})
set_target_properties(bellesip-static PROPERTIES OUTPUT_NAME bellesip)
target_include_directories(bellesip-static PUBLIC ${INCLUDES})
target_include_directories(bellesip-static PUBLIC ${PUBLIC_INCLUDE_DIRS} PRIVATE "antlr3c/include")
target_link_libraries(bellesip-static INTERFACE ${LIBS})
if(NOT "${LINK_FLAGS_STR}" STREQUAL "")
set_target_properties(bellesip-static PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
......@@ -218,10 +208,10 @@ if(ENABLE_STATIC)
)
endif()
if(ENABLE_SHARED)
add_library(bellesip SHARED ${BELLE_SIP_HEADER_FILES} ${BELLE_SIP_SOURCE_FILES_C} ${BELLE_SIP_SOURCE_FILES_CXX} ${BELLE_SIP_SOURCE_FILES_OBJC})
add_library(bellesip SHARED ${BELLE_SIP_HEADER_FILES} ${BELLE_SIP_SOURCE_FILES_C} ${BELLE_SIP_SOURCE_FILES_CXX} ${BELLE_SIP_SOURCE_FILES_OBJC} ${ANTLR3C_SOURCE_FILES})
set_target_properties(bellesip PROPERTIES SOVERSION 0)
set_target_properties(bellesip PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(bellesip PUBLIC ${INCLUDES})
target_include_directories(bellesip PUBLIC ${PUBLIC_INCLUDE_DIRS} PRIVATE "antlr3c/include")
target_link_libraries(bellesip PRIVATE ${LIBS})
if(NOT "${LINK_FLAGS_STR}" STREQUAL "")
set_target_properties(bellesip PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
......
############################################################################
# CMakeLists.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
option(ENABLE_64BIT "Turns on flags that produce 64 bit object code if any are required." OFF)
option(ENABLE_DEBUGGER "Turns on default flags that include the antlr debugger in the runtime. Disable to remove debugger and the socket dependancies." ON)
if(ENABLE_64BIT)
set(ANTLR3_USE_64BIT 1)
endif(ENABLE_64BIT)
if(NOT ENABLE_DEBUGGER)
set(ANTLR3_NODEBUGGER 1)
endif(NOT ENABLE_DEBUGGER)
include(CheckIncludeFile)
check_include_file("arpa/nameser.h" HAVE_ARPA_NAMESER_H)
check_include_file("ctype.h" HAVE_CTYPE_H)
check_include_file("inttypes.h" HAVE_INTTYPES_H)
check_include_file("malloc.h" HAVE_MALLOC_H)
check_include_file("memory.h" HAVE_MEMORY_H)
check_include_file("netdb.h" HAVE_NETDB_H)
check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
check_include_file("netinet/tcp.h" HAVE_NETINET_TCP_H)
check_include_file("socket.h" HAVE_SOCKET_H)
check_include_file("stdarg.h" HAVE_STDARG_H)
check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("stdlib.h" HAVE_STDLIB_H)
check_include_file("strings.h" HAVE_STRINGS_H)
check_include_file("string.h" HAVE_STRING_H)
check_include_file("sys/malloc.h" HAVE_SYS_MALLOC_H)
check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
check_include_file("unistd.h" HAVE_UNISTD_H)
foreach(KEYWORD "inline" "__inline__" "__inline")
if(NOT DEFINED C_INLINE)
try_compile(C_HAS_${KEYWORD} "${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/test_inline.c"
COMPILE_DEFINITIONS "-Dinline=${KEYWORD}")
if(C_HAS_${KEYWORD})
set(C_INLINE TRUE)
if(NOT "${KEYWORD}" STREQUAL "inline")
set(inline ${KEYWORD})
endif(NOT "${KEYWORD}" STREQUAL "inline")
endif(C_HAS_${KEYWORD})
endif(NOT DEFINED C_INLINE)
endforeach(KEYWORD)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/antlr3config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/antlr3config.h)
if(NOT MSVC)
add_definitions("-Wall")
endif()
include_directories(
include
${CMAKE_CURRENT_BINARY_DIR}
)
set(ANTLR3C_SOURCE_FILES
antlr3c/src/antlr3baserecognizer.c
antlr3c/src/antlr3basetree.c
antlr3c/src/antlr3basetreeadaptor.c
antlr3c/src/antlr3bitset.c
antlr3c/src/antlr3collections.c
antlr3c/src/antlr3commontoken.c
antlr3c/src/antlr3commontree.c
antlr3c/src/antlr3commontreeadaptor.c
antlr3c/src/antlr3commontreenodestream.c
antlr3c/src/antlr3convertutf.c
antlr3c/src/antlr3cyclicdfa.c
antlr3c/src/antlr3debughandlers.c
antlr3c/src/antlr3encodings.c
antlr3c/src/antlr3exception.c
antlr3c/src/antlr3filestream.c
antlr3c/src/antlr3inputstream.c
antlr3c/src/antlr3intstream.c
antlr3c/src/antlr3lexer.c
antlr3c/src/antlr3parser.c
antlr3c/src/antlr3rewritestreams.c
antlr3c/src/antlr3string.c
antlr3c/src/antlr3tokenstream.c
antlr3c/src/antlr3treeparser.c
${CMAKE_CURRENT_BINARY_DIR}/antlr3config.h
PARENT_SCOPE
)
/***************************************************************************
* antlr3config.h.cmake
* Copyright (C) 2014 Belledonne Communications, Grenoble France
*
****************************************************************************
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
****************************************************************************/
#cmakedefine PACKAGE "@PACKAGE@"
#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@"
#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@"
#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@"
#cmakedefine PACKAGE_TARNAME "@PACKAGE_TARNAME@"
#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
#cmakedefine PACKAGE_URL "@PACKAGE_URL@"
#cmakedefine VERSION "@VERSION@"
#cmakedefine ANTLR3_NODEBUGGER
#cmakedefine ANTLR3_USE_64BIT
#cmakedefine HAVE_ARPA_NAMESER_H 1
#cmakedefine HAVE_CTYPE_H 1
#cmakedefine HAVE_INTTYPES_H 1
#cmakedefine HAVE_MALLOC_H 1
#cmakedefine HAVE_MEMORY_H 1
#cmakedefine HAVE_NETDB_H 1
#cmakedefine HAVE_NETINET_IN_H 1
#cmakedefine HAVE_NETINET_TCP_H 1
#cmakedefine HAVE_SOCKET_H 1
#cmakedefine HAVE_STDARG_H 1
#cmakedefine HAVE_STDINT_H 1
#cmakedefine HAVE_STDLIB_H 1
#cmakedefine HAVE_STRINGS_H 1
#cmakedefine HAVE_STRING_H 1
#cmakedefine HAVE_SYS_MALLOC_H 1
#cmakedefine HAVE_SYS_SOCKET_H 1
#cmakedefine HAVE_SYS_STAT_H 1
#cmakedefine HAVE_SYS_TYPES_H 1
#cmakedefine HAVE_UNISTD_H 1
#ifndef __cplusplus
#cmakedefine inline @inline@
#endif
#!/usr/bin/env python
############################################################################
# FindAntlr3.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
# generate_grammar_sources.py
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
......@@ -19,67 +21,34 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
#
# - Find the antlr3c include file and library and antlr.jar
#
# ANTLR3_FOUND - system has antlr3c
# ANTLR3C_INCLUDE_DIR - the antlr3c include directory
# ANTLR3C_LIBRARIES - The libraries needed to use antlr3c
# ANTLR3_COMMAND - The command to run the antlr jar
set(_ANTLR3C_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
set(_ANTLR3_JAR_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
/usr/local
/usr
/opt/local
)
find_path(ANTLR3C_INCLUDE_DIRS
NAMES antlr3.h
HINTS _ANTLR3C_ROOT_PATHS
PATH_SUFFIXES include
)
if(ANTLR3C_INCLUDE_DIRS)
set(HAVE_ANTLR3_H 1)
endif()
find_library(ANTLR3C_LIBRARIES
NAMES antlr3c
HINTS _ANTLR3C_ROOT_PATHS
PATH_SUFFIXES bin lib
)
#NO_CMAKE_FIND_ROOT_PATH usefull to allow yocto build to find antlr3 in host file system
find_file(ANTLR3_COMMAND
NAMES antlr3
HINTS ${_ANTLR3_JAR_ROOT_PATHS}
PATH_SUFFIXES bin
NO_CMAKE_FIND_ROOT_PATH
)
if(NOT ANTLR3_COMMAND)
if (NOT Java_JAVA_EXECUTABLE) #to give a chance to set Java_JAVA_EXECUTABLE from command line
find_package(Java COMPONENTS Runtime REQUIRED)
endif()
# antlr3 command not found, search for the jar file
find_file(ANTLR3_JAR_PATH
NAMES antlr3.jar antlr.jar
HINTS ${_ANTLR3_JAR_ROOT_PATHS}
PATH_SUFFIXES share/java
)
if(ANTLR3_JAR_PATH)
set(ANTLR3_COMMAND ${Java_JAVA_EXECUTABLE} -Xmx384m -jar ${ANTLR3_JAR_PATH})
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Antlr3
DEFAULT_MSG
ANTLR3C_INCLUDE_DIRS ANTLR3C_LIBRARIES ANTLR3_COMMAND
)
mark_as_advanced(ANTLR3C_INCLUDE_DIRS ANTLR3C_LIBRARIES ANTLR3_COMMAND)
import sys
from subprocess import call
def main():
print("Deleting old sources...")
ret = call("rm ../grammars/belle_sdp*.c ../grammars/belle_sdp*.h ../grammars/belle_sip_message*.c ../grammars/belle_sip_message*.h", shell=True)
if ret != 0:
print("An error occured while deleting old sources")
return -1
else:
print("Done")
print("Generating sources from belle_sdp.g...")
ret = call(['java', '-jar', 'antlr-3.4-complete.jar', '-make', '-Xmultithreaded', '-Xconversiontimeout', '10000', '-fo', '../grammars', '../grammars/belle_sdp.g'])
if ret != 0:
print("An error occured while generating sources from belle_sdp.g")
return -1
else:
print("Done")
print("Generating sources from belle_sip_message.g...")
ret = call(['java', '-jar', 'antlr-3.4-complete.jar', '-make', '-Xmultithreaded', '-Xconversiontimeout', '10000', '-fo', '../grammars', '../grammars/belle_sip_message.g'])
if ret != 0:
print("An error occured while generating sources from belle_sip_message.g")
return -1
else:
print("Done")
if __name__ == "__main__":
sys.exit(main())
#ifndef _ANTLR3_H
#define _ANTLR3_H
// [The "BSD licence"]
// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
// http://www.temporal-wave.com
// http://www.linkedin.com/in/jimidle
//
// 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.
#include <antlr3defs.h>
#include <antlr3errors.h>
#include <antlr3exception.h>
#include <antlr3encodings.h>
#include <antlr3string.h>
#include <antlr3input.h>
#include <antlr3cyclicdfa.h>
#include <antlr3intstream.h>
#include <antlr3filestream.h>
#include <antlr3collections.h>
#include <antlr3recognizersharedstate.h>
#include <antlr3baserecognizer.h>
#include <antlr3commontoken.h>
#include <antlr3tokenstream.h>
#include <antlr3bitset.h>
#include <antlr3lexer.h>
#include <antlr3parser.h>
#include <antlr3basetreeadaptor.h>
#include <antlr3commontreeadaptor.h>
#include <antlr3rewritestreams.h>
#include <antlr3debugeventlistener.h>
#endif
/** \file
* Defines the basic structure to support recognizing by either a lexer,
* parser, or tree parser.
* \addtogroup ANTLR3_BASE_RECOGNIZER
* @{
*/
#ifndef _ANTLR3_BASERECOGNIZER_H
#define _ANTLR3_BASERECOGNIZER_H
// [The "BSD licence"]
// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
// http://www.temporal-wave.com
// http://www.linkedin.com/in/jimidle
//
// 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.
#include <antlr3defs.h>
#include <antlr3exception.h>
#include <antlr3input.h>
#include <antlr3tokenstream.h>
#include <antlr3commontoken.h>
#include <antlr3commontreenodestream.h>
#include <antlr3debugeventlistener.h>
#include <antlr3recognizersharedstate.h>
/** Type indicator for a lexer recognizer
*/
#define ANTLR3_TYPE_LEXER 0x0001
/** Type indicator for a parser recognizer
*/
#define ANTLR3_TYPE_PARSER 0x0002
/** Type indicator for a tree parser recognizer
*/
#define ANTLR3_TYPE_TREE_PARSER 0x0004
#ifdef __cplusplus
extern "C" {
#endif
/** \brief Base tracking context structure for all types of
* recognizers.
*/
typedef struct ANTLR3_BASE_RECOGNIZER_struct
{
/// Whatever super structure is providing this interface needs a pointer to itself
/// so that this can be passed back to it whenever the api functions
/// are called back from here.
///
void * super;
/// Indicates the type of recognizer that we are an instance of.
/// The programmer may set this to anything of course, but the default
/// implementations of the interface only really understand the built in
/// types, so new error handlers etc would probably be required to as well.
///
/// Valid types are:
///
/// - #ANTLR3_TYPE_LEXER
/// - #ANTLR3_TYPE_PARSER
/// - #ANTLR3_TYPE_TREE_PARSER
///
ANTLR3_UINT32 type;
/// A pointer to the shared recognizer state, such that multiple
/// recognizers can use the same inputs streams and so on (in
/// the case of grammar inheritance for instance.
///
pANTLR3_RECOGNIZER_SHARED_STATE state;
/// If set to something other than NULL, then this structure is
/// points to an instance of the debugger interface. In general, the
/// debugger is only referenced internally in recovery/error operations
/// so that it does not cause overhead by having to check this pointer
/// in every function/method
///
pANTLR3_DEBUG_EVENT_LISTENER debugger;
/// Pointer to a function that matches the current input symbol
/// against the supplied type. the function causes an error if a
/// match is not found and the default implementation will also
/// attempt to perform one token insertion or deletion if that is
/// possible with the input stream. You can override the default
/// implementation by installing a pointer to your own function
/// in this interface after the recognizer has initialized. This can
/// perform different recovery options or not recover at all and so on.
/// To ignore recovery altogether, see the comments in the default
/// implementation of this function in antlr3baserecognizer.c
///
/// Note that errors are signalled by setting the error flag below
/// and creating a new exception structure and installing it in the
/// exception pointer below (you can chain these if you like and handle them
/// in some customized way).
///
void * (*match) (struct ANTLR3_BASE_RECOGNIZER_struct * recognizer,
ANTLR3_UINT32 ttype, pANTLR3_BITSET_LIST follow);
/// Pointer to a function that matches the next token/char in the input stream
/// regardless of what it actually is.
///
void (*matchAny) (struct ANTLR3_BASE_RECOGNIZER_struct * recognizer);
/// Pointer to a function that decides if the token ahead of the current one is the
/// one we were loking for, in which case the curernt one is very likely extraneous
/// and can be reported that way.
///
ANTLR3_BOOLEAN
(*mismatchIsUnwantedToken) (struct ANTLR3_BASE_RECOGNIZER_struct * recognizer, pANTLR3_INT_STREAM input, ANTLR3_UINT32 ttype);
/// Pointer to a function that decides if the current token is one that can logically
/// follow the one we were looking for, in which case the one we were looking for is
/// probably missing from the input.
///
ANTLR3_BOOLEAN
(*mismatchIsMissingToken) (struct ANTLR3_BASE_RECOGNIZER_struct * recognizer, pANTLR3_INT_STREAM input, pANTLR3_BITSET_LIST follow);
/** Pointer to a function that works out what to do when a token mismatch
* occurs, so that Tree parsers can behave differently to other recognizers.