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

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
This diff is collapsed.
/// \file
/// Definition of the ANTLR3 base tree.
///
#ifndef _ANTLR3_BASE_TREE_H
#define _ANTLR3_BASE_TREE_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 <antlr3collections.h>
#include <antlr3string.h>
#ifdef __cplusplus
extern "C" {
#endif
/// A generic tree implementation with no payload. You must subclass to
/// actually have any user data. ANTLR v3 uses a list of children approach
/// instead of the child-sibling approach in v2. A flat tree (a list) is
/// an empty node whose children represent the list. An empty (as in it does not
/// have payload itself), but non-null node is called "nil".
///
typedef struct ANTLR3_BASE_TREE_struct
{
/// Implementers of this interface sometimes require a pointer to their selves.
///
void * super;
/// Generic void pointer allows the grammar programmer to attach any structure they
/// like to a tree node, in many cases saving the need to create their own tree
/// and tree adaptors. ANTLR does not use this pointer, but will copy it for you and so on.
///
void * u;
/// The list of all the children that belong to this node. They are not part of the node
/// as they belong to the common tree node that implements this.
///
pANTLR3_VECTOR children;
/// This is used to store the current child index position while descending
/// and ascending trees as the tree walk progresses.
///
ANTLR3_MARKER savedIndex;
/// A string factory to produce strings for toString etc
///
pANTLR3_STRING_FACTORY strFactory;
/// A pointer to a function that returns the common token pointer
/// for the payload in the supplied tree.
///
pANTLR3_COMMON_TOKEN (*getToken) (struct ANTLR3_BASE_TREE_struct * tree);
void (*addChild) (struct ANTLR3_BASE_TREE_struct * tree, void * child);
void (*addChildren) (struct ANTLR3_BASE_TREE_struct * tree, pANTLR3_LIST kids);
void (*createChildrenList) (struct ANTLR3_BASE_TREE_struct * tree);
void * (*deleteChild) (struct ANTLR3_BASE_TREE_struct * tree, ANTLR3_UINT32 i);
void (*replaceChildren) (struct ANTLR3_BASE_TREE_struct * parent, ANTLR3_INT32 startChildIndex, ANTLR3_INT32 stopChildIndex, struct ANTLR3_BASE_TREE_struct * t);
void * (*dupNode) (struct ANTLR3_BASE_TREE_struct * dupNode);
void * (*dupTree) (struct ANTLR3_BASE_TREE_struct * tree);
ANTLR3_UINT32 (*getCharPositionInLine) (struct ANTLR3_BASE_TREE_struct * tree);
void * (*getChild) (struct ANTLR3_BASE_TREE_struct * tree, ANTLR3_UINT32 i);
void (*setChildIndex) (struct ANTLR3_BASE_TREE_struct * tree, ANTLR3_INT32 );
ANTLR3_INT32 (*getChildIndex) (struct ANTLR3_BASE_TREE_struct * tree );
ANTLR3_UINT32 (*getChildCount) (struct ANTLR3_BASE_TREE_struct * tree);
struct ANTLR3_BASE_TREE_struct * (*getParent) (struct ANTLR3_BASE_TREE_struct * tree);
void (*setParent) (struct ANTLR3_BASE_TREE_struct * tree, struct ANTLR3_BASE_TREE_struct * parent);
ANTLR3_UINT32 (*getType) (struct ANTLR3_BASE_TREE_struct * tree);
void * (*getFirstChildWithType) (struct ANTLR3_BASE_TREE_struct * tree, ANTLR3_UINT32 type);
ANTLR3_UINT32 (*getLine) (struct ANTLR3_BASE_TREE_struct * tree);
pANTLR3_STRING (*getText) (struct ANTLR3_BASE_TREE_struct * tree);
ANTLR3_BOOLEAN (*isNilNode) (struct ANTLR3_BASE_TREE_struct * tree);
void (*setChild) (struct ANTLR3_BASE_TREE_struct * tree, ANTLR3_UINT32 i, void * child);
pANTLR3_STRING (*toStringTree) (struct ANTLR3_BASE_TREE_struct * tree);
pANTLR3_STRING (*toString) (struct ANTLR3_BASE_TREE_struct * tree);
void (*freshenPACIndexesAll) (struct ANTLR3_BASE_TREE_struct * tree);
void (*freshenPACIndexes) (struct ANTLR3_BASE_TREE_struct * tree, ANTLR3_UINT32 offset);
void (*reuse) (struct ANTLR3_BASE_TREE_struct * tree);
void (*free) (struct ANTLR3_BASE_TREE_struct * tree);
}
ANTLR3_BASE_TREE;
#ifdef __cplusplus
}
#endif
#endif
/** \file
* Definition of the ANTLR3 base tree adaptor.
*/
#ifndef _ANTLR3_BASE_TREE_ADAPTOR_H
#define _ANTLR3_BASE_TREE_ADAPTOR_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 <antlr3collections.h>
#include <antlr3string.h>
#include <antlr3basetree.h>
#include <antlr3commontoken.h>
#include <antlr3debugeventlistener.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ANTLR3_BASE_TREE_ADAPTOR_struct
{
/** Pointer to any enclosing structure/interface that
* contains this structure.
*/
void * super;
/** We need a string factory for creating imaginary tokens, we take this
* from the stream we are supplied to walk.
*/
pANTLR3_STRING_FACTORY strFactory;
/* And we also need a token factory for creating imaginary tokens
* this is also taken from the input source.
*/
pANTLR3_TOKEN_FACTORY tokenFactory;
/// 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;
void * (*nilNode) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor);
void * (*dupTree) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, void * tree);
void * (*dupTreeTT) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, void * t, void * tree);
void (*addChild) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, void * t, void * child);
void (*addChildToken) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, void * t, pANTLR3_COMMON_TOKEN child);
void (*setParent) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, void * child, void * parent);
void * (*getParent) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, void * child);
void * (*errorNode) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, pANTLR3_TOKEN_STREAM tnstream, pANTLR3_COMMON_TOKEN startToken, pANTLR3_COMMON_TOKEN stopToken, pANTLR3_EXCEPTION e);
ANTLR3_BOOLEAN (*isNilNode) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, void * t);
void * (*becomeRoot) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, void * newRoot, void * oldRoot);
void * (*rulePostProcessing) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, void * root);
void * (*becomeRootToken) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, void * newRoot, void * oldRoot);
void * (*create) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, pANTLR3_COMMON_TOKEN payload);
void * (*createTypeToken) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, ANTLR3_UINT32 tokenType, pANTLR3_COMMON_TOKEN fromToken);
void * (*createTypeTokenText) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, ANTLR3_UINT32 tokenType, pANTLR3_COMMON_TOKEN fromToken, pANTLR3_UINT8 text);
void * (*createTypeText) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, ANTLR3_UINT32 tokenType, pANTLR3_UINT8 text);
void * (*dupNode) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, void * treeNode);
ANTLR3_UINT32 (*getType) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, void * t);
void (*setType) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, void * t, ANTLR3_UINT32 type);
pANTLR3_STRING (*getText) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, void * t);
void (*setText) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, pANTLR3_STRING t);
void (*setText8) (struct ANTLR3_BASE_TREE_ADAPTOR_struct * adaptor, pANTLR3_UINT8 t);