This commit is contained in:
David Sisson 2016-05-14 10:55:07 -07:00
commit d95a0b664b
584 changed files with 41600 additions and 40334 deletions

3
.gitignore vendored
View File

@ -61,3 +61,6 @@ runtime/Java/target
tool/target
runtime-testsuite/target
tool-testsuite/target
runtime/Cpp/demo/generated
xcuserdata
*.jar

View File

@ -89,6 +89,7 @@ YYYY/MM/DD, github id, Full name, email
2015/12/23, pboyer, Peter Boyer, peter.b.boyer@gmail.com
2015/12/24, dtymon, David Tymon, david.tymon@gmail.com
2016/02/18, reitzig, Raphael Reitzig, reitzig[at]cs.uni-kl.de
2016/03/10, mike-lischke, Mike Lischke, mike@lischke-online.de
2016/03/27, beardlybread, Bradley Steinbacher, bradley.j.steinbacher@gmail.com
2016/03/29, msteiger, Martin Steiger, antlr@martin-steiger.de
2016/03/28, gagern, Martin von Gagern, gagern@ma.tum.de

View File

@ -56,6 +56,12 @@
<role>Developer - Maven Plugin</role>
</roles>
</developer>
<developer>
<name>Mike Lischke</name>
<roles>
<role>Developer - C++ Target</role>
</roles>
</developer>
</developers>
<modules>

View File

@ -58,18 +58,18 @@ public class TestCompositeParsers extends BaseTest {
@Test
public void testDelegatesSeeSameTokenType() throws Exception {
mkdir(tmpdir);
String slave_S =
"parser grammar S;\n" +
"tokens { A, B, C }\n" +
"x : A {Console.WriteLine(\"S.x\");};";
writeFile(tmpdir, "S.g4", slave_S);
String slave_T =
"parser grammar T;\n" +
"tokens { C, B, A } // reverse order\n" +
"y : A {Console.WriteLine(\"T.y\");};";
writeFile(tmpdir, "T.g4", slave_T);
String slave_S =
"parser grammar S;\n" +
"tokens { A, B, C }\n" +
"x : A {Console.WriteLine(\"S.x\");};";
writeFile(tmpdir, "S.g4", slave_S);
StringBuilder grammarBuilder = new StringBuilder(598);
grammarBuilder.append("// The lexer will create rules to match letters a, b, c.\n");
grammarBuilder.append("// The associated token types A, B, C must have the same value\n");
@ -191,17 +191,17 @@ public class TestCompositeParsers extends BaseTest {
@Test
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
mkdir(tmpdir);
String slave_T =
"parser grammar T;\n" +
"a : B {Console.WriteLine(\"T.a\");};";
writeFile(tmpdir, "T.g4", slave_T);
String slave_S =
"parser grammar S;\n" +
"a : b {Console.WriteLine(\"S.a\");};\n" +
"b : B;";
writeFile(tmpdir, "S.g4", slave_S);
String slave_T =
"parser grammar T;\n" +
"a : B {Console.WriteLine(\"T.a\");};";
writeFile(tmpdir, "T.g4", slave_T);
StringBuilder grammarBuilder = new StringBuilder(106);
grammarBuilder.append("grammar M;\n");
grammarBuilder.append("import S,T;\n");
@ -241,18 +241,18 @@ public class TestCompositeParsers extends BaseTest {
@Test
public void testDelegatorRuleOverridesDelegates() throws Exception {
mkdir(tmpdir);
String slave_S =
"parser grammar S;\n" +
"a : b {Console.WriteLine(\"S.a\");};\n" +
"b : 'b' ;";
writeFile(tmpdir, "S.g4", slave_S);
String slave_T =
"parser grammar T;\n" +
"tokens { A }\n" +
"b : 'b' {Console.WriteLine(\"T.b\");};";
writeFile(tmpdir, "T.g4", slave_T);
String slave_S =
"parser grammar S;\n" +
"a : b {Console.WriteLine(\"S.a\");};\n" +
"b : 'b' ;";
writeFile(tmpdir, "S.g4", slave_S);
StringBuilder grammarBuilder = new StringBuilder(94);
grammarBuilder.append("grammar M;\n");
grammarBuilder.append("import S, T;\n");

View File

@ -2,6 +2,7 @@
package org.antlr.v4.test.runtime.csharp;
import org.junit.Test;
import org.junit.Ignore;
@SuppressWarnings("unused")
public class TestParseTrees extends BaseTest {

View File

@ -933,7 +933,7 @@ public abstract class BaseTest {
g.atn = factory.createATN();
CodeGenerator gen = new CodeGenerator(g);
ST outputFileST = gen.generateParser();
ST outputFileST = gen.generateParser(false);
String output = outputFileST.render();
//System.out.println(output);
String b = "#" + actionName + "#";

View File

@ -72,18 +72,18 @@ public class TestCompositeParsers extends BaseTest {
public void testDelegatesSeeSameTokenType() throws Exception {
mkdir(tmpdir);
String slave_S =
"parser grammar S;\n" +
"tokens { A, B, C }\n" +
"x : A {System.out.println(\"S.x\");};";
writeFile(tmpdir, "S.g4", slave_S);
String slave_T =
"parser grammar T;\n" +
"tokens { C, B, A } // reverse order\n" +
"y : A {System.out.println(\"T.y\");};";
writeFile(tmpdir, "T.g4", slave_T);
String slave_S =
"parser grammar S;\n" +
"tokens { A, B, C }\n" +
"x : A {System.out.println(\"S.x\");};";
writeFile(tmpdir, "S.g4", slave_S);
StringBuilder grammarBuilder = new StringBuilder(598);
grammarBuilder.append("// The lexer will create rules to match letters a, b, c.\n");
grammarBuilder.append("// The associated token types A, B, C must have the same value\n");
@ -236,17 +236,17 @@ public class TestCompositeParsers extends BaseTest {
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
mkdir(tmpdir);
String slave_T =
"parser grammar T;\n" +
"a : B {System.out.println(\"T.a\");};";
writeFile(tmpdir, "T.g4", slave_T);
String slave_S =
"parser grammar S;\n" +
"a : b {System.out.println(\"S.a\");};\n" +
"b : B;";
writeFile(tmpdir, "S.g4", slave_S);
String slave_T =
"parser grammar T;\n" +
"a : B {System.out.println(\"T.a\");};";
writeFile(tmpdir, "T.g4", slave_T);
StringBuilder grammarBuilder = new StringBuilder(106);
grammarBuilder.append("grammar M;\n");
grammarBuilder.append("import S,T;\n");
@ -294,18 +294,18 @@ public class TestCompositeParsers extends BaseTest {
public void testDelegatorRuleOverridesDelegates() throws Exception {
mkdir(tmpdir);
String slave_S =
"parser grammar S;\n" +
"a : b {System.out.println(\"S.a\");};\n" +
"b : 'b' ;";
writeFile(tmpdir, "S.g4", slave_S);
String slave_T =
"parser grammar T;\n" +
"tokens { A }\n" +
"b : 'b' {System.out.println(\"T.b\");};";
writeFile(tmpdir, "T.g4", slave_T);
String slave_S =
"parser grammar S;\n" +
"a : b {System.out.println(\"S.a\");};\n" +
"b : 'b' ;";
writeFile(tmpdir, "S.g4", slave_S);
StringBuilder grammarBuilder = new StringBuilder(95);
grammarBuilder.append("grammar M;\n");
grammarBuilder.append("import S, T;\n");

View File

@ -1,10 +1,10 @@
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
package org.antlr.v4.test.runtime.java;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.*;
public class TestParseTrees extends BaseTest {

View File

@ -64,18 +64,18 @@ public class TestCompositeParsers extends BaseTest {
@Test
public void testDelegatesSeeSameTokenType() throws Exception {
mkdir(tmpdir);
String slave_S =
"parser grammar S;\n" +
"tokens { A, B, C }\n" +
"x : A {console.log(\"S.x\");};";
writeFile(tmpdir, "S.g4", slave_S);
String slave_T =
"parser grammar T;\n" +
"tokens { C, B, A } // reverse order\n" +
"y : A {console.log(\"T.y\");};";
writeFile(tmpdir, "T.g4", slave_T);
String slave_S =
"parser grammar S;\n" +
"tokens { A, B, C }\n" +
"x : A {console.log(\"S.x\");};";
writeFile(tmpdir, "S.g4", slave_S);
StringBuilder grammarBuilder = new StringBuilder(598);
grammarBuilder.append("// The lexer will create rules to match letters a, b, c.\n");
grammarBuilder.append("// The associated token types A, B, C must have the same value\n");
@ -207,17 +207,17 @@ public class TestCompositeParsers extends BaseTest {
@Test
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
mkdir(tmpdir);
String slave_T =
"parser grammar T;\n" +
"a : B {console.log(\"T.a\");};";
writeFile(tmpdir, "T.g4", slave_T);
String slave_S =
"parser grammar S;\n" +
"a : b {console.log(\"S.a\");};\n" +
"b : B;";
writeFile(tmpdir, "S.g4", slave_S);
String slave_T =
"parser grammar T;\n" +
"a : B {console.log(\"T.a\");};";
writeFile(tmpdir, "T.g4", slave_T);
StringBuilder grammarBuilder = new StringBuilder(106);
grammarBuilder.append("grammar M;\n");
grammarBuilder.append("import S,T;\n");
@ -261,18 +261,18 @@ public class TestCompositeParsers extends BaseTest {
@Test
public void testDelegatorRuleOverridesDelegates() throws Exception {
mkdir(tmpdir);
String slave_S =
"parser grammar S;\n" +
"a : b {console.log(\"S.a\");};\n" +
"b : 'b' ;";
writeFile(tmpdir, "S.g4", slave_S);
String slave_T =
"parser grammar T;\n" +
"tokens { A }\n" +
"b : 'b' {console.log(\"T.b\");};";
writeFile(tmpdir, "T.g4", slave_T);
String slave_S =
"parser grammar S;\n" +
"a : b {console.log(\"S.a\");};\n" +
"b : 'b' ;";
writeFile(tmpdir, "S.g4", slave_S);
StringBuilder grammarBuilder = new StringBuilder(88);
grammarBuilder.append("grammar M;\n");
grammarBuilder.append("import S, T;\n");

View File

@ -1,10 +1,10 @@
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
package org.antlr.v4.test.runtime.javascript.node;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.*;
@SuppressWarnings("unused")
public class TestParseTrees extends BaseTest {

View File

@ -75,18 +75,18 @@ public class TestCompositeParsers extends BasePython2Test {
public void testDelegatesSeeSameTokenType() throws Exception {
mkdir(tmpdir);
String slave_S =
"parser grammar S;\n" +
"tokens { A, B, C }\n" +
"x : A {print(\"S.x\")};";
writeFile(tmpdir, "S.g4", slave_S);
String slave_T =
"parser grammar T;\n" +
"tokens { C, B, A } // reverse order\n" +
"y : A {print(\"T.y\")};";
writeFile(tmpdir, "T.g4", slave_T);
String slave_S =
"parser grammar S;\n" +
"tokens { A, B, C }\n" +
"x : A {print(\"S.x\")};";
writeFile(tmpdir, "S.g4", slave_S);
StringBuilder grammarBuilder = new StringBuilder(598);
grammarBuilder.append("// The lexer will create rules to match letters a, b, c.\n");
grammarBuilder.append("// The associated token types A, B, C must have the same value\n");
@ -245,17 +245,17 @@ public class TestCompositeParsers extends BasePython2Test {
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
mkdir(tmpdir);
String slave_T =
"parser grammar T;\n" +
"a : B {print(\"T.a\")};";
writeFile(tmpdir, "T.g4", slave_T);
String slave_S =
"parser grammar S;\n" +
"a : b {print(\"S.a\")};\n" +
"b : B;";
writeFile(tmpdir, "S.g4", slave_S);
String slave_T =
"parser grammar T;\n" +
"a : B {print(\"T.a\")};";
writeFile(tmpdir, "T.g4", slave_T);
StringBuilder grammarBuilder = new StringBuilder(106);
grammarBuilder.append("grammar M;\n");
grammarBuilder.append("import S,T;\n");
@ -305,18 +305,18 @@ public class TestCompositeParsers extends BasePython2Test {
public void testDelegatorRuleOverridesDelegates() throws Exception {
mkdir(tmpdir);
String slave_S =
"parser grammar S;\n" +
"a : b {print(\"S.a\")};\n" +
"b : 'b' ;";
writeFile(tmpdir, "S.g4", slave_S);
String slave_T =
"parser grammar T;\n" +
"tokens { A }\n" +
"b : 'b' {print(\"T.b\")};";
writeFile(tmpdir, "T.g4", slave_T);
String slave_S =
"parser grammar S;\n" +
"a : b {print(\"S.a\")};\n" +
"b : 'b' ;";
writeFile(tmpdir, "S.g4", slave_S);
StringBuilder grammarBuilder = new StringBuilder(81);
grammarBuilder.append("grammar M;\n");
grammarBuilder.append("import S, T;\n");

View File

@ -1,10 +1,9 @@
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
package org.antlr.v4.test.runtime.python2;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.*;
@SuppressWarnings("unused")
public class TestParseTrees extends BasePython2Test {

View File

@ -75,18 +75,18 @@ public class TestCompositeParsers extends BasePython3Test {
public void testDelegatesSeeSameTokenType() throws Exception {
mkdir(tmpdir);
String slave_S =
"parser grammar S;\n" +
"tokens { A, B, C }\n" +
"x : A {print(\"S.x\")};";
writeFile(tmpdir, "S.g4", slave_S);
String slave_T =
"parser grammar T;\n" +
"tokens { C, B, A } // reverse order\n" +
"y : A {print(\"T.y\")};";
writeFile(tmpdir, "T.g4", slave_T);
String slave_S =
"parser grammar S;\n" +
"tokens { A, B, C }\n" +
"x : A {print(\"S.x\")};";
writeFile(tmpdir, "S.g4", slave_S);
StringBuilder grammarBuilder = new StringBuilder(598);
grammarBuilder.append("// The lexer will create rules to match letters a, b, c.\n");
grammarBuilder.append("// The associated token types A, B, C must have the same value\n");
@ -245,17 +245,17 @@ public class TestCompositeParsers extends BasePython3Test {
public void testDelegatorInvokesFirstVersionOfDelegateRule() throws Exception {
mkdir(tmpdir);
String slave_T =
"parser grammar T;\n" +
"a : B {print(\"T.a\")};";
writeFile(tmpdir, "T.g4", slave_T);
String slave_S =
"parser grammar S;\n" +
"a : b {print(\"S.a\")};\n" +
"b : B;";
writeFile(tmpdir, "S.g4", slave_S);
String slave_T =
"parser grammar T;\n" +
"a : B {print(\"T.a\")};";
writeFile(tmpdir, "T.g4", slave_T);
StringBuilder grammarBuilder = new StringBuilder(106);
grammarBuilder.append("grammar M;\n");
grammarBuilder.append("import S,T;\n");
@ -305,18 +305,18 @@ public class TestCompositeParsers extends BasePython3Test {
public void testDelegatorRuleOverridesDelegates() throws Exception {
mkdir(tmpdir);
String slave_S =
"parser grammar S;\n" +
"a : b {print(\"S.a\")};\n" +
"b : 'b' ;";
writeFile(tmpdir, "S.g4", slave_S);
String slave_T =
"parser grammar T;\n" +
"tokens { A }\n" +
"b : 'b' {print(\"T.b\")};";
writeFile(tmpdir, "T.g4", slave_T);
String slave_S =
"parser grammar S;\n" +
"a : b {print(\"S.a\")};\n" +
"b : 'b' ;";
writeFile(tmpdir, "S.g4", slave_S);
StringBuilder grammarBuilder = new StringBuilder(81);
grammarBuilder.append("grammar M;\n");
grammarBuilder.append("import S, T;\n");

View File

@ -1,10 +1,9 @@
/* This file is generated by TestGenerator, any edits will be overwritten by the next generation. */
package org.antlr.v4.test.runtime.python3;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.*;
@SuppressWarnings("unused")
public class TestParseTrees extends BasePython3Test {

File diff suppressed because it is too large Load Diff

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

@ -0,0 +1,131 @@
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")
GET_TARGET_PROPERTY(old_compile_flags ${_targetName} COMPILE_FLAGS)
IF(old_compile_flags STREQUAL "old_compile_flags-NOTFOUND")
SET(old_compile_flags "-include ${_name} -Winvalid-pch")
ELSE()
SET(old_compile_flags "${old_compile_flags} -include ${_name} -Winvalid-pch")
ENDIF()
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES
COMPILE_FLAGS "${old_compile_flags}"
)
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")

View File

@ -1,4 +1,5 @@
[The "BSD license"]
Copyright (c) 2016 Mike Lischke
Copyright (c) 2013 Terence Parr
Copyright (c) 2013 Dan McLaughlin
All rights reserved.

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

@ -1,6 +1,6 @@
# C++ target for ANTLR 4
This fork provides C++ runtime support for C++. See [the canonical antlr4 repository](https://github.com/antlr/antlr4) for in depth detail about how to use Antlr4.
This folder contains the C++ runtime support for ANTLR. See [the canonical antlr4 repository](https://github.com/antlr/antlr4) for in depth detail about how to use ANTLR 4.
## Authors and major contributors
@ -18,14 +18,21 @@ The C++ target has been the work of the following people:
* David Sisson, dsisson@google.com
* [Mike Lischke](www.soft-gems.net), mike@lischke-online.de
Project Status
--------------------------------------------------------------------------------
## Other contributors
* Building on OS X, Windows, and Linux (Ubuntu)
* Marcin Szalowicz, mszalowicz@mailplus.pl (cmake build setup)
## Project Status
* Building on OS X, Windows, and Linux (all major Linux flavours)
* No errors and warnings
* Library linking
* Simple running (e.g. heap objects initialize properly)
* Simple testing (creating significiant objects)
* Some unit tests in the OSX project, for important base classes with almost 100% code coverage.
* All memory allocations checked
* Simple command line demo application working on all supported platforms.
### Build notes
The minimum C++ version to compile the ANTLR C++ runtime with is C++11. The supplied projects can built the runtime either as static or dynamic library, as both 32bit and 64bit arch. The OSX project contains a target for iOS and can also be built using cmake (instead of XCode).
In order to maximize build speed and keep the runtime interface as clean as possible there are only the absolutely necessary header files included in runtime .h files. The runtime is prepared to build with precompiled headers. For platform neutrality there is no fixed header included in *.cpp files (like the typical stdafx.h on Windows), but instead a forced include is used. The precompiled header file is antlrcpp-Prefix.h and used by all build systems (Visual Studio, XCode and CMake). It includes all needed STL headers, so you won't find any STL include in the library itself. This however requires that you have to add those includes explicitly in your project which uses the ANTLR C++ runtime (something you have probably anyway already). You can do this again with a forced include or use antlrcpp-Prefix.h in your own precompile header, if you have any.

1
runtime/Cpp/VERSION Normal file
View File

@ -0,0 +1 @@
4.0.0

View File

@ -1,20 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "antlr4cpp", "antlr4cpp.vcxproj", "{A9762991-1B57-4DCE-90C0-EE42B96947BE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Debug|Win32.ActiveCfg = Debug|Win32
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Debug|Win32.Build.0 = Debug|Win32
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Release|Win32.ActiveCfg = Release|Win32
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -1,374 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{A9762991-1B57-4DCE-90C0-EE42B96947BE}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>antlr4cpp</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;ANTLR4CPP_EXPORTS;%(PreprocessorDefinitions);WINDOWS</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)\..\antlrcpp;$(ProjectDir)\..\org\antlr\v4\runtime;$(ProjectDir)\..\org\antlr\v4\runtime\atn;$(ProjectDir)\..\org\antlr\v4\runtime\dfa;$(ProjectDir)\..\org\antlr\v4\runtime\misc;$(ProjectDir)\..\org\antlr\v4\runtime\tree;$(ProjectDir)\..\org\antlr\v4\runtime\tree\xpath;$(ProjectDir)\..\org\antlr\v4\runtime\tree\pattern;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>false</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;ANTLR4CPP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\antlrcpp\Arrays.cpp" />
<ClCompile Include="..\antlrcpp\CPPUtils.cpp" />
<ClCompile Include="..\antlrcpp\StringBuilder.cpp" />
<ClCompile Include="..\antlrcpp\Strings.cpp" />
<ClCompile Include="..\antlrcpp\UUID.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\ANTLRErrorListener.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\ANTLRErrorStrategy.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\ANTLRFileStream.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\ANTLRInputStream.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\AbstractPredicateTransition.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\ActionTransition.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\ArrayPredictionContext.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATN.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATNConfig.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATNConfigSet.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATNDeserializationOptions.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATNDeserializer.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATNSerializer.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATNSimulator.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATNState.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATNType.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\AtomTransition.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\BasicBlockStartState.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\BasicState.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\BlockEndState.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\BlockStartState.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\DecisionState.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\EmptyPredictionContext.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\EpsilonTransition.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\LexerATNConfig.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\LexerATNSimulator.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\LL1Analyzer.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\LoopEndState.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\NotSetTransition.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\OrderedATNConfigSet.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\ParserATNSimulator.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\PlusBlockStartState.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\PlusLoopbackState.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\PrecedencePredicateTransition.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\PredicateTransition.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\PredictionContext.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\PredictionContextCache.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\PredictionMode.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\RangeTransition.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\RuleStartState.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\RuleStopState.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\RuleTransition.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\SemanticContext.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\SetTransition.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\SingletonPredictionContext.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\StarBlockStartState.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\StarLoopbackState.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\StarLoopEntryState.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\TokensStartState.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\Transition.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\atn\WildcardTransition.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\BailErrorStrategy.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\BaseErrorListener.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\BufferedTokenStream.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\CharStream.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\CommonToken.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\CommonTokenFactory.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\CommonTokenStream.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\ConsoleErrorListener.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\DefaultErrorStrategy.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\dfa\DFA.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\dfa\DFASerializer.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\dfa\DFAState.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\dfa\LexerDFASerializer.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\DiagnosticErrorListener.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\Exceptions.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\FailedPredicateException.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\InputMismatchException.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\InterpreterRuleContext.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\IntStream.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\Lexer.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\LexerInterpreter.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\LexerNoViableAltException.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\ListTokenSource.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\misc\AbstractEqualityComparator.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\misc\EqualityComparator.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\misc\GraphicsSupport.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\misc\Interval.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\misc\IntervalSet.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\misc\IntSet.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\misc\LogManager.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\misc\MultiMap.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\misc\MurmurHash.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\misc\NotNull.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\misc\ObjectEqualityComparator.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\misc\OrderedHashSet.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\misc\ParseCancellationException.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\misc\TestRig.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\misc\Utils.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\NoViableAltException.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\Parser.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\ParserInterpreter.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\ParserRuleContext.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\ProxyErrorListener.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\RecognitionException.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\RuleContext.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\Token.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\TokenFactory.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\TokenSource.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\TokenStream.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\TokenStreamRewriter.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\AbstractParseTreeVisitor.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\ErrorNode.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\ErrorNodeImpl.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\ParseTree.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\ParseTreeListener.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\ParseTreeProperty.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\ParseTreeVisitor.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\ParseTreeWalker.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\pattern\Chunk.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\pattern\ParseTreeMatch.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\pattern\ParseTreePattern.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\pattern\ParseTreePatternMatcher.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\pattern\RuleTagToken.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\pattern\TagChunk.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\pattern\TextChunk.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\pattern\TokenTagToken.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\RuleNode.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\SyntaxTree.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\TerminalNode.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\TerminalNodeImpl.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\Tree.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\Trees.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPath.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathElement.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathLexer.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathLexerErrorListener.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathRuleAnywhereElement.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathRuleElement.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathTokenAnywhereElement.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathTokenElement.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathWildcardAnywhereElement.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathWildcardElement.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\UnbufferedCharStream.cpp" />
<ClCompile Include="..\org\antlr\v4\runtime\WritableToken.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\antlrcpp\Arrays.h" />
<ClInclude Include="..\antlrcpp\CPPUtils.h" />
<ClInclude Include="..\antlrcpp\StringBuilder.h" />
<ClInclude Include="..\antlrcpp\Strings.h" />
<ClInclude Include="..\antlrcpp\UUID.h" />
<ClInclude Include="..\org\antlr\v4\runtime\ANTLRErrorListener.h" />
<ClInclude Include="..\org\antlr\v4\runtime\ANTLRErrorStrategy.h" />
<ClInclude Include="..\org\antlr\v4\runtime\ANTLRFileStream.h" />
<ClInclude Include="..\org\antlr\v4\runtime\ANTLRInputStream.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\AbstractPredicateTransition.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\ActionTransition.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\ArrayPredictionContext.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATN.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATNConfig.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATNConfigSet.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATNDeserializationOptions.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATNDeserializer.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATNSerializer.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATNSimulator.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATNState.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATNType.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\AtomTransition.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\BasicBlockStartState.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\BasicState.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\BlockEndState.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\BlockStartState.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\DecisionState.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\EmptyPredictionContext.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\EpsilonTransition.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\LexerATNConfig.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\LexerATNSimulator.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\LL1Analyzer.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\LoopEndState.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\NotSetTransition.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\OrderedATNConfigSet.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\ParserATNSimulator.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\PlusBlockStartState.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\PlusLoopbackState.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\PrecedencePredicateTransition.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\PredicateTransition.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\PredictionContext.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\PredictionContextCache.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\PredictionMode.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\RangeTransition.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\RuleStartState.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\RuleStopState.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\RuleTransition.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\SemanticContext.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\SetTransition.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\SingletonPredictionContext.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\StarBlockStartState.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\StarLoopbackState.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\StarLoopEntryState.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\TokensStartState.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\Transition.h" />
<ClInclude Include="..\org\antlr\v4\runtime\atn\WildcardTransition.h" />
<ClInclude Include="..\org\antlr\v4\runtime\BailErrorStrategy.h" />
<ClInclude Include="..\org\antlr\v4\runtime\BaseErrorListener.h" />
<ClInclude Include="..\org\antlr\v4\runtime\BufferedTokenStream.h" />
<ClInclude Include="..\org\antlr\v4\runtime\CharStream.h" />
<ClInclude Include="..\org\antlr\v4\runtime\CommonToken.h" />
<ClInclude Include="..\org\antlr\v4\runtime\CommonTokenFactory.h" />
<ClInclude Include="..\org\antlr\v4\runtime\CommonTokenStream.h" />
<ClInclude Include="..\org\antlr\v4\runtime\ConsoleErrorListener.h" />
<ClInclude Include="..\org\antlr\v4\runtime\DefaultErrorStrategy.h" />
<ClInclude Include="..\org\antlr\v4\runtime\dfa\DFA.h" />
<ClInclude Include="..\org\antlr\v4\runtime\dfa\DFASerializer.h" />
<ClInclude Include="..\org\antlr\v4\runtime\dfa\DFAState.h" />
<ClInclude Include="..\org\antlr\v4\runtime\dfa\LexerDFASerializer.h" />
<ClInclude Include="..\org\antlr\v4\runtime\DiagnosticErrorListener.h" />
<ClInclude Include="..\org\antlr\v4\runtime\Exceptions.h" />
<ClInclude Include="..\org\antlr\v4\runtime\FailedPredicateException.h" />
<ClInclude Include="..\org\antlr\v4\runtime\InputMismatchException.h" />
<ClInclude Include="..\org\antlr\v4\runtime\InterpreterRuleContext.h" />
<ClInclude Include="..\org\antlr\v4\runtime\IntStream.h" />
<ClInclude Include="..\org\antlr\v4\runtime\Lexer.h" />
<ClInclude Include="..\org\antlr\v4\runtime\LexerInterpreter.h" />
<ClInclude Include="..\org\antlr\v4\runtime\LexerNoViableAltException.h" />
<ClInclude Include="..\org\antlr\v4\runtime\ListTokenSource.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\AbstractEqualityComparator.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\Array2DHashSet.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\DoubleKeyMap.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\EqualityComparator.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\GraphicsSupport.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\Interval.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\IntervalSet.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\IntSet.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\LogManager.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\MultiMap.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\MurmurHash.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\NotNull.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\ObjectEqualityComparator.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\OrderedHashSet.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\ParseCancellationException.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\TestRig.h" />
<ClInclude Include="..\org\antlr\v4\runtime\misc\Utils.h" />
<ClInclude Include="..\org\antlr\v4\runtime\NoViableAltException.h" />
<ClInclude Include="..\org\antlr\v4\runtime\Parser.h" />
<ClInclude Include="..\org\antlr\v4\runtime\ParserInterpreter.h" />
<ClInclude Include="..\org\antlr\v4\runtime\ParserRuleContext.h" />
<ClInclude Include="..\org\antlr\v4\runtime\ProxyErrorListener.h" />
<ClInclude Include="..\org\antlr\v4\runtime\RecognitionException.h" />
<ClInclude Include="..\org\antlr\v4\runtime\Recognizer.h" />
<ClInclude Include="..\org\antlr\v4\runtime\RuleContext.h" />
<ClInclude Include="..\org\antlr\v4\runtime\Token.h" />
<ClInclude Include="..\org\antlr\v4\runtime\TokenFactory.h" />
<ClInclude Include="..\org\antlr\v4\runtime\TokenSource.h" />
<ClInclude Include="..\org\antlr\v4\runtime\TokenStream.h" />
<ClInclude Include="..\org\antlr\v4\runtime\TokenStreamRewriter.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\AbstractParseTreeVisitor.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\ErrorNode.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\ErrorNodeImpl.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\ParseTree.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\ParseTreeListener.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\ParseTreeProperty.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\ParseTreeVisitor.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\ParseTreeWalker.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\pattern\Chunk.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\pattern\ParseTreeMatch.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\pattern\ParseTreePattern.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\pattern\ParseTreePatternMatcher.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\pattern\RuleTagToken.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\pattern\TagChunk.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\pattern\TextChunk.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\pattern\TokenTagToken.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\RuleNode.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\SyntaxTree.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\TerminalNode.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\TerminalNodeImpl.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\Tree.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\Trees.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPath.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathElement.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathLexer.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathLexerErrorListener.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathRuleAnywhereElement.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathRuleElement.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathTokenAnywhereElement.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathTokenElement.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathWildcardAnywhereElement.h" />
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathWildcardElement.h" />
<ClInclude Include="..\org\antlr\v4\runtime\UnbufferedCharStream.h" />
<ClInclude Include="..\org\antlr\v4\runtime\UnbufferedTokenStream.h" />
<ClInclude Include="..\org\antlr\v4\runtime\WritableToken.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\org\antlr\v4\runtime\atn\Makefile" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,876 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\org\antlr\v4\runtime\ANTLRErrorListener.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\ANTLRErrorStrategy.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\ANTLRFileStream.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\ANTLRInputStream.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\BailErrorStrategy.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\BaseErrorListener.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\BufferedTokenStream.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\CharStream.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\CommonToken.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\CommonTokenFactory.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\CommonTokenStream.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\ConsoleErrorListener.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\DefaultErrorStrategy.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\DiagnosticErrorListener.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\Exceptions.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\FailedPredicateException.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\InputMismatchException.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\InterpreterRuleContext.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\IntStream.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\Lexer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\LexerInterpreter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\LexerNoViableAltException.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\ListTokenSource.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\NoViableAltException.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\Parser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\ParserInterpreter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\ParserRuleContext.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\ProxyErrorListener.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\RecognitionException.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\RuleContext.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\Token.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\TokenFactory.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\TokenSource.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\TokenStream.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\TokenStreamRewriter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\UnbufferedCharStream.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\WritableToken.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\AbstractPredicateTransition.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\ActionTransition.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\ArrayPredictionContext.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATN.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATNConfig.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATNConfigSet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATNDeserializationOptions.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATNDeserializer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATNSerializer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATNSimulator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATNState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\ATNType.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\AtomTransition.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\BasicBlockStartState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\BasicState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\BlockEndState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\BlockStartState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\DecisionState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\EmptyPredictionContext.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\EpsilonTransition.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\LexerATNConfig.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\LexerATNSimulator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\LL1Analyzer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\LoopEndState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\NotSetTransition.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\OrderedATNConfigSet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\ParserATNSimulator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\PlusBlockStartState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\PlusLoopbackState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\PrecedencePredicateTransition.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\PredicateTransition.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\PredictionContext.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\PredictionContextCache.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\PredictionMode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\RangeTransition.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\RuleStartState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\RuleStopState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\RuleTransition.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\SemanticContext.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\SetTransition.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\SingletonPredictionContext.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\StarBlockStartState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\StarLoopbackState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\StarLoopEntryState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\TokensStartState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\Transition.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\atn\WildcardTransition.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\dfa\DFA.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\dfa\DFASerializer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\dfa\DFAState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\dfa\LexerDFASerializer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\misc\AbstractEqualityComparator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\misc\EqualityComparator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\misc\GraphicsSupport.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\misc\Interval.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\misc\IntervalSet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\misc\IntSet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\misc\LogManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\misc\MultiMap.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\misc\MurmurHash.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\misc\NotNull.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\misc\ObjectEqualityComparator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\misc\OrderedHashSet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\misc\ParseCancellationException.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\misc\TestRig.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\misc\Utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\AbstractParseTreeVisitor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\ErrorNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\ErrorNodeImpl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\ParseTree.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\ParseTreeListener.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\ParseTreeProperty.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\ParseTreeVisitor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\ParseTreeWalker.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\RuleNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\SyntaxTree.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\TerminalNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\TerminalNodeImpl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\Tree.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\Trees.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\pattern\Chunk.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\pattern\ParseTreeMatch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\pattern\ParseTreePattern.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\pattern\ParseTreePatternMatcher.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\pattern\RuleTagToken.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\pattern\TagChunk.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\pattern\TextChunk.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\pattern\TokenTagToken.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPath.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathElement.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathLexer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathLexerErrorListener.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathRuleAnywhereElement.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathRuleElement.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathTokenAnywhereElement.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathTokenElement.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathWildcardAnywhereElement.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\org\antlr\v4\runtime\tree\xpath\XPathWildcardElement.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\antlrcpp\CPPUtils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\antlrcpp\UUID.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\antlrcpp\Strings.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\antlrcpp\StringBuilder.cpp">
<Filter>Header Files</Filter>
</ClCompile>
<ClCompile Include="..\antlrcpp\Arrays.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\org\antlr\v4\runtime\ANTLRErrorListener.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\ANTLRErrorStrategy.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\ANTLRFileStream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\ANTLRInputStream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\BailErrorStrategy.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\BaseErrorListener.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\BufferedTokenStream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\CharStream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\CommonToken.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\CommonTokenFactory.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\CommonTokenStream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\ConsoleErrorListener.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\DefaultErrorStrategy.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\DiagnosticErrorListener.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\Exceptions.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\FailedPredicateException.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\InputMismatchException.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\InterpreterRuleContext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\IntStream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\Lexer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\LexerInterpreter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\LexerNoViableAltException.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\ListTokenSource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\NoViableAltException.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\Parser.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\ParserInterpreter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\ParserRuleContext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\ProxyErrorListener.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\RecognitionException.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\Recognizer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\RuleContext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\Token.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\TokenFactory.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\TokenSource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\TokenStream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\TokenStreamRewriter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\UnbufferedCharStream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\UnbufferedTokenStream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\WritableToken.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\AbstractPredicateTransition.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\ActionTransition.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\ArrayPredictionContext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATN.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATNConfig.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATNConfigSet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATNDeserializationOptions.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATNDeserializer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATNSerializer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATNSimulator.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATNState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\ATNType.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\AtomTransition.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\BasicBlockStartState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\BasicState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\BlockEndState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\BlockStartState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\DecisionState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\EmptyPredictionContext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\EpsilonTransition.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\LexerATNConfig.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\LexerATNSimulator.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\LL1Analyzer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\LoopEndState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\NotSetTransition.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\OrderedATNConfigSet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\ParserATNSimulator.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\PlusBlockStartState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\PlusLoopbackState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\PrecedencePredicateTransition.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\PredicateTransition.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\PredictionContext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\PredictionContextCache.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\PredictionMode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\RangeTransition.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\RuleStartState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\RuleStopState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\RuleTransition.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\SemanticContext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\SetTransition.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\SingletonPredictionContext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\StarBlockStartState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\StarLoopbackState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\StarLoopEntryState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\TokensStartState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\Transition.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\atn\WildcardTransition.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\dfa\DFA.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\dfa\DFASerializer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\dfa\DFAState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\dfa\LexerDFASerializer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\AbstractEqualityComparator.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\Array2DHashSet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\DoubleKeyMap.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\EqualityComparator.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\GraphicsSupport.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\Interval.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\IntervalSet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\IntSet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\LogManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\MultiMap.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\MurmurHash.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\NotNull.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\ObjectEqualityComparator.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\OrderedHashSet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\ParseCancellationException.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\TestRig.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\misc\Utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\AbstractParseTreeVisitor.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\ErrorNode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\ErrorNodeImpl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\ParseTree.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\ParseTreeListener.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\ParseTreeProperty.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\ParseTreeVisitor.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\ParseTreeWalker.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\RuleNode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\SyntaxTree.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\TerminalNode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\TerminalNodeImpl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\Tree.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\Trees.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\pattern\Chunk.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\pattern\ParseTreeMatch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\pattern\ParseTreePattern.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\pattern\ParseTreePatternMatcher.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\pattern\RuleTagToken.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\pattern\TagChunk.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\pattern\TextChunk.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\pattern\TokenTagToken.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPath.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathElement.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathLexer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathLexerErrorListener.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathRuleAnywhereElement.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathRuleElement.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathTokenAnywhereElement.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathTokenElement.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathWildcardAnywhereElement.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\org\antlr\v4\runtime\tree\xpath\XPathWildcardElement.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\antlrcpp\CPPUtils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\antlrcpp\UUID.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\antlrcpp\Strings.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\antlrcpp\StringBuilder.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\antlrcpp\Arrays.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\org\antlr\v4\runtime\atn\Makefile" />
</ItemGroup>
</Project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ShowAllFiles>false</ShowAllFiles>
</PropertyGroup>
</Project>

View File

@ -1,122 +0,0 @@
#include "Arrays.h"
#include "Exceptions.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 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.
*/
std::wstring antlrcpp::Arrays::ListToString(std::vector<std::wstring> list,std::wstring separator)
{
StringBuilder *sb = new StringBuilder();
for (size_t i = 0; i < list.size(); i++)//(std::wstring s in list)
{
sb->append(list[i]);
if (i + 1 < list.size()) sb->append(separator);
}
return sb->toString();
}
std::vector<char> antlrcpp::Arrays::asList(const std::wstring *items)
{
std::vector<char> returnAnswer(items->begin(), items->end());
return returnAnswer;
}
std::vector<std::wstring> antlrcpp::Arrays::asList(int nArgs, ...)
{
std::vector<std::wstring> returnAnswer;
va_list ap;
va_start(ap, nArgs);
for (int i = 0; i < nArgs; i++) {
wchar_t * tmp = va_arg(ap, wchar_t*);
returnAnswer.insert(returnAnswer.end(), tmp);
}
return returnAnswer;
}
bool antlrcpp::Arrays::equals(std::vector<int> a, std::vector<int> b)
{
if (a.size() != b.size()) return false;
for (auto var: a) {
if (a[var] != b[var]) return false;
}
return true;
}
bool antlrcpp::Arrays::equals(void *a, void* b)
{
throw new org::antlr::v4::runtime::TODOException(L"antlrcpp::Arrays::equals");
return false;
}
std::list<std::wstring> antlrcpp::Arrays::copyOf(void * obj, int num)
{
std::list<std::wstring> returnAnswer;
// What ?
throw new org::antlr::v4::runtime::TODOException(L"antlrcpp::Arrays::copyOf(void*,int)");
return returnAnswer;
}
std::wstring antlrcpp::Arrays::copyOf(std::wstring obj, int num)
{
std::wstring foo;
throw new org::antlr::v4::runtime::TODOException(L"antlrcpp::Arrays::copyOf(wstring, int)");
return foo;
}
void antlrcpp::Arrays::arraycopy(void * arrayA, void * arrayB, int num)
{
throw new org::antlr::v4::runtime::TODOException(L"antlrcpp::Arrays::arraycopy");
}
std::list<std::wstring> antlrcpp::Arrays::StringToStringList(std::wstring items, char separator)
{
/*
std::list<std::wstring> *list = new std::list<std::wstring>();
std::wstring listItmes[] = items.Split(separator);
for (std::wstring item : listItmes)
{
list.Add(item);
}
if (list.Count > 0) {
return list;
} else {
return null;
}*/
throw new org::antlr::v4::runtime::TODOException(L"antlrcpp::Arrays::StringToStringList");
}

View File

@ -1,87 +0,0 @@
#pragma once
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <stdarg.h>
#include "Declarations.h"
#include "StringBuilder.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 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.
*/
namespace antlrcpp {
/// <summary>
/// Converts List to string with given separator.
/// </summary>
/// <param name="list">The list.</param>
/// <param name="separator">The separator.</param>
/// <returns></returns>
class Arrays {
public:
static std::wstring ListToString(std::vector<std::wstring> list,std::wstring separator);
/// <summary>
/// Strings to string list.
/// </summary>
/// <param name="items">The items.</param>
/// <param name="separator">The separator.</param>
/// <returns></returns>
static std::list<std::wstring> StringToStringList(std::wstring items, char separator);
static std::vector<char> asList(const std::wstring *items);
// Arguments must be of type wchar_t!
static std::vector<std::wstring> asList(int nArgs, ...);
static bool equals(std::vector<int> a, std::vector<int> b);
static bool equals(void *a, void* b);
/// <summary>
/// Strings to string list.
/// </summary>
/// <param name="items">The items.</param>
/// <param name="separator">The separator.</param>
/// <returns></returns>
static std::list<std::wstring> copyOf(void * obj, int num);
static std::wstring copyOf(std::wstring obj, int num);
static void arraycopy(void * arrayA, void * arrayB, int num);
};
}

View File

@ -1,131 +0,0 @@
#pragma once
#include <bitset>
#include <iostream>
#include <sstream>
#include <vector>
/*
* [The "BSD license"]
* Copyright (c) 2015 Ana Maria Rodriguez Reyes
* 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.
*/
namespace antlrcpp {
class BitSet {
public:
BitSet() {}
BitSet(const BitSet &other) {
data = other.data;
}
static const int BITSET_SIZE = 1024;
std::bitset<BITSET_SIZE> data;
void assign(size_t count, const BitSet & value ) {
}
int nextSetBit(const int & pos) {
for (size_t i = pos; i < data.size(); i++){
if (data.test(i)) return (int)i;
}
return -1;
}
void set(size_t pos){
data.set(pos);
}
void set(){
data.set();
}
size_t count(){
return data.count();
}
size_t size(){
return data.size();
}
// Prints a list of every index for which the bitset contains a bit in true.
friend std::wostream& operator<<(std::wostream& os, const BitSet& obj)
{
os << L"{";
size_t total = obj.data.count();
for (size_t i = 0; i < obj.data.size(); i++){
if (obj.data.test(i)){
os << i;
--total;
if (total > 1){
os << L", ";
}
}
}
os << L"}";
return os;
}
static std::wstring subStringRepresentation(const std::vector<BitSet>::iterator &begin,
const std::vector<BitSet>::iterator &end) {
std::wstring result;
std::vector<BitSet>::iterator vectorIterator;
for (vectorIterator = begin; vectorIterator != end; vectorIterator++) {
result += vectorIterator->toString();
}
// Grab the end
result += end->toString();
return result;
}
std::wstring toString(){
std::wstringstream stream;
stream << L"{";
size_t total = data.count();
for (size_t i = 0; i < data.size(); i++){
if (data.test(i)){
stream << i;
--total;
if (total > 1){
stream << L", ";
}
}
}
stream << L"}";
return stream.str();
}
};
}

View File

@ -1,99 +0,0 @@
#include "CPPUtils.h"
#include <stdarg.h> // for va_start, etc
#include <memory> // for std::unique_ptr
#include <stdlib.h>
#include <vector>
/*
* [The "BSD license"]
* Copyright (c) 2014 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.
*/
namespace antlrcpp {
std::wstring join(std::vector<std::wstring> strings, const std::wstring &separator) {
std::wstring str;
bool firstItem = true;
for (std::wstring s : strings) {
if (!firstItem) {
str.append(separator);
} else {
firstItem = false;
}
str.append(s);
}
return str;
}
std::map<std::wstring, int>* toMap(const std::vector<std::wstring> &keys) {
std::map<std::wstring, int>* m = new std::map<std::wstring, int>();
for (int i = 0; i < (int)keys.size(); ++i) {
m->insert(std::pair<std::wstring, int>(keys[i], i));
}
return m;
}
std::wstring escapeWhitespace(std::wstring str, bool TODO) {
// TODO - David, what is this boolean for, and what did you want to esacpe
// whitespace with?
std::wstring returnAnswer = str.replace(str.begin(), str.end(), L' ', L'\\');
return returnAnswer;
}
std::wstring stringFormat(const std::wstring fmt_str, ...)
{
// Not sure this is needed, just use swprintf (into a wchar_t array).
// TODO(dsisson): Remove this function in a future change.
std::wstring blank;
return blank;
}
wchar_t* toCharArray(const std::vector<size_t> *data){
if (data == nullptr) return nullptr;
wchar_t* cdata = new wchar_t[data->size()];
for (int i = 0; i < (int)data->size(); i++){
cdata[i] = (char)data->at(i);
}
return cdata;
}
std::wstring toHexString(const int t){
std::wstringstream stream;
stream << std::uppercase << std::hex << t;
return stream.str();
}
std::wstring arrayToString(const std::vector<std::wstring> &data) {
std::wstring answer;
for (auto sub: data) {
answer += sub;
}
return answer;
}
}

View File

@ -1,214 +0,0 @@
#pragma once
/*
* [The "BSD license"]
* Copyright (c) 2013 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.
*/
// This can be regenerated from the command line by using
// ls *.h | sed "s/\.h\*/;/" | sed 's/^/class /'
// Autogenerated
class XPathLexer;
class XPathParser;
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
class IllegalStateException;
class IllegalArgumentException;
class NoSuchElementException;
class NullPointerException;
class InputMismatchException;
class ParseCancellationException;
class InputMismatchException;
class EmptyStackException;
class LexerNoViableAltException;
class ANTLRErrorListener;
class ANTLRErrorStrategy;
class ANTLRFileStream;
class ANTLRInputStream;
class BailErrorStrategy;
class BaseErrorListener;
class BufferedTokenStream;
class CharStream;
class CommonToken;
class CommonTokenFactory;
class CommonTokenStream;
class ConsoleErrorListener;
class DefaultErrorStrategy;
class DiagnosticErrorListener;
class FailedPredicateException;
class InputMismatchException;
class IntStream;
class InterpreterRuleContext;
class IErrorListener;
template<typename Symbol, typename ATNInterpreter> class IRecognizer;
class Lexer;
class LexerInterpreter;
class LexerNoViableAltException;
class ListTokenSource;
class NoViableAltException;
class Parser;
class ParserInterpreter;
class ParserRuleContext;
class ProxyErrorListener;
class RecognitionException;
template<typename T1, typename T2> class Recognizer;
class RuleContext;
class Token;
template<typename Symbol> class TokenFactory;
class TokenSource;
class TokenStream;
class TokenStreamRewriter;
class UnbufferedCharStream;
template<typename T> class UnbufferedTokenStream;
class WritableToken;
namespace misc {
template<typename T> class AbstractEqualityComparator;
template<typename T> class Array2DHashSet;
template<typename Key1, typename Key2, typename Value> class DoubleKeyMap;
template<typename T> class EqualityComparator;
class GraphicsSupport;
class IntSet;
class Interval;
class IntervalSet;
class JFileChooserConfirmOverwrite;
class LogManager;
template<typename K, typename V> class MultiMap;
class MurmurHash;
class NotNull;
class ObjectEqualityComparator;
template<typename T> class OrderedHashSet;
class ParseCancellationException;
class TestRig;
class Utils;
}
namespace atn {
class ATN;
class ATNConfig;
class ATNConfigSet;
class ATNDeserializationOptions;
class ATNDeserializer;
class ATNSerializer;
class ATNSimulator;
class ATNState;
enum class ATNType;
class AbstractPredicateTransition;
class ActionTransition;
class ArrayPredictionContext;
class AtomTransition;
class BasicBlockStartState;
class BasicState;
class BlockEndState;
class BlockStartState;
class DecisionState;
class EmptyPredictionContext;
class EpsilonTransition;
class LL1Analyzer;
class LexerATNConfig;
class LexerATNSimulator;
class LoopEndState;
class NotSetTransition;
class OrderedATNConfigSet;
class ParserATNSimulator;
class PlusBlockStartState;
class PlusLoopbackState;
class PrecedencePredicateTransition;
class PredicateTransition;
class PredictionContext;
class PredictionContextCache;
enum class PredictionMode;
class PredictionModeClass;
class RangeTransition;
class RuleStartState;
class RuleStopState;
class RuleTransition;
class SemanticContext;
class SetTransition;
class SingletonPredictionContext;
class StarBlockStartState;
class StarLoopEntryState;
class StarLoopbackState;
class TokensStartState;
class Transition;
class WildcardTransition;
}
namespace dfa {
class DFA;
class DFASerializer;
class DFAState;
class LexerDFASerializer;
}
namespace tree {
template <typename t> class AbstractParseTreeVisitor;
class ErrorNode;
class ErrorNodeImpl;
class ParseTree;
class ParseTreeListener;
template<typename T> class ParseTreeProperty;
template<typename T> class ParseTreeVisitor;
class ParseTreeWalker;
class RuleNode;
class SyntaxTree;
class TerminalNode;
class TerminalNodeImpl;
class Tree;
class Trees;
namespace pattern {
class Chunk;
class ParseTreeMatch;
class ParseTreePattern;
class ParseTreePatternMatcher;
class RuleTagToken;
class TagChunk;
class TextChunk;
class TokenTagToken;
}
namespace xpath {
class XPath;
class XPathElement;
class XPathLexerErrorListener;
class XPathRuleAnywhereElement;
class XPathRuleElement;
class XPathTokenAnywhereElement;
class XPathTokenElement;
class XPathWildcardAnywhereElement;
class XPathWildcardElement;
}
}
}
}
}
}

View File

@ -1,149 +0,0 @@
#include <iostream>
#include <memory>
#include <cstdarg>
#include "StringBuilder.h"
#include "ATNState.h"
#include "SemanticContext.h"
#include "Strings.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 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.
*/
namespace antlrcpp {
StringBuilder & StringBuilder::append(const std::wstring & str) {
scratch.append(str);
if (scratch.size() > ScratchSize) {
main.append(scratch);
scratch.resize(0);
}
return *this;
}
StringBuilder & StringBuilder::append(const org::antlr::v4::runtime::atn::ATNState* const state) {
main = main + state->toString();
return *this;
}
StringBuilder & StringBuilder::append(const org::antlr::v4::runtime::atn::SemanticContext* const state) {
main = main + state->toString();
return *this;
}
StringBuilder & StringBuilder::append(const wchar_t & str) {
scratch.append(wchar2wstring(str));
if (scratch.size() > ScratchSize) {
main.append(scratch);
scratch.resize(0);
}
return *this;
}
const std::wstring & StringBuilder::str() {
if (scratch.size() > 0) {
main.append(scratch);
scratch.resize(0);
}
return main;
}
std::wstring StringBuilder::format(const std::string fmt_str, ...) {
int final_n, n = (int)fmt_str.size() * 2; // reserve 2 times as much as the length of the fmt_str
std::string str;
std::unique_ptr<char[]> formatted;
va_list ap;
while(1) {
formatted.reset(new char[n]); // wrap the plain char array into the unique_ptr
strcpy(&formatted[0], fmt_str.c_str());
va_start(ap, fmt_str);
final_n = vsnprintf(&formatted[0], n, fmt_str.c_str(), ap);
va_end(ap);
if (final_n < 0 || final_n >= n)
n += abs(final_n - n + 1);
else
break;
}
return std::wstring(s2ws(formatted.get()));
}
const std::wstring & StringBuilder::toString() {
return str();
}
std::wstring::size_type StringBuilder::length() {
return str().size();
}
std::wstring StringBuilder::stringToWstring( std::string str )
{
std::wstring wStr( str.length(), L' ' );
std::copy( str.begin(), str.end(), wStr.begin() );
return wStr;
}
std::string StringBuilder::WstringTostring( std::wstring wStr )
{
std::string str( wStr.length(), ' ' );
std::copy( wStr.begin(), wStr.end(), str.begin() );
return str;
}
std::string StringBuilder::string_replace(std::string src, std::string const& target, std::string const& repl)
{
// handle error situations/trivial cases
if (target.length() == 0) {
// searching for a match to the empty string will result in
// an infinite loop
// it might make sense to throw an exception for this case
return src;
}
if (src.length() == 0) {
return src; // nothing to match against
}
size_t idx = 0;
for (;;) {
idx = src.find( target, idx);
if (idx == std::string::npos) break;
src.replace( idx, target.length(), repl);
idx += repl.length();
}
return src;
}
}

View File

@ -1,72 +0,0 @@
#pragma once
#include "Declarations.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 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.
*/
namespace antlrcpp {
class StringBuilder {
private:
std::wstring main;
std::wstring scratch;
const std::wstring::size_type ScratchSize = 1024; // or some other arbitrary number
public:
StringBuilder & append(const std::wstring & str);
StringBuilder & append(const org::antlr::v4::runtime::atn::ATNState* const state);
StringBuilder & append(const org::antlr::v4::runtime::atn::SemanticContext* const state);
StringBuilder & append(const wchar_t & str);
const std::wstring & str();
const std::wstring & toString();
std::wstring::size_type length();
// Utility function to provide "format" capability
static std::wstring format(const std::string fmt_str, ...);
static std::wstring stringToWstring( std::string str );
static std::string WstringTostring( std::wstring wStr );
static std::string string_replace(std::string src,
std::string const& target,
std::string const& repl);
};
}

View File

@ -1,68 +0,0 @@
#include <codecvt>
#include <locale>
#include <string>
#include "Strings.h"
/*
* [The "BSD license"]
* Copyright (c) 2014 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.
*/
namespace antlrcpp {
std::string ws2s(const std::wstring& wstr) {
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
std::string narrow = converter.to_bytes(wstr);
return narrow;
}
std::wstring s2ws(const std::string& str) {
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
std::wstring wide = converter.from_bytes(str);
return wide;
}
void replaceAll(std::wstring& str, const std::wstring& from, const std::wstring& to)
{
if(from.empty()) {
return;
}
size_t start_pos = 0;
while((start_pos = str.find(from, start_pos)) != std::string::npos) {
str.replace(start_pos, from.length(), to);
start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'
}
}
std::wstring wchar2wstring(const wchar_t & str) {
std::wstring returnAnswer(&str);
return returnAnswer;
}
}

View File

@ -1,83 +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.
*/
#include "UUID.h"
// Terence thinks this is for some version control stuff or something
// or other - probably not important. So be nice in this function, be quiet and
// hope nobody complains
namespace antlrcpp {
UUID::UUID(long long mostSigBits, long long leastSigBits) {
// throw new std::exception();
}
UUID::UUID(const UUID &other) {
// throw new std::exception();
};
UUID::~UUID() {
// throw new std::exception();
};
const UUID &UUID::operator=(const UUID &rhs) {
// throw new std::exception();
return rhs;
};
bool UUID::operator==(const UUID &rhs) const {
// throw new std::exception();
return true;
};
bool UUID::equals(const UUID &rhs) const {
// throw new std::exception();
return true;
};
bool UUID::equals(const UUID *rhs) const {
// throw new std::exception();
return true;
};
UUID *UUID::fromString(const std::wstring &name) {
// throw new std::exception();
return new UUID(0,0);
};
std::wstring UUID::toString() const {
// throw new std::exception();
return L"UUID_UNIMPLEMENTED";
};
long UUID::getLeastSignificantBits() const {
// throw new std::exception();
return 0;
};
long UUID::getMostSignificantBits() const {
// throw new std::exception();
return 0;
};
}

View File

@ -1,8 +0,0 @@
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//
#include <iostream>

View File

@ -1,14 +0,0 @@
/*
* antlrcpp.cp
* antlrcpp
*
* Created by Dan McLaughlin on 12/22/13.
* Copyright (c) 2013 Dan McLaughlin. All rights reserved.
*
*/
#include <iostream>
#include "antlrcpp.h"
#include "antlrcppPriv.h"

View File

@ -1,19 +0,0 @@
/*
* antlrcpp.h
* antlrcpp
*
* Created by Dan McLaughlin on 12/22/13.
* Copyright (c) 2013 Dan McLaughlin. All rights reserved.
*
*/
#ifndef antlrcpp_
#define antlrcpp_
/* The classes below are exported */
#pragma GCC visibility push(default)
#pragma GCC visibility pop
#endif

View File

@ -1,19 +0,0 @@
/*
* antlrcppPriv.h
* antlrcpp
*
* Created by Dan McLaughlin on 12/22/13.
* Copyright (c) 2013 Dan McLaughlin. All rights reserved.
*
*/
/* The classes below are not exported */
#pragma GCC visibility push(hidden)
class antlrcppPriv
{
public:
void HelloWorldPriv(const char *);
};
#pragma GCC visibility pop

View File

@ -1,4 +0,0 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
GCC_INCREASE_PRECOMPILED_HEADER_SHARING = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;

View File

@ -1,10 +0,0 @@
PRODUCT_NAME = libantlrcpp;
MACH_O_TYPE = mh_dylib;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = antlrcpp/antlrcpp-Prefix.pch;
GCC_ENABLE_CPP_EXCEPTIONS = YES;
GCC_ENABLE_CPP_RTTI = YES;
GCC_SYMBOLS_PRIVATE_EXTERN = YES;

View File

@ -1,34 +0,0 @@
#pragma once
//----------------------------------------------------------------------------------------
// Copyright © 2007 - 2013 Tangible Software Solutions Inc.
// This class can be used by anyone provided that the copyright notice remains intact.
//
// This class is used to replace some conversions to or from strings.
//----------------------------------------------------------------------------------------
#include <sstream>
namespace antlrcpp {
class StringConverterHelper
{
public:
template<typename T>
static std::wstring toString(const T &subject)
{
std::wostringstream ss;
ss << subject;
return ss.str();
}
template<typename T>
static T fromString(const std::wstring &subject)
{
std::wistringstream ss(subject);
T target;
ss >> target;
return target;
}
};
}

View File

@ -1,31 +0,0 @@
#pragma once
//----------------------------------------------------------------------------------------
// Copyright © 2007 - 2013 Tangible Software Solutions Inc.
// This class can be used by anyone provided that the copyright notice remains intact.
//
// This class is used to simulate list constructor calls which reserve the list size.
//----------------------------------------------------------------------------------------
#include <vector>
namespace antlrcpp {
class VectorHelper
{
public:
template<typename T>
static std::vector<T> VectorWithReservedSize(int size)
{
std::vector<T> vector;
vector.reserve(size);
return vector;
}
template<typename T>
static std::vector<T> VectorSublist(const std::vector<T>& vec, int start, int end)
{
std::vector<T> vector(vec.begin() + start, vec.begin() + end);
return vector;
}
};
}

View File

@ -0,0 +1,59 @@
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
${PROJECT_SOURCE_DIR}/demo/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
)
foreach( src_file ${antlr4-demo_SRC} )
set_source_files_properties(
${src_file}
PROPERTIES
COMPILE_FLAGS -Wno-overloaded-virtual
)
endforeach( src_file ${antlr4-demo_SRC} )
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)
install(TARGETS antlr4-demo
DESTINATION "share"
COMPONENT dev
)

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

@ -0,0 +1,36 @@
//
// 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"
using namespace antlrcpptest;
using namespace org::antlr::v4::runtime;
int main(int , const char **) {
ANTLRInputStream input(u8"🍴 = 🍐 + \"😎\";(((x * π))) * µ + ∰; a + (x * (y ? 0 : 1) + z);");
TLexer lexer(&input);
CommonTokenStream tokens(&lexer);
/*
tokens.fill();
for (auto token : tokens.getTokens()) {
std::cout << token->toString() << std::endl;
}
*/
TParser parser(&tokens);
Ref<tree::ParseTree> tree = parser.main();
std::cout << tree->toStringTree(&parser) << std::endl;
std::fstream("test.txt") << tree->toStringTree(&parser);
return 0;
}

View File

@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.antlr.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>

View File

@ -0,0 +1,172 @@
/*
* [The "BSD license"]
* Copyright (c) 2016 Mike Lischke
* 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.
*/
#import <XCTest/XCTest.h>
#include "ANTLRInputStream.h"
#include "Exceptions.h"
#include "Interval.h"
#include "UnbufferedTokenStream.h"
#include "StringUtils.h"
using namespace antlrcpp;
using namespace org::antlr::v4::runtime;
using namespace org::antlr::v4::runtime::misc;
@interface InputHandlingTests : XCTestCase
@end
@implementation InputHandlingTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testANTLRInputStreamCreation {
ANTLRInputStream stream1;
XCTAssert(stream1.toString().empty());
XCTAssertEqual(stream1.index(), 0U);
ANTLRInputStream stream2("To be or not to be");
XCTAssert(stream2.toString() == "To be or not to be");
XCTAssertEqual(stream2.index(), 0U);
XCTAssertEqual(stream2.size(), 18U);
char data[] = "Lorem ipsum dolor sit amet";
ANTLRInputStream stream3(data, sizeof(data) / sizeof(data[0]));
XCTAssert(stream3.toString() == std::string("Lorem ipsum dolor sit amet\0", 27));
XCTAssertEqual(stream3.index(), 0U);
XCTAssertEqual(stream3.size(), 27U);
std::wstringstream input(L"Lorem ipsum dolor sit amet");
ANTLRInputStream stream4(input);
std::string content = stream4.toString();
XCTAssertEqual(content, "Lorem ipsum dolor sit amet"); // Now as utf-8 string.
XCTAssertEqual(stream4.index(), 0U);
XCTAssertEqual(stream4.size(), 26U);
std::wstring longString(33333, 'a');
input.str(longString);
stream4.load(input);
XCTAssertEqual(stream4.index(), 0U);
XCTAssertEqual(stream4.size(), 26U); // Nothing changed as the stream is still at eof.
input.clear();
stream4.load(input);
XCTAssertEqual(stream4.size(), 33333U);
}
- (void)testANTLRInputStreamUse {
std::string text(u8"🚧Lorem ipsum dolor sit amet🕶");
std::u32string wtext = utfConverter.from_bytes(text); // Convert to UTF-32.
ANTLRInputStream stream(text);
XCTAssertEqual(stream.index(), 0U);
XCTAssertEqual(stream.size(), wtext.size());
for (size_t i = 0; i < stream.size(); ++i) {
stream.consume();
XCTAssertEqual(stream.index(), i + 1);
}
try {
stream.consume();
XCTFail();
} catch (IllegalStateException &e) {
// Expected.
std::string message = e.what();
XCTAssertEqual(message, "cannot consume EOF");
}
XCTAssertEqual(stream.index(), wtext.size());
stream.reset();
XCTAssertEqual(stream.index(), 0U);
XCTAssertEqual(stream.LA(0), 0);
for (size_t i = 1; i < wtext.size(); ++i) {
XCTAssertEqual(stream.LA((ssize_t)i), wtext[i - 1]); // LA(1) means: current char.
XCTAssertEqual(stream.LT((ssize_t)i), wtext[i - 1]); // LT is mapped to LA.
XCTAssertEqual(stream.index(), 0U); // No consumption when looking ahead.
}
stream.seek(wtext.size() - 1);
XCTAssertEqual(stream.index(), wtext.size() - 1);
stream.seek(wtext.size() / 2);
XCTAssertEqual(stream.index(), wtext.size() / 2);
stream.seek(wtext.size() - 1);
for (ssize_t i = 1; i < (ssize_t)wtext.size() - 1; ++i) {
XCTAssertEqual(stream.LA(-i), wtext[wtext.size() - i - 1]); // LA(-1) means: previous char.
XCTAssertEqual(stream.LT(-i), wtext[wtext.size() - i - 1]); // LT is mapped to LA.
XCTAssertEqual(stream.index(), wtext.size() - 1); // No consumption when looking ahead.
}
XCTAssertEqual((int)stream.LA(-10000), IntStream::EOF);
// Mark and release do nothing.
stream.reset();
XCTAssertEqual(stream.index(), 0U);
ssize_t marker = stream.mark();
XCTAssertEqual(marker, -1);
stream.seek(10);
XCTAssertEqual(stream.index(), 10U);
XCTAssertEqual(stream.mark(), -1);
stream.release(marker);
XCTAssertEqual(stream.index(), 10U);
misc::Interval interval1(2, 10); // From - to, inclusive.
std::string output = stream.getText(interval1);
std::string sub = utfConverter.to_bytes(wtext.substr(2, 9));
XCTAssertEqual(output, sub);
misc::Interval interval2(200, 10); // Start beyond bounds.
output = stream.getText(interval2);
XCTAssert(output.empty());
misc::Interval interval3(0, 200); // End beyond bounds.
output = stream.getText(interval3);
XCTAssertEqual(output, text);
stream.name = "unit tests"; // Quite useless test, as "name" is a public field.
XCTAssertEqual(stream.getSourceName(), "unit tests");
}
- (void)testUnbufferedTokenSteam {
//UnbufferedTokenStream stream;
}
@end

View File

@ -0,0 +1,410 @@
/*
* [The "BSD license"]
* Copyright (c) 2016 Mike Lischke
* 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.
*/
#import <XCTest/XCTest.h>
#include "MurmurHash.h"
#include "Interval.h"
#include "IntervalSet.h"
#include "Token.h"
#include "Exceptions.h"
#include "Lexer.h"
#include "CPPUtils.h"
using namespace org::antlr::v4::runtime;
using namespace org::antlr::v4::runtime::misc;
using namespace antlrcpp;
@interface MiscClassTests : XCTestCase
@end
@implementation MiscClassTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testCPPUtils {
class A { public: virtual ~A() {}; };
class B : public A { public: virtual ~B() {}; };
class C : public A { public: virtual ~C() {}; };
class D : public C { public: virtual ~D() {}; };
{
A a; B b; C c; D d;
const A &cc = d;
XCTAssert(is<A>(b));
XCTAssertFalse(is<B>(a));
XCTAssert(is<A>(c));
XCTAssertFalse(is<B>(c));
XCTAssert(is<A>(d));
XCTAssert(is<C>(d));
XCTAssertFalse(is<B>(d));
XCTAssert(is<C>(cc));
auto isA = [&](const A &aa) { XCTAssert(is<A>(aa)); };
isA(a);
isA(b);
isA(c);
isA(d);
auto isC = [&](const A &aa, bool mustBeTrue) {
if (mustBeTrue)
XCTAssert(is<C>(aa));
else
XCTAssertFalse(is<C>(aa));
};
isC(a, false);
isC(b, false);
isC(c, true);
isC(d, true);
}
{
A *a = new A(); B *b = new B(); C *c = new C(); D *d = new D();
XCTAssert(is<A*>(b));
XCTAssertFalse(is<B*>(a));
XCTAssert(is<A*>(c));
XCTAssertFalse(is<B*>(c));
XCTAssert(is<A*>(d));
XCTAssert(is<C*>(d));
XCTAssertFalse(is<B*>(d));
delete a; delete b; delete c; delete d;
}
{
Ref<A> a(new A());
Ref<B> b(new B());
Ref<C> c(new C());
Ref<D> d(new D());
XCTAssert(is<A>(b));
XCTAssertFalse(is<B>(a));
XCTAssert(is<A>(c));
XCTAssertFalse(is<B>(c));
XCTAssert(is<A>(d));
XCTAssert(is<C>(d));
XCTAssertFalse(is<B>(d));
}
}
- (void)testMurmurHash {
XCTAssertEqual(MurmurHash::initialize(), 0U);
XCTAssertEqual(MurmurHash::initialize(31), 31U);
// In absence of real test vectors (64bit) for murmurhash I instead check if I can find duplicate hash values
// in a deterministic and a random sequence of 100K values each.
std::set<size_t> hashs;
for (size_t i = 0; i < 100000; ++i) {
std::vector<size_t> data = { i, (size_t)(i * M_PI), arc4random()};
size_t hash = 0;
for (auto value : data)
hash = MurmurHash::update(hash, value);
hash = MurmurHash::finish(hash, data.size());
hashs.insert(hash);
}
XCTAssertEqual(hashs.size(), 100000U, @"At least one duplicate hash found.");
hashs.clear();
for (size_t i = 0; i < 100000; ++i) {
std::vector<size_t> data = { i, (size_t)(i * M_PI)};
size_t hash = 0;
for (auto value : data)
hash = MurmurHash::update(hash, value);
hash = MurmurHash::finish(hash, data.size());
hashs.insert(hash);
}
XCTAssertEqual(hashs.size(), 100000U, @"At least one duplicate hash found.");
// Another test with fixed input but varying seeds.
// Note: the higher the seed the less LSDs are in the result (for small input data).
hashs.clear();
std::vector<size_t> data = { L'µ', 'a', '@', '1' };
for (size_t i = 0; i < 100000; ++i) {
size_t hash = i;
for (auto value : data)
hash = MurmurHash::update(hash, value);
hash = MurmurHash::finish(hash, data.size());
hashs.insert(hash);
}
XCTAssertEqual(hashs.size(), 100000U, @"At least one duplicate hash found.");
}
- (void)testInterval {
// The Interval class contains no error handling (checks for invalid intervals), hence some of the results
// look strange as we test of course such intervals as well.
XCTAssertEqual(Interval().length(), 0);
XCTAssertEqual(Interval(0, 0).length(), 1); // Remember: it's an inclusive interval.
XCTAssertEqual(Interval(100, 100).length(), 1);
XCTAssertEqual(Interval(-1, -1).length(), 1); // Unwanted behavior: negative ranges.
XCTAssertEqual(Interval(-1, -2).length(), 0);
XCTAssertEqual(Interval(100, 50).length(), 0);
XCTAssert(Interval() == Interval(-1, -2));
XCTAssert(Interval(0, 0) == Interval(0, 0));
XCTAssertFalse(Interval(0, 1) == Interval(1, 2));
XCTAssertEqual(Interval().hashCode(), 22070U);
XCTAssertEqual(Interval(0, 0).hashCode(), 22103U);
XCTAssertEqual(Interval(10, 2000).hashCode(), 24413U);
// Results for the interval test functions in this order:
// startsBeforeDisjoint
// startsBeforeNonDisjoint
// startsAfter
// startsAfterDisjoint
// startsAfterNonDisjoint
// disjoint
// adjacent
// properlyContains
typedef std::vector<bool> TestResults;
struct TestEntry { size_t runningNumber; Interval interval1, interval2; TestResults results; };
std::vector<TestEntry> testData = {
// Extreme cases + invalid intervals.
{ 0, Interval(), Interval(10, 20), { true, false, false, false, false, true, false, false } },
{ 1, Interval(1, 1), Interval(1, 1), { false, true, false, false, false, false, false, true } },
{ 2, Interval(10000, 10000), Interval(10000, 10000), { false, true, false, false, false, false, false, true } },
{ 3, Interval(100, 10), Interval(100, 10), { false, false, false, true, false, true, false, true } },
{ 4, Interval(100, 10), Interval(10, 100), { false, false, true, false, true, false, false, false } },
{ 5, Interval(10, 100), Interval(100, 10), { false, true, false, false, false, false, false, true } },
// First starts before second. End varies.
{ 20, Interval(10, 12), Interval(12, 100), { false, true, false, false, false, false, false, false } },
{ 21, Interval(10, 12), Interval(13, 100), { true, false, false, false, false, true, true, false } },
{ 22, Interval(10, 12), Interval(14, 100), { true, false, false, false, false, true, false, false } },
{ 23, Interval(10, 13), Interval(12, 100), { false, true, false, false, false, false, false, false } },
{ 24, Interval(10, 14), Interval(12, 100), { false, true, false, false, false, false, false, false } },
{ 25, Interval(10, 99), Interval(12, 100), { false, true, false, false, false, false, false, false } },
{ 26, Interval(10, 100), Interval(12, 100), { false, true, false, false, false, false, false, true } },
{ 27, Interval(10, 101), Interval(12, 100), { false, true, false, false, false, false, false, true } },
{ 28, Interval(10, 1000), Interval(12, 100), { false, true, false, false, false, false, false, true } },
// First and second start equal. End varies.
{ 30, Interval(12, 12), Interval(12, 100), { false, true, false, false, false, false, false, false } },
{ 31, Interval(12, 12), Interval(13, 100), { true, false, false, false, false, true, true, false } },
{ 32, Interval(12, 12), Interval(14, 100), { true, false, false, false, false, true, false, false } },
{ 33, Interval(12, 13), Interval(12, 100), { false, true, false, false, false, false, false, false } },
{ 34, Interval(12, 14), Interval(12, 100), { false, true, false, false, false, false, false, false } },
{ 35, Interval(12, 99), Interval(12, 100), { false, true, false, false, false, false, false, false } },
{ 36, Interval(12, 100), Interval(12, 100), { false, true, false, false, false, false, false, true } },
{ 37, Interval(12, 101), Interval(12, 100), { false, true, false, false, false, false, false, true } },
{ 38, Interval(12, 1000), Interval(12, 100), { false, true, false, false, false, false, false, true } },
// First starts after second. End varies.
{ 40, Interval(15, 12), Interval(12, 100), { false, false, true, false, true, false, false, false } },
{ 41, Interval(15, 12), Interval(13, 100), { false, false, true, false, true, false, true, false } },
{ 42, Interval(15, 12), Interval(14, 100), { false, false, true, false, true, false, false, false } },
{ 43, Interval(15, 13), Interval(12, 100), { false, false, true, false, true, false, false, false } },
{ 44, Interval(15, 14), Interval(12, 100), { false, false, true, false, true, false, false, false } },
{ 45, Interval(15, 99), Interval(12, 100), { false, false, true, false, true, false, false, false } },
{ 46, Interval(15, 100), Interval(12, 100), { false, false, true, false, true, false, false, false } },
{ 47, Interval(15, 101), Interval(12, 100), { false, false, true, false, true, false, false, false } },
{ 48, Interval(15, 1000), Interval(12, 100), { false, false, true, false, true, false, false, false } },
// First ends before second. Start varies.
{ 50, Interval(10, 90), Interval(20, 100), { false, true, false, false, false, false, false, false } },
{ 51, Interval(19, 90), Interval(20, 100), { false, true, false, false, false, false, false, false } },
{ 52, Interval(20, 90), Interval(20, 100), { false, true, false, false, false, false, false, false } },
{ 53, Interval(21, 90), Interval(20, 100), { false, false, true, false, true, false, false, false } },
{ 54, Interval(98, 90), Interval(20, 100), { false, false, true, false, true, false, false, false } },
{ 55, Interval(99, 90), Interval(20, 100), { false, false, true, false, true, false, false, false } },
{ 56, Interval(100, 90), Interval(20, 100), { false, false, true, false, true, false, false, false } },
{ 57, Interval(101, 90), Interval(20, 100), { false, false, true, true, false, true, true, false } },
{ 58, Interval(1000, 90), Interval(20, 100), { false, false, true, true, false, true, false, false } },
// First and second end equal. Start varies.
{ 60, Interval(10, 100), Interval(20, 100), { false, true, false, false, false, false, false, true } },
{ 61, Interval(19, 100), Interval(20, 100), { false, true, false, false, false, false, false, true } },
{ 62, Interval(20, 100), Interval(20, 100), { false, true, false, false, false, false, false, true } },
{ 63, Interval(21, 100), Interval(20, 100), { false, false, true, false, true, false, false, false } },
{ 64, Interval(98, 100), Interval(20, 100), { false, false, true, false, true, false, false, false } },
{ 65, Interval(99, 100), Interval(20, 100), { false, false, true, false, true, false, false, false } },
{ 66, Interval(100, 100), Interval(20, 100), { false, false, true, false, true, false, false, false } },
{ 67, Interval(101, 100), Interval(20, 100), { false, false, true, true, false, true, true, false } },
{ 68, Interval(1000, 100), Interval(20, 100), { false, false, true, true, false, true, false, false } },
// First ends after second. Start varies.
{ 70, Interval(10, 1000), Interval(20, 100), { false, true, false, false, false, false, false, true } },
{ 71, Interval(19, 1000), Interval(20, 100), { false, true, false, false, false, false, false, true } },
{ 72, Interval(20, 1000), Interval(20, 100), { false, true, false, false, false, false, false, true } },
{ 73, Interval(21, 1000), Interval(20, 100), { false, false, true, false, true, false, false, false } },
{ 74, Interval(98, 1000), Interval(20, 100), { false, false, true, false, true, false, false, false } },
{ 75, Interval(99, 1000), Interval(20, 100), { false, false, true, false, true, false, false, false } },
{ 76, Interval(100, 1000), Interval(20, 100), { false, false, true, false, true, false, false, false } },
{ 77, Interval(101, 1000), Interval(20, 100), { false, false, true, true, false, true, true, false } },
{ 78, Interval(1000, 1000), Interval(20, 100), { false, false, true, true, false, true, false, false } },
// It's possible to add more tests with borders that touch each other (e.g. first starts before/on/after second
// and first ends directly before/after second. However, such cases are not handled differently in the Interval class
// (only adjacent intervals, where first ends directly before second starts and vice versa. So I ommitted them here.
};
for (auto &entry : testData) {
XCTAssert(entry.interval1.startsBeforeDisjoint(entry.interval2) == entry.results[0], @"entry: %zu", entry.runningNumber);
XCTAssert(entry.interval1.startsBeforeNonDisjoint(entry.interval2) == entry.results[1], @"entry: %zu", entry.runningNumber);
XCTAssert(entry.interval1.startsAfter(entry.interval2) == entry.results[2], @"entry: %zu", entry.runningNumber);
XCTAssert(entry.interval1.startsAfterDisjoint(entry.interval2) == entry.results[3], @"entry: %zu", entry.runningNumber);
XCTAssert(entry.interval1.startsAfterNonDisjoint(entry.interval2) == entry.results[4], @"entry: %zu", entry.runningNumber);
XCTAssert(entry.interval1.disjoint(entry.interval2) == entry.results[5], @"entry: %zu", entry.runningNumber);
XCTAssert(entry.interval1.adjacent(entry.interval2) == entry.results[6], @"entry: %zu", entry.runningNumber);
XCTAssert(entry.interval1.properlyContains(entry.interval2) == entry.results[7], @"entry: %zu", entry.runningNumber);
}
XCTAssert(Interval().Union(Interval(10, 100)) == Interval(-1, 100));
XCTAssert(Interval(10, 10).Union(Interval(10, 100)) == Interval(10, 100));
XCTAssert(Interval(10, 11).Union(Interval(10, 100)) == Interval(10, 100));
XCTAssert(Interval(10, 1000).Union(Interval(10, 100)) == Interval(10, 1000));
XCTAssert(Interval(1000, 30).Union(Interval(10, 100)) == Interval(10, 100));
XCTAssert(Interval(1000, 2000).Union(Interval(10, 100)) == Interval(10, 2000));
XCTAssert(Interval(500, 2000).Union(Interval(10, 1000)) == Interval(10, 2000));
XCTAssert(Interval().intersection(Interval(10, 100)) == Interval(10, -2));
XCTAssert(Interval(10, 10).intersection(Interval(10, 100)) == Interval(10, 10));
XCTAssert(Interval(10, 11).intersection(Interval(10, 100)) == Interval(10, 11));
XCTAssert(Interval(10, 1000).intersection(Interval(10, 100)) == Interval(10, 100));
XCTAssert(Interval(1000, 30).intersection(Interval(10, 100)) == Interval(1000, 30));
XCTAssert(Interval(1000, 2000).intersection(Interval(10, 100)) == Interval(1000, 100));
XCTAssert(Interval(500, 2000).intersection(Interval(10, 1000)) == Interval(500, 1000));
XCTAssert(Interval().toString() == "-1..-2");
XCTAssert(Interval(10, 10).toString() == "10..10");
XCTAssert(Interval(1000, 2000).toString() == "1000..2000");
XCTAssert(Interval(500, INT_MAX).toString() == "500.." + std::to_string(INT_MAX));
}
- (void)testIntervalSet {
XCTAssertFalse(IntervalSet().isReadOnly());
XCTAssert(IntervalSet().isEmpty());
IntervalSet set1;
set1.setReadOnly(true);
XCTAssert(set1.isReadOnly());
XCTAssert(IntervalSet() == IntervalSet::EMPTY_SET);
std::vector<Interval> intervals = { Interval(), Interval(10, 20), Interval(20, 100), Interval(1000, 2000) };
IntervalSet set2(intervals);
XCTAssertFalse(set2.isEmpty());
XCTAssertFalse(set2.contains(9));
XCTAssert(set2.contains(10));
XCTAssert(set2.contains(20));
XCTAssertTrue(set2.contains(22));
XCTAssert(set2.contains(1111));
XCTAssertFalse(set2.contains(10000));
XCTAssertEqual(set2.getSingleElement(), Token::INVALID_TYPE);
XCTAssertEqual(set2.getMinElement(), -1);
XCTAssertEqual(set2.getMaxElement(), 2000);
IntervalSet set3(set2);
XCTAssertFalse(set3.isEmpty());
XCTAssertFalse(set3.contains(9));
XCTAssert(set3.contains(10));
XCTAssert(set3.contains(20));
XCTAssertTrue(set3.contains(22));
XCTAssert(set3.contains(1111));
XCTAssertFalse(set3.contains(10000));
XCTAssertEqual(set3.getSingleElement(), Token::INVALID_TYPE);
XCTAssertEqual(set3.getMinElement(), 10);
XCTAssertEqual(set3.getMaxElement(), 2000);
set3.add(Interval(100, 1000));
XCTAssertEqual(set3.getMinElement(), 10);
set3.add(Interval(9, 1000));
XCTAssertEqual(set3.getMinElement(), 9);
set3.add(Interval(1, 1));
XCTAssertEqual(set3.getMinElement(), 1);
IntervalSet set4;
set4.add(10);
XCTAssertEqual(set4.getSingleElement(), 10);
XCTAssertEqual(set4.getMinElement(), 10);
XCTAssertEqual(set4.getMaxElement(), 10);
set4.clear();
XCTAssert(set4.isEmpty());
set4.add(Interval(10, 10));
XCTAssertEqual(set4.getSingleElement(), 10);
XCTAssertEqual(set4.getMinElement(), 10);
XCTAssertEqual(set4.getMaxElement(), 10);
set4.setReadOnly(true);
try {
set4.clear();
XCTFail(@"Expected exception");
}
catch (IllegalStateException &e) {
}
try {
set4.setReadOnly(false);
XCTFail(@"Expected exception");
}
catch (IllegalStateException &e) {
}
set4 = IntervalSet::of(12345);
XCTAssertEqual(set4.getSingleElement(), 12345);
XCTAssertEqual(set4.getMinElement(), 12345);
XCTAssertEqual(set4.getMaxElement(), 12345);
IntervalSet set5(10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50);
XCTAssertEqual(set5.getMinElement(), 5);
XCTAssertEqual(set5.getMaxElement(), 50);
XCTAssertEqual(set5.size(), 10U);
set5.add(12, 18);
XCTAssertEqual(set5.size(), 16U); // (15, 15) replaced by (12, 18)
set5.add(9, 33);
XCTAssertEqual(set5.size(), 30U); // (10, 10), (12, 18), (20, 20), (25, 25) and (30, 30) replaced by (9, 33)
XCTAssert(IntervalSet(3, 1, 2, 10).Or(IntervalSet(3, 1, 2, 5)) == IntervalSet(4, 1, 2, 5, 10));
XCTAssert(IntervalSet({ Interval(2, 10) }).Or(IntervalSet({ Interval(5, 8) })) == IntervalSet({ Interval(2, 10) }));
XCTAssert(IntervalSet::of(1, 10).complement(IntervalSet::of(7, 55)) == IntervalSet::of(11, 55));
XCTAssert(IntervalSet::of(1, 10).complement(IntervalSet::of(20, 55)) == IntervalSet::of(20, 55));
XCTAssert(IntervalSet::of(1, 10).complement(IntervalSet::of(5, 6)) == IntervalSet::EMPTY_SET);
XCTAssert(IntervalSet::of(15, 20).complement(IntervalSet::of(7, 55)) == IntervalSet({ Interval(7, 14), Interval(21, 55) }));
XCTAssert(IntervalSet({ Interval(1, 10), Interval(30, 35) }).complement(IntervalSet::of(7, 55)) == IntervalSet({ Interval(11, 29), Interval(36, 55) }));
XCTAssert(IntervalSet::of(1, 10).And(IntervalSet::of(7, 55)) == IntervalSet::of(7, 10));
XCTAssert(IntervalSet::of(1, 10).And(IntervalSet::of(20, 55)) == IntervalSet::EMPTY_SET);
XCTAssert(IntervalSet::of(1, 10).And(IntervalSet::of(5, 6)) == IntervalSet::of(5, 6));
XCTAssert(IntervalSet::of(15, 20).And(IntervalSet::of(7, 55)) == IntervalSet::of(15, 20));
XCTAssert(IntervalSet::of(1, 10).subtract(IntervalSet::of(7, 55)) == IntervalSet::of(1, 6));
XCTAssert(IntervalSet::of(1, 10).subtract(IntervalSet::of(20, 55)) == IntervalSet::of(1, 10));
XCTAssert(IntervalSet::of(1, 10).subtract(IntervalSet::of(5, 6)) == IntervalSet({ Interval(1, 4), Interval(7, 10) }));
XCTAssert(IntervalSet::of(15, 20).subtract(IntervalSet::of(7, 55)) == IntervalSet::EMPTY_SET);
}
@end

View File

@ -29,11 +29,15 @@
#import <Cocoa/Cocoa.h>
#import <XCTest/XCTest.h>
#include "ParserATNSimulator.h"
#include "DFA.h"
#include "ATN.h"
#include <vector>
using namespace org::antlr::v4::runtime;
@interface antlrcpp_Tests : XCTestCase
@end
@ -52,22 +56,16 @@
- (void)testExample {
try {
std::vector<org::antlr::v4::runtime::dfa::DFA> decisionToDFA;
std::vector<dfa::DFA> decisionToDFA;
atn::ATN atn;
org::antlr::v4::runtime::atn::ParserATNSimulator foo(nullptr, decisionToDFA, nullptr);
org::antlr::v4::runtime::atn::ParserATNSimulator foo(nullptr, atn, decisionToDFA, nullptr);
}
catch (std::exception e) {
catch (std::exception &e) {
XCTAssert(NO, @"Fail");
}
XCTAssert(YES, @"Pass");
}
- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
}
@end

View File

@ -0,0 +1,593 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
270925AC1CDB427200522D32 /* antlrcpp.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 270925A71CDB409400522D32 /* antlrcpp.dylib */; };
270925AF1CDB428A00522D32 /* libantlrcpp_static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 270925A91CDB409400522D32 /* libantlrcpp_static.a */; };
270925B11CDB455B00522D32 /* TLexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27A23EA11CC2A8D60036D8A3 /* TLexer.cpp */; };
2747A7131CA6C46C0030247B /* InputHandlingTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2747A7121CA6C46C0030247B /* InputHandlingTests.mm */; };
274FC6D91CA96B6C008D4374 /* MiscClassTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 274FC6D81CA96B6C008D4374 /* MiscClassTests.mm */; };
27C66A6A1C9591280021E494 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C66A691C9591280021E494 /* main.cpp */; };
27C6E1801C972FFC0079AF06 /* TParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6E1741C972FFC0079AF06 /* TParser.cpp */; };
27C6E1811C972FFC0079AF06 /* TParserBaseListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6E1771C972FFC0079AF06 /* TParserBaseListener.cpp */; };
27C6E1821C972FFC0079AF06 /* TParserBaseVisitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6E1791C972FFC0079AF06 /* TParserBaseVisitor.cpp */; };
27C6E1831C972FFC0079AF06 /* TParserListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6E17B1C972FFC0079AF06 /* TParserListener.cpp */; };
27C6E1841C972FFC0079AF06 /* TParserVisitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27C6E17D1C972FFC0079AF06 /* TParserVisitor.cpp */; };
37F1356D1B4AC02800E0CACF /* antlrcpp_Tests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37F1356C1B4AC02800E0CACF /* antlrcpp_Tests.mm */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
270925A61CDB409400522D32 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 270925A11CDB409400522D32 /* antlrcpp.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 37D727AA1867AF1E007B6D10;
remoteInfo = antlrcpp;
};
270925A81CDB409400522D32 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 270925A11CDB409400522D32 /* antlrcpp.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 37C147171B4D5A04008EDDDB;
remoteInfo = antlrcpp_static;
};
270925AA1CDB426900522D32 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 270925A11CDB409400522D32 /* antlrcpp.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 37D727A91867AF1E007B6D10;
remoteInfo = antlrcpp;
};
270925AD1CDB428400522D32 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 270925A11CDB409400522D32 /* antlrcpp.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 37C147161B4D5A04008EDDDB;
remoteInfo = antlrcpp_static;
};
273DC2BC1CDB619900DB7B2B /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 270925A11CDB409400522D32 /* antlrcpp.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 270C67F01CDB4F1E00116E17;
remoteInfo = antlrcpp_ios;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
27C66A651C9591280021E494 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
270925A11CDB409400522D32 /* antlrcpp.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = antlrcpp.xcodeproj; path = ../../runtime/antlrcpp.xcodeproj; sourceTree = "<group>"; };
270925B01CDB435600522D32 /* antlrcpp-Prefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "antlrcpp-Prefix.h"; path = "../../runtime/src/antlrcpp-Prefix.h"; sourceTree = "<group>"; };
2747A7121CA6C46C0030247B /* InputHandlingTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InputHandlingTests.mm; sourceTree = "<group>"; wrapsLines = 0; };
274FC6D81CA96B6C008D4374 /* MiscClassTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MiscClassTests.mm; sourceTree = "<group>"; wrapsLines = 0; };
27874F1D1CCB7A0700AF1C53 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
27A23EA11CC2A8D60036D8A3 /* TLexer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TLexer.cpp; path = ../generated/TLexer.cpp; sourceTree = "<group>"; wrapsLines = 0; };
27A23EA21CC2A8D60036D8A3 /* TLexer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TLexer.h; path = ../generated/TLexer.h; sourceTree = "<group>"; };
27C66A671C9591280021E494 /* antlr4-cpp-demo */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "antlr4-cpp-demo"; sourceTree = BUILT_PRODUCTS_DIR; };
27C66A691C9591280021E494 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
27C66A731C9592400021E494 /* TLexer.g4 */ = {isa = PBXFileReference; lastKnownFileType = text; name = TLexer.g4; path = ../../TLexer.g4; sourceTree = "<group>"; };
27C66A741C9592400021E494 /* TParser.g4 */ = {isa = PBXFileReference; lastKnownFileType = text; name = TParser.g4; path = ../../TParser.g4; sourceTree = "<group>"; };
27C6E1741C972FFC0079AF06 /* TParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TParser.cpp; path = ../generated/TParser.cpp; sourceTree = "<group>"; wrapsLines = 0; };
27C6E1751C972FFC0079AF06 /* TParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TParser.h; path = ../generated/TParser.h; sourceTree = "<group>"; wrapsLines = 0; };
27C6E1771C972FFC0079AF06 /* TParserBaseListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TParserBaseListener.cpp; path = ../generated/TParserBaseListener.cpp; sourceTree = "<group>"; };
27C6E1781C972FFC0079AF06 /* TParserBaseListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TParserBaseListener.h; path = ../generated/TParserBaseListener.h; sourceTree = "<group>"; };
27C6E1791C972FFC0079AF06 /* TParserBaseVisitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TParserBaseVisitor.cpp; path = ../generated/TParserBaseVisitor.cpp; sourceTree = "<group>"; };
27C6E17B1C972FFC0079AF06 /* TParserListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TParserListener.cpp; path = ../generated/TParserListener.cpp; sourceTree = "<group>"; };
27C6E17C1C972FFC0079AF06 /* TParserListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TParserListener.h; path = ../generated/TParserListener.h; sourceTree = "<group>"; };
27C6E17D1C972FFC0079AF06 /* TParserVisitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TParserVisitor.cpp; path = ../generated/TParserVisitor.cpp; sourceTree = "<group>"; };
27C6E1851C97322F0079AF06 /* TParserBaseVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TParserBaseVisitor.h; path = ../generated/TParserBaseVisitor.h; sourceTree = "<group>"; wrapsLines = 0; };
27C6E1861C97322F0079AF06 /* TParserVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TParserVisitor.h; path = ../generated/TParserVisitor.h; sourceTree = "<group>"; };
37F135681B4AC02800E0CACF /* antlrcpp Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "antlrcpp Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
37F1356B1B4AC02800E0CACF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
37F1356C1B4AC02800E0CACF /* antlrcpp_Tests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = antlrcpp_Tests.mm; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
27C66A641C9591280021E494 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
270925AC1CDB427200522D32 /* antlrcpp.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
37F135651B4AC02800E0CACF /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
270925AF1CDB428A00522D32 /* libantlrcpp_static.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
270925A21CDB409400522D32 /* Products */ = {
isa = PBXGroup;
children = (
270925A71CDB409400522D32 /* antlrcpp.dylib */,
270925A91CDB409400522D32 /* libantlrcpp_static.a */,
273DC2BD1CDB619900DB7B2B /* antlrcpp_ios.framework */,
);
name = Products;
sourceTree = "<group>";
};
27874F221CCBB34200AF1C53 /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
27874F1D1CCB7A0700AF1C53 /* CoreFoundation.framework */,
);
name = "Linked Frameworks";
sourceTree = "<group>";
};
27C66A5C1C958EB50021E494 /* generated */ = {
isa = PBXGroup;
children = (
27A23EA11CC2A8D60036D8A3 /* TLexer.cpp */,
27A23EA21CC2A8D60036D8A3 /* TLexer.h */,
27C6E1741C972FFC0079AF06 /* TParser.cpp */,
27C6E1751C972FFC0079AF06 /* TParser.h */,
27C6E1771C972FFC0079AF06 /* TParserBaseListener.cpp */,
27C6E1781C972FFC0079AF06 /* TParserBaseListener.h */,
27C6E1791C972FFC0079AF06 /* TParserBaseVisitor.cpp */,
27C6E1851C97322F0079AF06 /* TParserBaseVisitor.h */,
27C6E17B1C972FFC0079AF06 /* TParserListener.cpp */,
27C6E17C1C972FFC0079AF06 /* TParserListener.h */,
27C6E17D1C972FFC0079AF06 /* TParserVisitor.cpp */,
27C6E1861C97322F0079AF06 /* TParserVisitor.h */,
);
name = generated;
sourceTree = "<group>";
};
27C66A681C9591280021E494 /* antlr4-cpp-demo */ = {
isa = PBXGroup;
children = (
27C66A691C9591280021E494 /* main.cpp */,
27C66A731C9592400021E494 /* TLexer.g4 */,
27C66A741C9592400021E494 /* TParser.g4 */,
);
path = "antlr4-cpp-demo";
sourceTree = "<group>";
};
37D727A11867AF1E007B6D10 = {
isa = PBXGroup;
children = (
270925B01CDB435600522D32 /* antlrcpp-Prefix.h */,
270925A11CDB409400522D32 /* antlrcpp.xcodeproj */,
27C66A681C9591280021E494 /* antlr4-cpp-demo */,
37F135691B4AC02800E0CACF /* antlrcpp Tests */,
27C66A5C1C958EB50021E494 /* generated */,
27874F221CCBB34200AF1C53 /* Linked Frameworks */,
37D727AB1867AF1E007B6D10 /* Products */,
);
sourceTree = "<group>";
};
37D727AB1867AF1E007B6D10 /* Products */ = {
isa = PBXGroup;
children = (
37F135681B4AC02800E0CACF /* antlrcpp Tests.xctest */,
27C66A671C9591280021E494 /* antlr4-cpp-demo */,
);
name = Products;
sourceTree = "<group>";
};
37F135691B4AC02800E0CACF /* antlrcpp Tests */ = {
isa = PBXGroup;
children = (
37F1356A1B4AC02800E0CACF /* Supporting Files */,
37F1356C1B4AC02800E0CACF /* antlrcpp_Tests.mm */,
2747A7121CA6C46C0030247B /* InputHandlingTests.mm */,
274FC6D81CA96B6C008D4374 /* MiscClassTests.mm */,
);
path = "antlrcpp Tests";
sourceTree = "<group>";
};
37F1356A1B4AC02800E0CACF /* Supporting Files */ = {
isa = PBXGroup;
children = (
37F1356B1B4AC02800E0CACF /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
27C66A661C9591280021E494 /* antlr4-cpp-demo */ = {
isa = PBXNativeTarget;
buildConfigurationList = 27C66A6B1C9591280021E494 /* Build configuration list for PBXNativeTarget "antlr4-cpp-demo" */;
buildPhases = (
27C66A721C9591EF0021E494 /* Generate Parser */,
27C66A631C9591280021E494 /* Sources */,
27C66A641C9591280021E494 /* Frameworks */,
27C66A651C9591280021E494 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
270925AB1CDB426900522D32 /* PBXTargetDependency */,
);
name = "antlr4-cpp-demo";
productName = "antlr4-cpp-demo";
productReference = 27C66A671C9591280021E494 /* antlr4-cpp-demo */;
productType = "com.apple.product-type.tool";
};
37F135671B4AC02800E0CACF /* antlrcpp Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 37F135731B4AC02800E0CACF /* Build configuration list for PBXNativeTarget "antlrcpp Tests" */;
buildPhases = (
37F135641B4AC02800E0CACF /* Sources */,
37F135651B4AC02800E0CACF /* Frameworks */,
37F135661B4AC02800E0CACF /* Resources */,
);
buildRules = (
);
dependencies = (
270925AE1CDB428400522D32 /* PBXTargetDependency */,
);
name = "antlrcpp Tests";
productName = "antlrcpp Tests";
productReference = 37F135681B4AC02800E0CACF /* antlrcpp Tests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
37D727A21867AF1E007B6D10 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0730;
ORGANIZATIONNAME = "Dan McLaughlin";
TargetAttributes = {
27C66A661C9591280021E494 = {
CreatedOnToolsVersion = 7.2.1;
};
37F135671B4AC02800E0CACF = {
CreatedOnToolsVersion = 6.3.2;
};
};
};
buildConfigurationList = 37D727A51867AF1E007B6D10 /* Build configuration list for PBXProject "antlrcpp-demo" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 37D727A11867AF1E007B6D10;
productRefGroup = 37D727AB1867AF1E007B6D10 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 270925A21CDB409400522D32 /* Products */;
ProjectRef = 270925A11CDB409400522D32 /* antlrcpp.xcodeproj */;
},
);
projectRoot = "";
targets = (
37F135671B4AC02800E0CACF /* antlrcpp Tests */,
27C66A661C9591280021E494 /* antlr4-cpp-demo */,
);
};
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
270925A71CDB409400522D32 /* antlrcpp.dylib */ = {
isa = PBXReferenceProxy;
fileType = "compiled.mach-o.dylib";
path = antlrcpp.dylib;
remoteRef = 270925A61CDB409400522D32 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
270925A91CDB409400522D32 /* libantlrcpp_static.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libantlrcpp_static.a;
remoteRef = 270925A81CDB409400522D32 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
273DC2BD1CDB619900DB7B2B /* antlrcpp_ios.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = antlrcpp_ios.framework;
remoteRef = 273DC2BC1CDB619900DB7B2B /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
37F135661B4AC02800E0CACF /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
27C66A721C9591EF0021E494 /* Generate Parser */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Generate Parser";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "pushd ..\nif [ TParser.g4 -nt generated/TParser.cpp -o TLexer.g4 -nt generated/TLexer.cpp ]; then\n./generate.sh;\nfi\npopd";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
27C66A631C9591280021E494 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
27C66A6A1C9591280021E494 /* main.cpp in Sources */,
27C6E1821C972FFC0079AF06 /* TParserBaseVisitor.cpp in Sources */,
270925B11CDB455B00522D32 /* TLexer.cpp in Sources */,
27C6E1831C972FFC0079AF06 /* TParserListener.cpp in Sources */,
27C6E1811C972FFC0079AF06 /* TParserBaseListener.cpp in Sources */,
27C6E1841C972FFC0079AF06 /* TParserVisitor.cpp in Sources */,
27C6E1801C972FFC0079AF06 /* TParser.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
37F135641B4AC02800E0CACF /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
37F1356D1B4AC02800E0CACF /* antlrcpp_Tests.mm in Sources */,
2747A7131CA6C46C0030247B /* InputHandlingTests.mm in Sources */,
274FC6D91CA96B6C008D4374 /* MiscClassTests.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
270925AB1CDB426900522D32 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = antlrcpp;
targetProxy = 270925AA1CDB426900522D32 /* PBXContainerItemProxy */;
};
270925AE1CDB428400522D32 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = antlrcpp_static;
targetProxy = 270925AD1CDB428400522D32 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
27C66A6C1C9591280021E494 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CODE_SIGN_IDENTITY = "-";
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
27C66A6D1C9591280021E494 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
37D727B51867AF1E007B6D10 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "../../runtime/src/antlrcpp-Prefix.h";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
../../runtime/src/tree/pattern,
../../runtime/src/tree,
../../runtime/src/support,
../../runtime/src/misc,
../../runtime/src/dfa,
../../runtime/src/atn,
../../runtime/src,
);
MACOSX_DEPLOYMENT_TARGET = 10.9;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
37D727B61867AF1E007B6D10 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "../../runtime/src/antlrcpp-Prefix.h";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
../../runtime/src/tree/pattern,
../../runtime/src/tree,
../../runtime/src/support,
../../runtime/src/misc,
../../runtime/src/dfa,
../../runtime/src/atn,
../../runtime/src,
);
MACOSX_DEPLOYMENT_TARGET = 10.9;
SDKROOT = macosx;
};
name = Release;
};
37F135711B4AC02800E0CACF /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
COMBINE_HIDPI_IMAGES = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(DEVELOPER_FRAMEWORKS_DIR)",
"$(inherited)",
);
GCC_NO_COMMON_BLOCKS = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INFOPLIST_FILE = "antlrcpp Tests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.antlr.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
37F135721B4AC02800E0CACF /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(DEVELOPER_FRAMEWORKS_DIR)",
"$(inherited)",
);
GCC_NO_COMMON_BLOCKS = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
INFOPLIST_FILE = "antlrcpp Tests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.antlr.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
27C66A6B1C9591280021E494 /* Build configuration list for PBXNativeTarget "antlr4-cpp-demo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
27C66A6C1C9591280021E494 /* Debug */,
27C66A6D1C9591280021E494 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
37D727A51867AF1E007B6D10 /* Build configuration list for PBXProject "antlrcpp-demo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
37D727B51867AF1E007B6D10 /* Debug */,
37D727B61867AF1E007B6D10 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
37F135731B4AC02800E0CACF /* Build configuration list for PBXNativeTarget "antlrcpp Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
37F135711B4AC02800E0CACF /* Debug */,
37F135721B4AC02800E0CACF /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 37D727A21867AF1E007B6D10 /* Project object */;
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

View File

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "27C66A661C9591280021E494"
BuildableName = "antlr4-cpp-demo"
BlueprintName = "antlr4-cpp-demo"
ReferencedContainer = "container:antlrcpp-demo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "37F135671B4AC02800E0CACF"
BuildableName = "antlrcpp Tests.xctest"
BlueprintName = "antlrcpp Tests"
ReferencedContainer = "container:antlrcpp-demo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "27C66A661C9591280021E494"
BuildableName = "antlr4-cpp-demo"
BlueprintName = "antlr4-cpp-demo"
ReferencedContainer = "container:antlrcpp-demo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "27C66A661C9591280021E494"
BuildableName = "antlr4-cpp-demo"
BlueprintName = "antlr4-cpp-demo"
ReferencedContainer = "container:antlrcpp-demo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "27C66A661C9591280021E494"
BuildableName = "antlr4-cpp-demo"
BlueprintName = "antlr4-cpp-demo"
ReferencedContainer = "container:antlrcpp-demo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "37F135671B4AC02800E0CACF"
BuildableName = "antlrcpp Tests.xctest"
BlueprintName = "antlrcpp Tests"
ReferencedContainer = "container:antlrcpp-demo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,27 @@
# Demo application for the ANTLR 4 C++ target
This demo app shows how to build the ANTLR runtime both as dynamic and static library and how to use a parser generated from a simple demo grammar.
A few steps are necessary to get this to work:
- Download the current ANTLR jar and place it in this folder.
- Open the generation script for your platform (generate.cmd for Windows, generate.sh for *nix/OSX) and update the LOCATION var to the actual name of the jar you downloaded.
- Run the generation script. This will generate a test parser + lexer, along with listener + visitor classes in a subfolder named "generated". This is where the demo application looks for these files.
- Open the project in the folder that matches your system.
- Compile (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,85 @@
lexer grammar TLexer;
// These are all supported lexer sections:
// Lexer file header. Appears at the top of h + cpp files. Use e.g. for copyrights.
@lexer::header {/* lexer header section */}
// Appears before any #include in h + cpp files.
@lexer::preinclude {/* lexer precinclude section */}
// Follows directly after the standard #includes in h + cpp files.
@lexer::postinclude {
/* lexer postinclude section */
#ifndef _WIN32
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
}
// Directly preceds the lexer class declaration in the h file (e.g. for additional types etc.).
@lexer::context {/* lexer context section */}
// Appears in the public part of the lexer in the h file.
@lexer::members {/* public lexer declarations section */
bool canTestFoo() { return true; }
bool isItFoo() { return true; }
bool isItBar() { return true; }
void myFooLexerAction() { /* do something*/ };
void myBarLexerAction() { /* do something*/ };
}
// Appears in the private part of the lexer in the h file.
@lexer::declarations {/* private lexer declarations/members section */}
// Appears in line with the other class member definitions in the cpp file.
@lexer::definitions {/* lexer definitions section */}
channels { COMMENTS_CHANNEL, DIRECTIVE }
tokens {
DUMMY
}
Return: 'return';
Continue: 'continue';
INT: Digit+;
Digit: [0-9];
ID: LETTER (LETTER | '0'..'9')*;
fragment LETTER : [a-zA-Z\u0080-\uFFFF];
LessThan: '<';
GreaterThan: '>';
Equal: '=';
And: 'and';
Colon: ':';
Semicolon: ';';
Plus: '+';
Minus: '-';
Star: '*';
OpenPar: '(';
ClosePar: ')';
OpenCurly: '{' -> pushMode(Mode1);
CloseCurly: '}' -> popMode;
QuestionMark: '?';
Comma: ',';
Dollar: '$' -> more, mode(Mode1), type(DUMMY);
String: '"' .*? '"';
Foo: {canTestFoo()}? 'foo' {isItFoo()}? { myFooLexerAction(); };
Bar: 'bar' {isItBar()}? { myBarLexerAction(); };
Any: Foo Dot Bar? DotDot Baz;
Comment : '#' ~[\r\n]* '\r'? '\n' -> skip ;
WS: [ \t\r\n]+ -> channel(99);
fragment Baz: 'Baz';
mode Mode1;
Dot: '.';
mode Mode2;
DotDot: '..';

118
runtime/Cpp/demo/TParser.g4 Normal file
View File

@ -0,0 +1,118 @@
parser grammar TParser;
options {
tokenVocab = TLexer;
}
// These are all supported parser sections:
// Parser file header. Appears at the top in all parser related files. Use e.g. for copyrights.
@parser::header {/* parser/listener/visitor header section */}
// Appears before any #include in h + cpp files.
@parser::preinclude {/* parser precinclude section */}
// Follows directly after the standard #includes in h + cpp files.
@parser::postinclude {
/* parser postinclude section */
#ifndef _WIN32
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
}
// Directly preceeds the parser class declaration in the h file (e.g. for additional types etc.).
@parser::context {/* parser context section */}
// Appears in the private part of the parser in the h file.
// The function bodies could also appear in the definitions section, but I want to maximize
// Java compatibility, so we can also create a Java parser from this grammar.
// Still, some tweaking is necessary after the Java file generation (e.g. bool -> boolean).
@parser::members {
/* public parser declarations/members section */
bool myAction() { return true; }
bool doesItBlend() { return true; }
void cleanUp() {}
void doInit() {}
void doAfter() {}
}
// Appears in the public part of the parser in the h file.
@parser::declarations {/* private parser declarations section */}
// Appears in line with the other class member definitions in the cpp file.
@parser::definitions {/* parser definitions section */}
// Additionally there are similar sections for (base)listener and (base)visitor files.
@parser::listenerpreinclude {/* listener preinclude section */}
@parser::listenerpostinclude {/* listener postinclude section */}
@parser::listenerdeclarations {/* listener public declarations/members section */}
@parser::listenermembers {/* listener private declarations/members section */}
@parser::listenerdefinitions {/* listener definitions section */}
@parser::baselistenerpreinclude {/* base listener preinclude section */}
@parser::baselistenerpostinclude {/* base listener postinclude section */}
@parser::baselistenerdeclarations {/* base listener public declarations/members section */}
@parser::baselistenermembers {/* base listener private declarations/members section */}
@parser::baselistenerdefinitions {/* base listener definitions section */}
@parser::visitorpreinclude {/* visitor preinclude section */}
@parser::visitorpostinclude {/* visitor postinclude section */}
@parser::visitordeclarations {/* visitor public declarations/members section */}
@parser::visitormembers {/* visitor private declarations/members section */}
@parser::visitordefinitions {/* visitor definitions section */}
@parser::basevisitorpreinclude {/* base visitor preinclude section */}
@parser::basevisitorpostinclude {/* base visitor postinclude section */}
@parser::basevisitordeclarations {/* base visitor public declarations/members section */}
@parser::basevisitormembers {/* base visitor private declarations/members section */}
@parser::basevisitordefinitions {/* base visitor definitions section */}
// Actual grammar start.
main: stat+ EOF;
divide : ID (and_ GreaterThan)? {doesItBlend()}?;
and_ @init{ doInit(); } @after { doAfter(); } : And ;
conquer:
divide+
| {doesItBlend()}? and_ { myAction(); }
| ID (LessThan* divide)?? { $ID.text; }
;
// Unused rule to demonstrate some of the special features.
unused[double input = 111] returns [double calculated] locals [int _a, double _b, int _c] @init{ doInit(); } @after { doAfter(); } :
stat
;
catch [...] {
// Replaces the standard exception handling.
}
finally {
cleanUp();
}
unused2:
(unused[1] .)+ (Colon | Semicolon | Plus)? ~Semicolon
;
stat: expr Equal expr Semicolon
| expr Semicolon
;
expr: expr Star expr
| expr Plus expr
| OpenPar expr ClosePar
| <assoc = right> expr QuestionMark expr Colon expr
| <assoc = right> expr Equal expr
| identifier = id
| flowControl
| INT
| String
;
flowControl:
Return expr # Return
| Continue # Continue
;
id: ID;
array : OpenCurly el += INT (Comma el += INT)* CloseCurly;
idarray : OpenCurly element += id (Comma element += id)* CloseCurly;

View File

@ -0,0 +1,192 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{24EC5104-7402-4C76-B66B-27ADBE062D68}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>antlr4cppdemo</RootNamespace>
<ProjectName>antlr4cpp-demo</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)..\generated;$(SolutionDir)..\..\runtime\src;$(SolutionDir)..\..\runtime\src\atn;$(SolutionDir)..\..\runtime\src\dfa;$(SolutionDir)..\..\runtime\src\misc;$(SolutionDir)..\..\runtime\src\support;$(SolutionDir)..\..\runtime\src\tree;$(SolutionDir)..\..\runtime\src\tree\xpath;$(SolutionDir)..\..\runtime\src\tree\pattern;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>antlrcpp-Prefix.h</ForcedIncludeFiles>
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)..\generated;$(SolutionDir)..\..\runtime\src;$(SolutionDir)..\..\runtime\src\atn;$(SolutionDir)..\..\runtime\src\dfa;$(SolutionDir)..\..\runtime\src\misc;$(SolutionDir)..\..\runtime\src\support;$(SolutionDir)..\..\runtime\src\tree;$(SolutionDir)..\..\runtime\src\tree\xpath;$(SolutionDir)..\..\runtime\src\tree\pattern;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>antlrcpp-Prefix.h</ForcedIncludeFiles>
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)..\generated;$(SolutionDir)..\..\runtime\src;$(SolutionDir)..\..\runtime\src\atn;$(SolutionDir)..\..\runtime\src\dfa;$(SolutionDir)..\..\runtime\src\misc;$(SolutionDir)..\..\runtime\src\support;$(SolutionDir)..\..\runtime\src\tree;$(SolutionDir)..\..\runtime\src\tree\xpath;$(SolutionDir)..\..\runtime\src\tree\pattern;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>antlrcpp-Prefix.h</ForcedIncludeFiles>
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)..\generated;$(SolutionDir)..\..\runtime\src;$(SolutionDir)..\..\runtime\src\atn;$(SolutionDir)..\..\runtime\src\dfa;$(SolutionDir)..\..\runtime\src\misc;$(SolutionDir)..\..\runtime\src\support;$(SolutionDir)..\..\runtime\src\tree;$(SolutionDir)..\..\runtime\src\tree\xpath;$(SolutionDir)..\..\runtime\src\tree\pattern;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>antlrcpp-Prefix.h</ForcedIncludeFiles>
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\generated\TLexer.cpp" />
<ClCompile Include="..\..\generated\TParser.cpp" />
<ClCompile Include="..\..\generated\TParserBaseListener.cpp" />
<ClCompile Include="..\..\generated\TParserBaseVisitor.cpp" />
<ClCompile Include="..\..\generated\TParserListener.cpp" />
<ClCompile Include="..\..\generated\TParserVisitor.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\runtime\src\antlrcpp-Prefix.h" />
<ClInclude Include="..\..\generated\TLexer.h" />
<ClInclude Include="..\..\generated\TParser.h" />
<ClInclude Include="..\..\generated\TParserBaseListener.h" />
<ClInclude Include="..\..\generated\TParserBaseVisitor.h" />
<ClInclude Include="..\..\generated\TParserListener.h" />
<ClInclude Include="..\..\generated\TParserVisitor.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\runtime\antlr4cpp.vcxproj">
<Project>{a9762991-1b57-4dce-90c0-ee42b96947be}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="generated">
<UniqueIdentifier>{ef397b7b-1192-4d44-93ed-fadaec7622e8}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\generated\TParser.cpp">
<Filter>generated</Filter>
</ClCompile>
<ClCompile Include="..\..\generated\TParserBaseListener.cpp">
<Filter>generated</Filter>
</ClCompile>
<ClCompile Include="..\..\generated\TParserBaseVisitor.cpp">
<Filter>generated</Filter>
</ClCompile>
<ClCompile Include="..\..\generated\TParserListener.cpp">
<Filter>generated</Filter>
</ClCompile>
<ClCompile Include="..\..\generated\TParserVisitor.cpp">
<Filter>generated</Filter>
</ClCompile>
<ClCompile Include="..\..\generated\TLexer.cpp">
<Filter>generated</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\generated\TLexer.h">
<Filter>generated</Filter>
</ClInclude>
<ClInclude Include="..\..\generated\TParser.h">
<Filter>generated</Filter>
</ClInclude>
<ClInclude Include="..\..\generated\TParserBaseListener.h">
<Filter>generated</Filter>
</ClInclude>
<ClInclude Include="..\..\generated\TParserBaseVisitor.h">
<Filter>generated</Filter>
</ClInclude>
<ClInclude Include="..\..\generated\TParserListener.h">
<Filter>generated</Filter>
</ClInclude>
<ClInclude Include="..\..\generated\TParserVisitor.h">
<Filter>generated</Filter>
</ClInclude>
<ClInclude Include="..\..\..\runtime\src\antlrcpp-Prefix.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -0,0 +1,35 @@
//
// 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"
#include <Windows.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);
std::shared_ptr<tree::ParseTree> tree = parser.main();
std::wstring s = tree->toStringTree(&parser) + L"\n";
OutputDebugString(s.data());
return 0;
}

View File

@ -0,0 +1,38 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "antlr4-cpp-demo", "antlr4-cpp-demo\antlr4-cpp-demo.vcxproj", "{24EC5104-7402-4C76-B66B-27ADBE062D68}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "antlr4cpp", "..\..\runtime\antlr4cpp.vcxproj", "{A9762991-1B57-4DCE-90C0-EE42B96947BE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Debug|Win32.ActiveCfg = Debug|Win32
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Debug|Win32.Build.0 = Debug|Win32
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Debug|x64.ActiveCfg = Debug|x64
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Debug|x64.Build.0 = Debug|x64
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Release|Win32.ActiveCfg = Release|Win32
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Release|Win32.Build.0 = Release|Win32
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Release|x64.ActiveCfg = Release|x64
{24EC5104-7402-4C76-B66B-27ADBE062D68}.Release|x64.Build.0 = Release|x64
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Debug|Win32.ActiveCfg = Debug|Win32
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Debug|Win32.Build.0 = Debug|Win32
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Debug|x64.ActiveCfg = Debug|x64
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Debug|x64.Build.0 = Debug|x64
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Release|Win32.ActiveCfg = Release|Win32
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Release|Win32.Build.0 = Release|Win32
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Release|x64.ActiveCfg = Release|x64
{A9762991-1B57-4DCE-90C0-EE42B96947BE}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,13 @@
@echo off
:: Created 2016, Mike Lischke (public domain)
:: This script is used to generate source files from the test grammars in the same folder. The generated files are placed
:: into a subfolder "generated" which the demo project uses to compile a demo binary.
:: Download the ANLTR jar and place it in the same folder as this script (or adjust the LOCATION var accordingly).
set LOCATION=antlr4-4.5.4-SNAPSHOT.jar
java -jar %LOCATION% -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
::java -jar %LOCATION% -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest -XdbgST TLexer.g4 TParser.g4
::java -jar %LOCATION% -Dlanguage=Java -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4

28
runtime/Cpp/demo/generate.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
set -o errexit
# Created 2016, Mike Lischke (public domain)
# This script is used to generate source files from the test grammars in the same folder. The generated files are placed
# into a subfolder "generated" which the demo project uses to compile a demo binary.
# There are 2 ways of running the ANTLR generator here.
# 1) Running from jar. Use the given jar (or replace it by another one you built or downloaded) for generation.
#LOCATION=antlr4-4.5.4-SNAPSHOT.jar
#java -jar $LOCATION -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
#java -jar $LOCATION -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest -XdbgST TLexer.g4 TParser.g4
#java -jar $LOCATION -Dlanguage=Java -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
# 2) Running from class path. This requires that you have both antlr3 and antlr4 compiled. In this scenario no installation
# is needed. You just compile the java class files (using "mvn compile" in both the antlr4 and the antlr3 root folders).
# The script then runs the generation using these class files, by specifying them on the classpath.
# Also the string template jar is needed. Adjust CLASSPATH if you have stored the jar in a different folder as this script assumes.
# Furthermore is assumed that the antlr3 folder is located side-by-side with the antlr4 folder. Adjust CLASSPATH if not.
# This approach is especially useful if you are working on a target stg file, as it doesn't require to regenerate the
# antlr jar over and over again.
CLASSPATH=../../../tool/resources/:ST-4.0.8.jar:../../../tool/target/classes:../../../runtime/Java/target/classes:../../../../antlr3/runtime/Java/target/classes
java -cp $CLASSPATH org.antlr.v4.Tool -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest TLexer.g4 TParser.g4
#java -cp $CLASSPATH org.antlr.v4.Tool -Dlanguage=Cpp -listener -visitor -o generated/ -package antlrcpptest -XdbgST TLexer.g4 TParser.g4
#java -cp $CLASSPATH org.antlr.v4.Tool -Dlanguage=Java -listener -visitor -o generated/ TLexer.g4 TParser.g4

View File

@ -1,40 +0,0 @@
#include "ANTLRErrorListener.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
}
}
}
}

View File

@ -1,167 +0,0 @@
#pragma once
#include "IRecognizer.h"
#include "Declarations.h"
#include "BitSet.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
/// <summary>
/// How to emit recognition errors. </summary>
class ANTLRErrorListener {
/// <summary>
/// Upon syntax error, notify any interested parties. This is not how to
/// recover from errors or compute error messages. <seealso cref="ANTLRErrorStrategy"/>
/// specifies how to recover from syntax errors and how to compute error
/// messages. This listener's job is simply to emit a computed message,
/// though it has enough information to create its own message in many cases.
/// <p/>
/// The <seealso cref="RecognitionException"/> is non-null for all syntax errors except
/// when we discover mismatched token errors that we can recover from
/// in-line, without returning from the surrounding rule (via the single
/// token insertion and deletion mechanism).
/// </summary>
/// <param name="recognizer">
/// What parser got the error. From this
/// object, you can access the context as well
/// as the input stream. </param>
/// <param name="offendingSymbol">
/// The offending token in the input token
/// stream, unless recognizer is a lexer (then it's null). If
/// no viable alternative error, {@code e} has token at which we
/// started production for the decision. </param>
/// <param name="line">
/// The line number in the input where the error occurred. </param>
/// <param name="charPositionInLine">
/// The character position within that line where the error occurred. </param>
/// <param name="msg">
/// The message to emit. </param>
/// <param name="e">
/// The exception generated by the parser that led to
/// the reporting of an error. It is null in the case where
/// the parser was able to recover in line without exiting the
/// surrounding rule. </param>
public:
template<typename T1, typename T2>
void syntaxError(IRecognizer<T1, T2> *recognizer, void *offendingSymbol,
int line, int charPositionInLine, const std::wstring &msg,
RecognitionException *e) {}
/// <summary>
/// This method is called by the parser when a full-context prediction
/// results in an ambiguity.
/// <p/>
/// When {@code exact} is {@code true}, <em>all</em> of the alternatives in
/// {@code ambigAlts} are viable, i.e. this is reporting an exact ambiguity.
/// When {@code exact} is {@code false}, <em>at least two</em> of the
/// alternatives in {@code ambigAlts} are viable for the current input, but
/// the prediction algorithm terminated as soon as it determined that at
/// least the <em>minimum</em> alternative in {@code ambigAlts} is viable.
/// <p/>
/// When the <seealso cref="PredictionMode#LL_EXACT_AMBIG_DETECTION"/> prediction mode
/// is used, the parser is required to identify exact ambiguities so
/// {@code exact} will always be {@code true}.
/// <p/>
/// This method is not used by lexers.
/// </summary>
/// <param name="recognizer"> the parser instance </param>
/// <param name="dfa"> the DFA for the current decision </param>
/// <param name="startIndex"> the input index where the decision started </param>
/// <param name="stopIndex"> the input input where the ambiguity is reported </param>
/// <param name="exact"> {@code true} if the ambiguity is exactly known, otherwise
/// {@code false}. This is always {@code true} when
/// <seealso cref="PredictionMode#LL_EXACT_AMBIG_DETECTION"/> is used. </param>
/// <param name="ambigAlts"> the potentially ambiguous alternatives </param>
/// <param name="configs"> the ATN configuration set where the ambiguity was
/// determined </param>
virtual void reportAmbiguity(Parser *recognizer, dfa::DFA *dfa, int startIndex, int stopIndex, bool exact, antlrcpp::BitSet *ambigAlts, atn::ATNConfigSet *configs) = 0;
/// <summary>
/// This method is called when an SLL conflict occurs and the parser is about
/// to use the full context information to make an LL decision.
/// <p/>
/// If one or more configurations in {@code configs} contains a semantic
/// predicate, the predicates are evaluated before this method is called. The
/// subset of alternatives which are still viable after predicates are
/// evaluated is reported in {@code conflictingAlts}.
/// <p/>
/// This method is not used by lexers.
/// </summary>
/// <param name="recognizer"> the parser instance </param>
/// <param name="dfa"> the DFA for the current decision </param>
/// <param name="startIndex"> the input index where the decision started </param>
/// <param name="stopIndex"> the input index where the SLL conflict occurred </param>
/// <param name="conflictingAlts"> The specific conflicting alternatives. If this is
/// {@code null}, the conflicting alternatives are all alternatives
/// represented in {@code configs}. </param>
/// <param name="configs"> the ATN configuration set where the SLL conflict was
/// detected </param>
virtual void reportAttemptingFullContext(Parser *recognizer, dfa::DFA *dfa, int startIndex, int stopIndex, antlrcpp::BitSet *conflictingAlts, atn::ATNConfigSet *configs) = 0;
/// <summary>
/// This method is called by the parser when a full-context prediction has a
/// unique result.
/// <p/>
/// For prediction implementations that only evaluate full-context
/// predictions when an SLL conflict is found (including the default
/// <seealso cref="ParserATNSimulator"/> implementation), this method reports cases
/// where SLL conflicts were resolved to unique full-context predictions,
/// i.e. the decision was context-sensitive. This report does not necessarily
/// indicate a problem, and it may appear even in completely unambiguous
/// grammars.
/// <p/>
/// {@code configs} may have more than one represented alternative if the
/// full-context prediction algorithm does not evaluate predicates before
/// beginning the full-context prediction. In all cases, the final prediction
/// is passed as the {@code prediction} argument.
/// <p/>
/// This method is not used by lexers.
/// </summary>
/// <param name="recognizer"> the parser instance </param>
/// <param name="dfa"> the DFA for the current decision </param>
/// <param name="startIndex"> the input index where the decision started </param>
/// <param name="stopIndex"> the input index where the context sensitivity was
/// finally determined </param>
/// <param name="prediction"> the unambiguous result of the full-context prediction </param>
/// <param name="configs"> the ATN configuration set where the unambiguous prediction
/// was determined </param>
virtual void reportContextSensitivity(Parser *recognizer, dfa::DFA *dfa, int startIndex, int stopIndex, int prediction, atn::ATNConfigSet *configs) = 0;
};
}
}
}
}

View File

@ -1,40 +0,0 @@
#include "ANTLRErrorStrategy.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
}
}
}
}

View File

@ -1,144 +0,0 @@
#pragma once
#include "Declarations.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
/// <summary>
/// The interface for defining strategies to deal with syntax errors encountered
/// during a parse by ANTLR-generated parsers. We distinguish between three
/// different kinds of errors:
///
/// <ul>
/// <li>The parser could not figure out which path to take in the ATN (none of
/// the available alternatives could possibly match)</li>
/// <li>The current input does not match what we were looking for</li>
/// <li>A predicate evaluated to false</li>
/// </ul>
///
/// Implementations of this interface report syntax errors by calling
/// <seealso cref="Parser#notifyErrorListeners"/>.
/// <p/>
/// TODO: what to do about lexers
/// </summary>
class ANTLRErrorStrategy {
/// <summary>
/// Reset the error handler state for the specified {@code recognizer}. </summary>
/// <param name="recognizer"> the parser instance </param>
public:
virtual void reset(Parser *recognizer) = 0;
/// <summary>
/// This method is called when an unexpected symbol is encountered during an
/// inline match operation, such as <seealso cref="Parser#match"/>. If the error
/// strategy successfully recovers from the match failure, this method
/// returns the <seealso cref="Token"/> instance which should be treated as the
/// successful result of the match.
/// <p/>
/// Note that the calling code will not report an error if this method
/// returns successfully. The error strategy implementation is responsible
/// for calling <seealso cref="Parser#notifyErrorListeners"/> as appropriate.
/// </summary>
/// <param name="recognizer"> the parser instance </param>
/// <exception cref="RecognitionException"> if the error strategy was not able to
/// recover from the unexpected input symbol </exception>
virtual Token *recoverInline(Parser *recognizer) = 0;
/// <summary>
/// This method is called to recover from exception {@code e}. This method is
/// called after <seealso cref="#reportError"/> by the default exception handler
/// generated for a rule method.
/// </summary>
/// <seealso cref= #reportError
/// </seealso>
/// <param name="recognizer"> the parser instance </param>
/// <param name="e"> the recognition exception to recover from </param>
/// <exception cref="RecognitionException"> if the error strategy could not recover from
/// the recognition exception </exception>
virtual void recover(Parser *recognizer, RecognitionException *e) = 0;
/// <summary>
/// This method provides the error handler with an opportunity to handle
/// syntactic or semantic errors in the input stream before they result in a
/// <seealso cref="RecognitionException"/>.
/// <p/>
/// The generated code currently contains calls to <seealso cref="#sync"/> after
/// entering the decision state of a closure block ({@code (...)*} or
/// {@code (...)+}).
/// <p/>
/// For an implementation based on Jim Idle's "magic sync" mechanism, see
/// <seealso cref="DefaultErrorStrategy#sync"/>.
/// </summary>
/// <seealso cref= DefaultErrorStrategy#sync
/// </seealso>
/// <param name="recognizer"> the parser instance </param>
/// <exception cref="RecognitionException"> if an error is detected by the error
/// strategy but cannot be automatically recovered at the current state in
/// the parsing process </exception>
virtual void sync(Parser *recognizer) = 0;
/// <summary>
/// Tests whether or not {@code recognizer} is in the process of recovering
/// from an error. In error recovery mode, <seealso cref="Parser#consume"/> adds
/// symbols to the parse tree by calling
/// <seealso cref="ParserRuleContext#addErrorNode(Token)"/> instead of
/// <seealso cref="ParserRuleContext#addChild(Token)"/>.
/// </summary>
/// <param name="recognizer"> the parser instance </param>
/// <returns> {@code true} if the parser is currently recovering from a parse
/// error, otherwise {@code false} </returns>
virtual bool inErrorRecoveryMode(Parser *recognizer) = 0;
/// <summary>
/// This method is called by when the parser successfully matches an input
/// symbol.
/// </summary>
/// <param name="recognizer"> the parser instance </param>
virtual void reportMatch(Parser *recognizer) = 0;
/// <summary>
/// Report any kind of <seealso cref="RecognitionException"/>. This method is called by
/// the default exception handler generated for a rule method.
/// </summary>
/// <param name="recognizer"> the parser instance </param>
/// <param name="e"> the recognition exception to report </param>
virtual void reportError(Parser *recognizer, RecognitionException *e) = 0;
};
}
}
}
}

View File

@ -1,88 +0,0 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstring>
#include "ANTLRFileStream.h"
#include "Exceptions.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
ANTLRFileStream::ANTLRFileStream(const std::string &fileName) {
}
ANTLRFileStream::ANTLRFileStream(const std::string &fileName, const std::string &encoding) {
this->fileName = fileName;
load(fileName, encoding);
}
/*
Issue: is seems that file name in C++ are considered to be not
wide for the reason that not all systems support wchar file
names. Win32 is good about this but not all others.
TODO: this could be a place to have platform specific build
flags
*/
void ANTLRFileStream::load(const std::string &fileName, const std::string &encoding) {
if (fileName == "") {
return;
}
std::stringstream ss;
std::wifstream f;
// Open as a byte stream
f.open(fileName, std::ios::binary);
ss<<f.rdbuf();
std::string const &s = ss.str();
if (s.size() % sizeof(wchar_t) != 0)
{
throw new IOException(L"file not the right size");
}
std::wstring ws;
ws.resize(s.size()/sizeof(wchar_t));
std::memcpy(&ws[0],s.c_str(),s.size()); // copy data into wstring
data=ws;
}
std::string ANTLRFileStream::getSourceName() {
return fileName;
}
}
}
}
}

View File

@ -1,209 +0,0 @@
#include "ANTLRInputStream.h"
#include "Exceptions.h"
#include "Interval.h"
#include "assert.h"
#include "Arrays.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
using misc::Interval;
ANTLRInputStream::ANTLRInputStream() {
InitializeInstanceFields();
}
ANTLRInputStream::ANTLRInputStream(const std::wstring &input) {
InitializeInstanceFields();
this->data = input;
this->n = (int)input.length();
}
ANTLRInputStream::ANTLRInputStream(wchar_t data[], int numberOfActualCharsInArray) {
InitializeInstanceFields();
this->data = data;
this->n = numberOfActualCharsInArray;
}
ANTLRInputStream::ANTLRInputStream(std::wifstream *r) {
}
ANTLRInputStream::ANTLRInputStream(std::wifstream *r, int initialSize) {
}
ANTLRInputStream::ANTLRInputStream(std::wifstream *r, int initialSize, int readChunkSize) {
InitializeInstanceFields();
load(r, initialSize, readChunkSize);
}
void ANTLRInputStream::load(std::wifstream *r, int size, int readChunkSize) {
if (r == nullptr) {
return;
}
if (size <= 0) {
size = INITIAL_BUFFER_SIZE;
}
if (readChunkSize <= 0) {
readChunkSize = READ_BUFFER_SIZE;
}
// System.out.println("load "+size+" in chunks of "+readChunkSize);
try {
// alloc initial buffer size.
data = new wchar_t[size];
// read all the data in chunks of readChunkSize
int numRead = 0;
int p = 0;
do {
if (p + readChunkSize > (int)data.length()) { // overflow?
// System.out.println("### overflow p="+p+", data.length="+data.length);
data = antlrcpp::Arrays::copyOf(data, (int)data.length() * 2);
}
r->read(new wchar_t[100], p);
// System.out.println("read "+numRead+" chars; p was "+p+" is now "+(p+numRead));
p += numRead;
} while (numRead != -1); // while not EOF
// set the actual size of the data available;
// EOF subtracted one above in p+=numRead; add one back
n = p + 1;
//System.out.println("n="+n);
}
catch (void *){
r->close();
}
}
void ANTLRInputStream::reset() {
p = 0;
}
void ANTLRInputStream::consume() {
if (p >= n) {
assert(LA(1) == IntStream::_EOF);
throw IllegalStateException(L"cannot consume EOF");
}
//System.out.println("prev p="+p+", c="+(char)data[p]);
if (p < n) {
p++;
//System.out.println("p moves to "+p+" (c='"+(char)data[p]+"')");
}
}
int ANTLRInputStream::LA(int i) {
if (i == 0) {
return 0; // undefined
}
if (i < 0) {
i++; // e.g., translate LA(-1) to use offset i=0; then data[p+0-1]
if ((p + i - 1) < 0) {
return IntStream::_EOF; // invalid; no char before first char
}
}
if ((p + i - 1) >= n) {
//System.out.println("char LA("+i+")=EOF; p="+p);
return IntStream::_EOF;
}
//System.out.println("char LA("+i+")="+(char)data[p+i-1]+"; p="+p);
//System.out.println("LA("+i+"); p="+p+" n="+n+" data.length="+data.length);
return data[p + i - 1];
}
int ANTLRInputStream::LT(int i) {
return LA(i);
}
int ANTLRInputStream::index() {
return p;
}
size_t ANTLRInputStream::size() {
return n;
}
int ANTLRInputStream::mark() {
return -1;
}
void ANTLRInputStream::release(int marker) {
}
void ANTLRInputStream::seek(int index) {
if (index <= p) {
p = index; // just jump; don't update stream state (line, ...)
return;
}
// seek forward, consume until p hits index
while (p < index && index < n) {
consume();
}
}
std::wstring ANTLRInputStream::getText(Interval *interval) {
int start = interval->a;
int stop = interval->b;
if (stop >= n) {
stop = n - 1;
}
int count = stop - start + 1;
if (start >= n) {
return L"";
}
// System.err.println("data: "+Arrays.toString(data)+", n="+n+
// ", start="+start+
// ", stop="+stop);
return std::wstring(data, start, count);
}
std::string ANTLRInputStream::getSourceName() {
return name;
}
std::wstring ANTLRInputStream::toString() {
return std::wstring(data);
}
void ANTLRInputStream::InitializeInstanceFields() {
n = 0;
p = 0;
}
}
}
}
}

View File

@ -1,145 +0,0 @@
#pragma once
#include <string>
#include <fstream>
#include "CharStream.h"
#include "Declarations.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
/// <summary>
/// Vacuum all input from a <seealso cref="Reader"/>/<seealso cref="InputStream"/> and then treat it
/// like a {@code char[]} buffer. Can also pass in a <seealso cref="String"/> or
/// {@code char[]} to use.
/// <p/>
/// If you need encoding, pass in stream/reader with correct encoding.
/// </summary>
class ANTLRInputStream : public CharStream {
public:
static const int READ_BUFFER_SIZE = 1024;
static const int INITIAL_BUFFER_SIZE = 1024;
/// <summary>
/// The data being scanned </summary>
protected:
std::wstring data;
/// <summary>
/// How many characters are actually in the buffer </summary>
int n;
/// <summary>
/// 0..n-1 index into string of next char </summary>
int p;
/// <summary>
/// What is name or source of this char stream? </summary>
public:
std::string name;
ANTLRInputStream();
/// <summary>
/// Copy data in string to a local char array </summary>
ANTLRInputStream(const std::wstring &input);
/// <summary>
/// This is the preferred constructor for strings as no data is copied </summary>
ANTLRInputStream(wchar_t data[], int numberOfActualCharsInArray);
ANTLRInputStream(std::wifstream *r) ; //this(r, INITIAL_BUFFER_SIZE, READ_BUFFER_SIZE);
ANTLRInputStream(std::wifstream *r, int initialSize) ; //this(r, initialSize, READ_BUFFER_SIZE);
ANTLRInputStream(std::wifstream *r, int initialSize, int readChunkSize);
ANTLRInputStream(std::wiostream *input) ; //this(new InputStreamReader(input), INITIAL_BUFFER_SIZE);
ANTLRInputStream(std::wiostream *input, int initialSize); //this(new InputStreamReader(input), initialSize);
ANTLRInputStream(std::wiostream *input, int initialSize, int readChunkSize); //this(new InputStreamReader(input), initialSize, readChunkSize);
virtual void load(std::wifstream *r, int size, int readChunkSize);
/// <summary>
/// Reset the stream so that it's in the same state it was
/// when the object was created *except* the data array is not
/// touched.
/// </summary>
virtual void reset();
virtual void consume() override;
virtual int LA(int i) override;
virtual int LT(int i);
/// <summary>
/// Return the current input symbol index 0..n where n indicates the
/// last symbol has been read. The index is the index of char to
/// be returned from LA(1).
/// </summary>
virtual int index() override;
virtual size_t size() override;
/// <summary>
/// mark/release do nothing; we have entire buffer </summary>
virtual int mark() override;
virtual void release(int marker) override;
/// <summary>
/// consume() ahead until p==index; can't just set p=index as we must
/// update line and charPositionInLine. If we seek backwards, just set p
/// </summary>
virtual void seek(int index) override;
virtual std::wstring getText(misc::Interval *interval) override;
virtual std::string getSourceName() override;
virtual std::wstring toString();
private:
void InitializeInstanceFields();
};
}
}
}
}

View File

@ -1,70 +0,0 @@
#pragma once
#include "DefaultErrorStrategy.h"
#include "Declarations.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
/// <summary>
/// Bail out of parser at first syntax error. Do this to use it:
/// <p/>
/// {@code myparser.setErrorHandler(new BailErrorStrategy());}
/// </summary>
class BailErrorStrategy : public DefaultErrorStrategy {
/// <summary>
/// Instead of recovering from exception {@code e}, re-throw it wrapped
/// in a <seealso cref="ParseCancellationException"/> so it is not caught by the
/// rule function catches. Use <seealso cref="Exception#getCause()"/> to get the
/// original <seealso cref="RecognitionException"/>.
/// </summary>
public:
virtual void recover(Parser *recognizer, RecognitionException *e) override;
/// <summary>
/// Make sure we don't attempt to recover inline; if the parser
/// successfully recovers, it won't throw an exception.
/// </summary>
virtual Token *recoverInline(Parser *recognizer) override;
/// <summary>
/// Make sure we don't attempt to recover from problems in subrules. </summary>
virtual void sync(Parser *recognizer) override;
};
}
}
}
}

View File

@ -1,410 +0,0 @@
#include <assert.h>
#include <algorithm>
#include "BufferedTokenStream.h"
#include "WritableToken.h"
#include "Lexer.h"
#include "Exceptions.h"
#include "StringBuilder.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
BufferedTokenStream::BufferedTokenStream(TokenSource *tokenSource) {
InitializeInstanceFields();
if (tokenSource == nullptr) {
throw new NullPointerException(L"tokenSource cannot be null");
}
this->tokenSource = tokenSource;
}
TokenSource *BufferedTokenStream::getTokenSource() {
return tokenSource;
}
int BufferedTokenStream::index() {
return p;
}
int BufferedTokenStream::mark() {
return 0;
}
void BufferedTokenStream::release(int marker) {
// no resources to release
}
void BufferedTokenStream::reset() {
seek(0);
}
void BufferedTokenStream::seek(int index) {
lazyInit();
p = adjustSeekIndex(index);
}
size_t BufferedTokenStream::size() {
return tokens.size();
}
void BufferedTokenStream::consume() {
if (LA(1) == _EOF) {
throw new IllegalStateException(L"cannot consume EOF");
}
if (sync(p + 1)) {
p = adjustSeekIndex(p + 1);
}
}
bool BufferedTokenStream::sync(int i) {
assert(i >= 0);
size_t n = i - tokens.size() + 1; // how many more elements we need?
//System.out.println("sync("+i+") needs "+n);
if (n > 0) {
size_t fetched = fetch((int)n);
return fetched >= n;
}
return true;
}
int BufferedTokenStream::fetch(int n) {
if (fetchedEOF) {
return 0;
}
for (int i = 0; i < n; i++) {
Token *t = tokenSource->nextToken();
if (dynamic_cast<WritableToken*>(t) != nullptr) {
(static_cast<WritableToken*>(t))->setTokenIndex((int)tokens.size());
}
tokens.push_back(t);
if (t->getType() == Token::_EOF) {
fetchedEOF = true;
return i + 1;
}
}
return n;
}
Token *BufferedTokenStream::get(int i) {
if (i < 0 || i >= (int)tokens.size()) {
throw IndexOutOfBoundsException(std::wstring(L"token index ") +
std::to_wstring(i) +
std::wstring(L" out of range 0..") +
std::to_wstring(tokens.size() - 1));
}
return tokens[i];
}
std::vector<Token*> BufferedTokenStream::get(int start, int stop) {
if (start < 0 || stop < 0) {
return std::vector<Token*>();
}
lazyInit();
std::vector<Token*> subset = std::vector<Token*>();
if (stop >= (int)tokens.size()) {
stop = (int)tokens.size() - 1;
}
for (int i = start; i <= stop; i++) {
Token *t = tokens[i];
if (t->getType() == Token::_EOF) {
break;
}
subset.push_back(t);
}
return subset;
}
int BufferedTokenStream::LA(int i) {
return LT(i)->getType();
}
Token *BufferedTokenStream::LB(int k) {
if ((p - k) < 0) {
return nullptr;
}
return tokens[p - k];
}
Token *BufferedTokenStream::LT(int k) {
lazyInit();
if (k == 0) {
return nullptr;
}
if (k < 0) {
return LB(-k);
}
int i = p + k - 1;
sync(i);
if (i >= (int)tokens.size()) { // return EOF token
// EOF must be last token
return tokens[tokens.size() - 1];
}
// if ( i>range ) range = i;
return tokens[i];
}
int BufferedTokenStream::adjustSeekIndex(int i) {
return i;
}
void BufferedTokenStream::lazyInit() {
if (p == -1) {
setup();
}
}
void BufferedTokenStream::setup() {
sync(0);
p = adjustSeekIndex(0);
}
void BufferedTokenStream::setTokenSource(TokenSource *tokenSource) {
this->tokenSource = tokenSource;
tokens.clear();
p = -1;
}
std::vector<Token*> BufferedTokenStream::getTokens() {
return tokens;
}
std::vector<Token*> BufferedTokenStream::getTokens(int start, int stop) {
return getTokens(start, stop, nullptr);
}
std::vector<Token*> BufferedTokenStream::getTokens(int start, int stop, std::vector<int> *types) {
lazyInit();
if (start < 0 || stop >= (int)tokens.size() || stop < 0 || (int)start >= (int)tokens.size()) {
throw new IndexOutOfBoundsException(std::wstring(L"start ") +
std::to_wstring(start) +
std::wstring(L" or stop ") +
std::to_wstring(stop) +
std::wstring(L" not in 0..") +
std::to_wstring(tokens.size() - 1));
}
if (start > stop) {
return std::vector<Token*>();
}
// list = tokens[start:stop]:{T t, t.getType() in types}
std::vector<Token*> filteredTokens = std::vector<Token*>();
for (int i = start; i <= stop; i++) {
Token *tok = tokens[i];
if (types == nullptr) {
filteredTokens.push_back(tok);
} else {
if (types == nullptr || std::find(types->begin(), types->end(), tok->getType()) != types->end()) {
filteredTokens.push_back(tok);
}
}
}
if (filteredTokens.empty()) {
filteredTokens.clear();
}
return filteredTokens;
}
std::vector<Token*> BufferedTokenStream::getTokens(int start, int stop, int ttype) {
std::vector<int> *s = new std::vector<int>();
s->insert(s->begin(), ttype);
return getTokens(start,stop, s);
}
int BufferedTokenStream::nextTokenOnChannel(int i, int channel) {
sync(i);
Token *token = tokens[i];
if (i >= (int)size()) {
return -1;
}
while (token->getChannel() != channel) {
if (token->getType() == Token::_EOF) {
return -1;
}
i++;
sync(i);
token = tokens[i];
}
return i;
}
int BufferedTokenStream::previousTokenOnChannel(int i, int channel) {
while (i >= 0 && tokens[i]->getChannel() != channel) {
i--;
}
return i;
}
std::vector<Token*> BufferedTokenStream::getHiddenTokensToRight(int tokenIndex, int channel) {
lazyInit();
if (tokenIndex < 0 || tokenIndex >= (int)tokens.size()) {
throw new IndexOutOfBoundsException(std::to_wstring(tokenIndex) +
std::wstring(L" not in 0..") +
std::to_wstring(tokens.size() - 1));
}
int nextOnChannel = nextTokenOnChannel(tokenIndex + 1, Lexer::DEFAULT_TOKEN_CHANNEL);
int to;
int from = tokenIndex + 1;
// if none onchannel to right, nextOnChannel=-1 so set to = last token
if (nextOnChannel == -1) {
to = (int)size() - 1;
} else {
to = nextOnChannel;
}
return filterForChannel(from, to, channel);
}
std::vector<Token*> BufferedTokenStream::getHiddenTokensToRight(int tokenIndex) {
return getHiddenTokensToRight(tokenIndex, -1);
}
std::vector<Token*> BufferedTokenStream::getHiddenTokensToLeft(int tokenIndex, int channel) {
lazyInit();
if (tokenIndex < 0 || tokenIndex >= (int)tokens.size()) {
throw new IndexOutOfBoundsException(std::to_wstring(tokenIndex) +
std::wstring(L" not in 0..") +
std::to_wstring(tokens.size() - 1));
}
int prevOnChannel = previousTokenOnChannel(tokenIndex - 1, Lexer::DEFAULT_TOKEN_CHANNEL);
if (prevOnChannel == tokenIndex - 1) {
return std::vector<Token*>();
}
// if none onchannel to left, prevOnChannel=-1 then from=0
int from = prevOnChannel + 1;
int to = tokenIndex - 1;
return filterForChannel(from, to, channel);
}
std::vector<Token*> BufferedTokenStream::getHiddenTokensToLeft(int tokenIndex) {
return getHiddenTokensToLeft(tokenIndex, -1);
}
std::vector<Token*> BufferedTokenStream::filterForChannel(int from, int to, int channel) {
std::vector<Token*> hidden = std::vector<Token*>();
for (int i = from; i <= to; i++) {
Token *t = tokens[i];
if (channel == -1) {
if (t->getChannel() != Lexer::DEFAULT_TOKEN_CHANNEL) {
hidden.push_back(t);
}
} else {
if (t->getChannel() == channel) {
hidden.push_back(t);
}
}
}
if (hidden.empty()) {
return std::vector<Token*>();
}
return hidden;
}
/**
* Get the text of all tokens in this buffer.
*/
std::string BufferedTokenStream::getSourceName()
{
return tokenSource->getSourceName();
}
std::wstring BufferedTokenStream::getText() {
lazyInit();
fill();
return getText(misc::Interval::of(0, (int)size() - 1));
}
std::wstring BufferedTokenStream::getText(misc::Interval *interval) {
int start = interval->a;
int stop = interval->b;
if (start < 0 || stop < 0) {
return L"";
}
lazyInit();
if (stop >= (int)tokens.size()) {
stop = (int)tokens.size() - 1;
}
antlrcpp::StringBuilder *buf = new antlrcpp::StringBuilder();
for (int i = start; i <= stop; i++) {
Token *t = tokens[i];
if (t->getType() == Token::_EOF) {
break;
}
buf->append(t->getText());
}
return buf->toString();
}
std::wstring BufferedTokenStream::getText(RuleContext *ctx) {
return getText(ctx->getSourceInterval());
}
std::wstring BufferedTokenStream::getText(Token *start, Token *stop) {
if (start != nullptr && stop != nullptr) {
return getText(misc::Interval::of(start->getTokenIndex(), stop->getTokenIndex()));
}
return L"";
}
void BufferedTokenStream::fill() {
lazyInit();
const int blockSize = 1000;
while (true) {
int fetched = fetch(blockSize);
if (fetched < blockSize) {
return;
}
}
}
void BufferedTokenStream::InitializeInstanceFields() {
tokens = antlrcpp::VectorHelper::VectorWithReservedSize<Token*>(100);
p = -1;
fetchedEOF = false;
}
}
}
}
}

View File

@ -1,240 +0,0 @@
#pragma once
#include "Token.h"
#include "Interval.h"
#include "TokenStream.h"
#include "TokenSource.h"
#include "RuleContext.h"
#include "vectorhelper.h"
#include <string>
#include <vector>
#include <set>
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
/// <summary>
/// Buffer all input tokens but do on-demand fetching of new tokens from lexer.
/// Useful when the parser or lexer has to set context/mode info before proper
/// lexing of future tokens. The ST template parser needs this, for example,
/// because it has to constantly flip back and forth between inside/output
/// templates. E.g., {@code <names:{hi, <it>}>} has to parse names as part of an
/// expression but {@code "hi, <it>"} as a nested template.
/// <p/>
/// You can't use this stream if you pass whitespace or other off-channel tokens
/// to the parser. The stream can't ignore off-channel tokens.
/// (<seealso cref="UnbufferedTokenStream"/> is the same way.) Use
/// <seealso cref="CommonTokenStream"/>.
/// </summary>
class BufferedTokenStream : public TokenStream {
protected:
TokenSource *tokenSource;
/// <summary>
/// Record every single token pulled from the source so we can reproduce
/// chunks of it later. This list captures everything so we can access
/// complete input text.
/// </summary>
std::vector<Token*> tokens;
/// <summary>
/// The index into <seealso cref="#tokens"/> of the current token (next token to
/// consume). <seealso cref="#tokens"/>{@code [}<seealso cref="#p"/>{@code ]} should be
/// <seealso cref="#LT LT(1)"/>. <seealso cref="#p"/>{@code =-1} indicates need to initialize
/// with first token. The constructor doesn't get a token. First call to
/// <seealso cref="#LT LT(1)"/> or whatever gets the first token and sets
/// <seealso cref="#p"/>{@code =0;}.
/// </summary>
int p;
/// <summary>
/// Set to {@code true} when the EOF token is fetched. Do not continue fetching
/// tokens after that point, or multiple EOF tokens could end up in the
/// <seealso cref="#tokens"/> array.
/// </summary>
/// <seealso cref= #fetch </seealso>
bool fetchedEOF;
public:
BufferedTokenStream(TokenSource *tokenSource);
virtual TokenSource *getTokenSource() override;
virtual int index() override;
virtual int mark() override;
virtual void release(int marker) override;
virtual void reset();
virtual void seek(int index) override;
virtual size_t size() override;
virtual void consume() override;
/// <summary>
/// Make sure index {@code i} in tokens has a token.
/// </summary>
/// <returns> {@code true} if a token is located at index {@code i}, otherwise
/// {@code false}. </returns>
/// <seealso cref= #get(int i) </seealso>
protected:
virtual bool sync(int i);
/// <summary>
/// Add {@code n} elements to buffer.
/// </summary>
/// <returns> The actual number of elements added to the buffer. </returns>
virtual int fetch(int n);
public:
virtual Token *get(int i) override;
/// <summary>
/// Get all tokens from start..stop inclusively </summary>
virtual std::vector<Token*> get(int start, int stop);
virtual int LA(int i) override;
protected:
virtual Token *LB(int k);
public:
virtual Token *LT(int k) override;
/// <summary>
/// Allowed derived classes to modify the behavior of operations which change
/// the current stream position by adjusting the target token index of a seek
/// operation. The default implementation simply returns {@code i}. If an
/// exception is thrown in this method, the current stream index should not be
/// changed.
/// <p/>
/// For example, <seealso cref="CommonTokenStream"/> overrides this method to ensure that
/// the seek target is always an on-channel token.
/// </summary>
/// <param name="i"> The target token index. </param>
/// <returns> The adjusted target token index. </returns>
protected:
virtual int adjustSeekIndex(int i);
void lazyInit();
virtual void setup();
/// <summary>
/// Reset this token stream by setting its token source. </summary>
public:
virtual void setTokenSource(TokenSource *tokenSource);
virtual std::vector<Token*> getTokens();
virtual std::vector<Token*> getTokens(int start, int stop);
/// <summary>
/// Given a start and stop index, return a List of all tokens in
/// the token type BitSet. Return null if no tokens were found. This
/// method looks at both on and off channel tokens.
/// </summary>
virtual std::vector<Token*> getTokens(int start, int stop, std::vector<int> *types);
virtual std::vector<Token*> getTokens(int start, int stop, int ttype);
/// <summary>
/// Given a starting index, return the index of the next token on channel.
/// Return i if tokens[i] is on channel. Return -1 if there are no tokens
/// on channel between i and EOF.
/// </summary>
protected:
virtual int nextTokenOnChannel(int i, int channel);
/// <summary>
/// Given a starting index, return the index of the previous token on channel.
/// Return i if tokens[i] is on channel. Return -1 if there are no tokens
/// on channel between i and 0.
/// </summary>
virtual int previousTokenOnChannel(int i, int channel);
/// <summary>
/// Collect all tokens on specified channel to the right of
/// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL or
/// EOF. If channel is -1, find any non default channel token.
/// </summary>
public:
virtual std::vector<Token*> getHiddenTokensToRight(int tokenIndex, int channel);
/// <summary>
/// Collect all hidden tokens (any off-default channel) to the right of
/// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL
/// of EOF.
/// </summary>
virtual std::vector<Token*> getHiddenTokensToRight(int tokenIndex);
/// <summary>
/// Collect all tokens on specified channel to the left of
/// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL.
/// If channel is -1, find any non default channel token.
/// </summary>
virtual std::vector<Token*> getHiddenTokensToLeft(int tokenIndex, int channel);
/// <summary>
/// Collect all hidden tokens (any off-default channel) to the left of
/// the current token up until we see a token on DEFAULT_TOKEN_CHANNEL.
/// </summary>
virtual std::vector<Token*> getHiddenTokensToLeft(int tokenIndex);
protected:
virtual std::vector<Token*> filterForChannel(int from, int to, int channel);
public:
virtual std::string getSourceName() override;
virtual std::wstring getText() override;
virtual std::wstring getText(misc::Interval *interval) override;
virtual std::wstring getText(RuleContext *ctx) override;
virtual std::wstring getText(Token *start, Token *stop) override;
/// <summary>
/// Get all tokens from lexer until EOF </summary>
virtual void fill();
private:
void InitializeInstanceFields();
};
}
}
}
}

View File

@ -1,68 +0,0 @@
#pragma once
#include "IntStream.h"
#include "Declarations.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
/// <summary>
/// A source of characters for an ANTLR lexer. </summary>
class CharStream : public IntStream {
/// <summary>
/// This method returns the text for a range of characters within this input
/// stream. This method is guaranteed to not throw an exception if the
/// specified {@code interval} lies entirely within a marked range. For more
/// information about marked ranges, see <seealso cref="IntStream#mark"/>.
/// </summary>
/// <param name="interval"> an interval within the stream </param>
/// <returns> the text of the specified interval
/// </returns>
/// <exception cref="NullPointerException"> if {@code interval} is {@code null} </exception>
/// <exception cref="IllegalArgumentException"> if {@code interval.a < 0}, or if
/// {@code interval.b < interval.a - 1}, or if {@code interval.b} lies at or
/// past the end of the stream </exception>
/// <exception cref="UnsupportedOperationException"> if the stream does not support
/// getting the text of the specified interval </exception>
public:
virtual std::wstring getText(misc::Interval *interval) = 0;
virtual ~CharStream() = 0;
};
}
}
}
}

View File

@ -1,204 +0,0 @@
#include "CommonToken.h"
#include "Interval.h"
#include "TokenSource.h"
#include "Strings.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
std::pair<TokenSource*, CharStream*> *const CommonToken::EMPTY_SOURCE = new std::pair<TokenSource*, CharStream*>(nullptr, nullptr);
CommonToken::CommonToken(int type) {
InitializeInstanceFields();
this->type = type;
}
CommonToken::CommonToken(std::pair<TokenSource*, CharStream*> *source, int type, int channel, int start, int stop) {
InitializeInstanceFields();
this->source = source;
this->type = type;
this->channel = channel;
this->start = start;
this->stop = stop;
if (source->first != nullptr) {
this->line = source->first->getLine();
this->charPositionInLine = source->first->getCharPositionInLine();
}
}
CommonToken::CommonToken(int type, const std::wstring &text) {
InitializeInstanceFields();
this->type = type;
this->channel = DEFAULT_CHANNEL;
this->text = text;
this->source = EMPTY_SOURCE;
}
CommonToken::CommonToken(Token *oldToken) {
InitializeInstanceFields();
text = oldToken->getText();
type = oldToken->getType();
line = oldToken->getLine();
index = oldToken->getTokenIndex();
charPositionInLine = oldToken->getCharPositionInLine();
channel = oldToken->getChannel();
start = oldToken->getStartIndex();
stop = oldToken->getStopIndex();
if (dynamic_cast<CommonToken*>(oldToken) != nullptr) {
source = (static_cast<CommonToken*>(oldToken))->source;
} else {
source = new std::pair<TokenSource*, CharStream*>(oldToken->getTokenSource(), oldToken->getInputStream());
}
}
int CommonToken::getType() {
return type;
}
void CommonToken::setLine(int line) {
this->line = line;
}
std::wstring CommonToken::getText() {
if (text != L"") {
return text;
}
CharStream *input = getInputStream();
if (input == nullptr) {
return L"";
}
size_t n = input->size();
if ((size_t)start < n && (size_t)stop < n) {
return input->getText(misc::Interval::of(start,stop));
} else {
return L"<EOF>";
}
}
void CommonToken::setText(const std::wstring &text) {
this->text = text;
}
int CommonToken::getLine() {
return line;
}
int CommonToken::getCharPositionInLine() {
return charPositionInLine;
}
void CommonToken::setCharPositionInLine(int charPositionInLine) {
this->charPositionInLine = charPositionInLine;
}
int CommonToken::getChannel() {
return channel;
}
void CommonToken::setChannel(int channel) {
this->channel = channel;
}
void CommonToken::setType(int type) {
this->type = type;
}
int CommonToken::getStartIndex() {
return start;
}
void CommonToken::setStartIndex(int start) {
this->start = start;
}
int CommonToken::getStopIndex() {
return stop;
}
void CommonToken::setStopIndex(int stop) {
this->stop = stop;
}
int CommonToken::getTokenIndex() {
return index;
}
void CommonToken::setTokenIndex(int index) {
this->index = index;
}
org::antlr::v4::runtime::TokenSource *CommonToken::getTokenSource() {
return source->first;
}
org::antlr::v4::runtime::CharStream *CommonToken::getInputStream() {
return source->second;
}
std::wstring CommonToken::toString() {
std::wstring channelStr = L"";
if (channel > 0) {
channelStr = std::wstring(L",channel=") + std::to_wstring(channel);
}
std::wstring txt = getText();
if (txt != L"") {
antlrcpp::replaceAll(txt, L"\n",L"\\n");
antlrcpp::replaceAll(txt, L"\r",L"\\r");
antlrcpp::replaceAll(txt, L"\t",L"\\t");
} else {
txt = L"<no text>";
}
return std::wstring(L"[@") + std::to_wstring(getTokenIndex()) + std::wstring(L",") + std::to_wstring(start) + std::wstring(L":") + std::to_wstring(stop) + std::wstring(L"='") + txt + std::wstring(L"',<") + std::to_wstring(type) + std::wstring(L">") + channelStr + std::wstring(L",") + std::to_wstring(line) + std::wstring(L":") + std::to_wstring(getCharPositionInLine()) + std::wstring(L"]");
}
void CommonToken::InitializeInstanceFields() {
type = 0;
line = 0;
charPositionInLine = -1;
channel = DEFAULT_CHANNEL;
index = -1;
start = 0;
stop = 0;
}
}
}
}
}

View File

@ -1,136 +0,0 @@
#pragma once
#include "WritableToken.h"
#include "CharStream.h"
#include "Declarations.h"
#include <string>
#include <utility>
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
class CommonToken : public WritableToken {
protected:
static std::pair<TokenSource*, CharStream*> *const EMPTY_SOURCE;
int type;
int line;
int charPositionInLine; // set to invalid position
int channel;
std::pair<TokenSource*, CharStream*> *source;
/// <summary>
/// We need to be able to change the text once in a while. If
/// this is non-null, then getText should return this. Note that
/// start/stop are not affected by changing this.
/// </summary>
// TODO: can store these in map in token stream rather than as field here
std::wstring text;
/// <summary>
/// What token number is this from 0..n-1 tokens; < 0 implies invalid index </summary>
int index;
/// <summary>
/// The char position into the input buffer where this token starts </summary>
int start;
/// <summary>
/// The char position into the input buffer where this token stops </summary>
int stop;
public:
CommonToken(int type);
CommonToken(std::pair<TokenSource*, CharStream*> *source, int type, int channel, int start, int stop);
CommonToken(int type, const std::wstring &text);
CommonToken(Token *oldToken);
virtual int getType() override;
virtual void setLine(int line) override;
virtual std::wstring getText() override;
/// <summary>
/// Override the text for this token. getText() will return this text
/// rather than pulling from the buffer. Note that this does not mean
/// that start/stop indexes are not valid. It means that that input
/// was converted to a new string in the token object.
/// </summary>
virtual void setText(const std::wstring &text) override;
virtual int getLine() override;
virtual int getCharPositionInLine() override;
virtual void setCharPositionInLine(int charPositionInLine) override;
virtual int getChannel() override;
virtual void setChannel(int channel) override;
virtual void setType(int type) override;
virtual int getStartIndex() override;
virtual void setStartIndex(int start);
virtual int getStopIndex() override;
virtual void setStopIndex(int stop);
virtual int getTokenIndex() override;
virtual void setTokenIndex(int index) override;
virtual TokenSource *getTokenSource() override;
virtual CharStream *getInputStream() override;
virtual std::wstring toString() ;
private:
void InitializeInstanceFields();
};
}
}
}
}

View File

@ -1,75 +0,0 @@
#pragma once
#include "CommonToken.h"
#include "TokenFactory.h"
#include "CharStream.h"
#include "TokenSource.h"
#include <string>
#include <utility>
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
class CommonTokenFactory : public TokenFactory<CommonToken*> {
public:
static TokenFactory<CommonToken*> *const DEFAULT;
/// <summary>
/// Copy text for token out of input char stream. Useful when input
/// stream is unbuffered. </summary>
/// <seealso cref= UnbufferedCharStream </seealso>
protected:
const bool copyText;
/// <summary>
/// Create factory and indicate whether or not the factory copy
/// text out of the char stream.
/// </summary>
public:
CommonTokenFactory(bool copyText);
CommonTokenFactory();
virtual CommonToken *create(std::pair<TokenSource*, CharStream*> *source, int type, const std::wstring &text, int channel, int start, int stop, int line, int charPositionInLine) override;
virtual CommonToken *create(int type, const std::wstring &text) override;
};
}
}
}
}

View File

@ -1,115 +0,0 @@
#include "CommonTokenStream.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
CommonTokenStream::CommonTokenStream(TokenSource *tokenSource) : BufferedTokenStream(tokenSource) {
InitializeInstanceFields();
}
CommonTokenStream::CommonTokenStream(TokenSource *tokenSource, int channel)
: BufferedTokenStream(tokenSource)
{
this->channel = channel;
}
int CommonTokenStream::adjustSeekIndex(int i) {
return nextTokenOnChannel(i, channel);
}
Token *CommonTokenStream::LB(int k) {
if (k == 0 || (p - k) < 0) {
return nullptr;
}
int i = p;
int n = 1;
// find k good tokens looking backwards
while (n <= k) {
// skip off-channel tokens
i = previousTokenOnChannel(i - 1, channel);
n++;
}
if (i < 0) {
return nullptr;
}
return tokens[i];
}
Token *CommonTokenStream::LT(int k) {
//System.out.println("enter LT("+k+")");
lazyInit();
if (k == 0) {
return nullptr;
}
if (k < 0) {
return LB(-k);
}
int i = p;
int n = 1; // we know tokens[p] is a good one
// find k good tokens
while (n < k) {
// skip off-channel tokens, but make sure to not look past EOF
if (sync(i + 1)) {
i = nextTokenOnChannel(i + 1, channel);
}
n++;
}
// if ( i>range ) range = i;
return tokens[i];
}
int CommonTokenStream::getNumberOfOnChannelTokens() {
int n = 0;
fill();
for (size_t i = 0; i < tokens.size(); i++) {
Token *t = tokens[i];
if (t->getChannel() == channel) {
n++;
}
if (t->getType() == Token::_EOF) {
break;
}
}
return n;
}
void CommonTokenStream::InitializeInstanceFields() {
channel = Token::DEFAULT_CHANNEL;
}
}
}
}
}

View File

@ -1,89 +0,0 @@
#pragma once
#include "BufferedTokenStream.h"
#include "TokenSource.h"
#include "Token.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
/// <summary>
/// The most common stream of tokens where every token is buffered up
/// and tokens are filtered for a certain channel (the parser will only
/// see these tokens).
///
/// Even though it buffers all of the tokens, this token stream pulls tokens
/// from the tokens source on demand. In other words, until you ask for a
/// token using consume(), LT(), etc. the stream does not pull from the lexer.
///
/// The only difference between this stream and <seealso cref="BufferedTokenStream"/> superclass
/// is that this stream knows how to ignore off channel tokens. There may be
/// a performance advantage to using the superclass if you don't pass
/// whitespace and comments etc. to the parser on a hidden channel (i.e.,
/// you set {@code $channel} instead of calling {@code skip()} in lexer rules.)
/// </summary>
/// <seealso cref= UnbufferedTokenStream </seealso>
/// <seealso cref= BufferedTokenStream </seealso>
class CommonTokenStream : public BufferedTokenStream {
/// <summary>
/// Skip tokens on any channel but this one; this is how we skip whitespace... </summary>
protected:
int channel;
public:
CommonTokenStream(TokenSource *tokenSource);
CommonTokenStream(TokenSource *tokenSource, int channel);
protected:
virtual int adjustSeekIndex(int i) override;
virtual Token *LB(int k) override;
public:
virtual Token *LT(int k) override;
/// <summary>
/// Count EOF just once. </summary>
virtual int getNumberOfOnChannelTokens();
private:
void InitializeInstanceFields();
};
}
}
}
}

View File

@ -1,378 +0,0 @@
#include <locale>
#include <codecvt>
#include <string>
#include "DefaultErrorStrategy.h"
#include "NoViableAltException.h"
#include "IntervalSet.h"
#include "ParserATNSimulator.h"
#include "InputMismatchException.h"
#include "Exceptions.h"
#include "ATN.h"
#include "ATNState.h"
#include "Transition.h"
#include "Strings.h"
#include "RuleTransition.h"
#include "TokenSource.h"
#include "FailedPredicateException.h"
#include "ParserRuleContext.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
void DefaultErrorStrategy::reset(Parser *recognizer) {
endErrorCondition(recognizer);
}
void DefaultErrorStrategy::beginErrorCondition(Parser *recognizer) {
errorRecoveryMode = true;
}
bool DefaultErrorStrategy::inErrorRecoveryMode(Parser *recognizer) {
return errorRecoveryMode;
}
void DefaultErrorStrategy::endErrorCondition(Parser *recognizer) {
errorRecoveryMode = false;
delete lastErrorStates;
lastErrorIndex = -1;
}
void DefaultErrorStrategy::reportMatch(Parser *recognizer) {
endErrorCondition(recognizer);
}
void DefaultErrorStrategy::reportError(Parser *recognizer, RecognitionException *e) {
// if we've already reported an error and have not matched a token
// yet successfully, don't report any errors.
if (inErrorRecoveryMode(recognizer)) {
// System.err.print("[SPURIOUS] ");
return; // don't report spurious errors
}
beginErrorCondition(recognizer);
if (dynamic_cast<NoViableAltException*>(e) != nullptr) {
reportNoViableAlternative(recognizer, static_cast<NoViableAltException*>(e));
} else if (dynamic_cast<InputMismatchException*>(e) != nullptr) {
reportInputMismatch(recognizer, static_cast<InputMismatchException*>(e));
} else if (dynamic_cast<FailedPredicateException*>(e) != nullptr) {
reportFailedPredicate(recognizer, dynamic_cast<FailedPredicateException*>(e));
} else {
// This is really bush league, I hate libraries that gratuitiously print
// stuff out
std::wcerr << std::wstring(L"unknown recognition error type: " +
antlrcpp::s2ws(typeid(e).name()));
recognizer->notifyErrorListeners(e->getOffendingToken(), antlrcpp::s2ws(e->what()), e);
}
}
void DefaultErrorStrategy::recover(Parser *recognizer, RecognitionException *e) {
// System.out.println("recover in "+recognizer.getRuleInvocationStack()+
// " index="+recognizer.getInputStream().index()+
// ", lastErrorIndex="+
// lastErrorIndex+
// ", states="+lastErrorStates);
if (lastErrorIndex == recognizer->getInputStream()->index() && lastErrorStates != nullptr && lastErrorStates->contains(recognizer->getState())) {
// uh oh, another error at same token index and previously-visited
// state in ATN; must be a case where LT(1) is in the recovery
// token set so nothing got consumed. Consume a single token
// at least to prevent an infinite loop; this is a failsafe.
// System.err.println("seen error condition before index="+
// lastErrorIndex+", states="+lastErrorStates);
// System.err.println("FAILSAFE consumes "+recognizer.getTokenNames()[recognizer.getInputStream().LA(1)]);
recognizer->consume();
}
lastErrorIndex = recognizer->getInputStream()->index();
if (lastErrorStates == nullptr) {
lastErrorStates = new misc::IntervalSet(0);
}
lastErrorStates->add(recognizer->getState());
misc::IntervalSet *followSet = getErrorRecoverySet(recognizer);
consumeUntil(recognizer, followSet);
}
void DefaultErrorStrategy::sync(Parser *recognizer) {
atn::ATNState *s = recognizer->getInterpreter()->atn->states[recognizer->getState()];
// System.err.println("sync @ "+s.stateNumber+"="+s.getClass().getSimpleName());
// If already recovering, don't try to sync
if (inErrorRecoveryMode(recognizer)) {
return;
}
TokenStream *tokens = recognizer->getInputStream();
int la = tokens->LA(1);
// try cheaper subset first; might get lucky. seems to shave a wee bit off
if (recognizer->getATN()->nextTokens(s)->contains(la) || la == Token::_EOF) {
return;
}
// Return but don't end recovery. only do that upon valid token match
if (recognizer->isExpectedToken(la)) {
return;
}
switch (s->getStateType()) {
case atn::ATNState::BLOCK_START:
case atn::ATNState::STAR_BLOCK_START:
case atn::ATNState::PLUS_BLOCK_START:
case atn::ATNState::STAR_LOOP_ENTRY:
// report error and recover if possible
if (singleTokenDeletion(recognizer) != nullptr) {
return;
}
throw new InputMismatchException(recognizer);
case atn::ATNState::PLUS_LOOP_BACK:
case atn::ATNState::STAR_LOOP_BACK: {
// System.err.println("at loop back: "+s.getClass().getSimpleName());
reportUnwantedToken(recognizer);
misc::IntervalSet *expecting = recognizer->getExpectedTokens();
misc::IntervalSet *whatFollowsLoopIterationOrRule = expecting->Or(getErrorRecoverySet(recognizer));
consumeUntil(recognizer, whatFollowsLoopIterationOrRule);
}
break;
default:
// do nothing if we can't identify the exact kind of ATN state
break;
}
}
void DefaultErrorStrategy::reportNoViableAlternative(Parser *recognizer, NoViableAltException *e) {
TokenStream *tokens = recognizer->getInputStream();
std::wstring input;
if (tokens != nullptr) {
if (e->getStartToken()->getType() == Token::_EOF) {
input = L"<EOF>";
} else {
input = tokens->getText(e->getStartToken(), e->getOffendingToken());
}
} else {
input = L"<unknown input>";
}
std::wstring msg = std::wstring(L"no viable alternative at input ") + escapeWSAndQuote(input);
recognizer->notifyErrorListeners(e->getOffendingToken(), msg, e);
}
void DefaultErrorStrategy::reportInputMismatch(Parser *recognizer, InputMismatchException *e) {
std::wstring msg = std::wstring(L"mismatched input ") + getTokenErrorDisplay(e->getOffendingToken()) + std::wstring(L" expecting ") + e->getExpectedTokens()->toString(recognizer->getTokenNames());
recognizer->notifyErrorListeners(e->getOffendingToken(), msg, e);
}
void DefaultErrorStrategy::reportFailedPredicate(Parser *recognizer, FailedPredicateException *e) {
const std::wstring& ruleName = recognizer->getRuleNames()[recognizer->_ctx->getRuleIndex()];
std::wstring msg = std::wstring(L"rule ") + ruleName + std::wstring(L" ") + e->getMessage();
recognizer->notifyErrorListeners(e->getOffendingToken(), msg, e);
}
void DefaultErrorStrategy::reportUnwantedToken(Parser *recognizer) {
if (inErrorRecoveryMode(recognizer)) {
return;
}
beginErrorCondition(recognizer);
Token *t = recognizer->getCurrentToken();
std::wstring tokenName = getTokenErrorDisplay(t);
misc::IntervalSet *expecting = getExpectedTokens(recognizer);
std::wstring msg = std::wstring(L"extraneous input ") + tokenName + std::wstring(L" expecting ") + expecting->toString(recognizer->getTokenNames());
recognizer->notifyErrorListeners(t, msg, nullptr);
}
void DefaultErrorStrategy::reportMissingToken(Parser *recognizer) {
if (inErrorRecoveryMode(recognizer)) {
return;
}
beginErrorCondition(recognizer);
Token *t = recognizer->getCurrentToken();
misc::IntervalSet *expecting = getExpectedTokens(recognizer);
std::wstring msg = std::wstring(L"missing ") + expecting->toString(recognizer->getTokenNames()) + std::wstring(L" at ") + getTokenErrorDisplay(t);
recognizer->notifyErrorListeners(t, msg, nullptr);
}
Token *DefaultErrorStrategy::recoverInline(Parser *recognizer) {
// SINGLE TOKEN DELETION
Token *matchedSymbol = singleTokenDeletion(recognizer);
if (matchedSymbol != nullptr) {
// we have deleted the extra token.
// now, move past ttype token as if all were ok
recognizer->consume();
return matchedSymbol;
}
// SINGLE TOKEN INSERTION
if (singleTokenInsertion(recognizer)) {
return getMissingSymbol(recognizer);
}
// even that didn't work; must throw the exception
throw InputMismatchException(recognizer);
}
bool DefaultErrorStrategy::singleTokenInsertion(Parser *recognizer) {
int currentSymbolType = recognizer->getInputStream()->LA(1);
// if current token is consistent with what could come after current
// ATN state, then we know we're missing a token; error recovery
// is free to conjure up and insert the missing token
atn::ATNState *currentState = recognizer->getInterpreter()->atn->states[recognizer->getState()];
atn::ATNState *next = currentState->transition(0)->target;
atn::ATN *atn = recognizer->getInterpreter()->atn;
misc::IntervalSet *expectingAtLL2 = atn->nextTokens(next, recognizer->_ctx);
// System.out.println("LT(2) set="+expectingAtLL2.toString(recognizer.getTokenNames()));
if (expectingAtLL2->contains(currentSymbolType)) {
reportMissingToken(recognizer);
return true;
}
return false;
}
Token *DefaultErrorStrategy::singleTokenDeletion(Parser *recognizer) {
int nextTokenType = recognizer->getInputStream()->LA(2);
misc::IntervalSet *expecting = getExpectedTokens(recognizer);
if (expecting->contains(nextTokenType)) {
reportUnwantedToken(recognizer);
/*
System.err.println("recoverFromMismatchedToken deleting "+
((TokenStream)recognizer.getInputStream()).LT(1)+
" since "+((TokenStream)recognizer.getInputStream()).LT(2)+
" is what we want");
*/
recognizer->consume(); // simply delete extra token
// we want to return the token we're actually matching
Token *matchedSymbol = recognizer->getCurrentToken();
reportMatch(recognizer); // we know current token is correct
return matchedSymbol;
}
return nullptr;
}
Token *DefaultErrorStrategy::getMissingSymbol(Parser *recognizer) {
Token *currentSymbol = recognizer->getCurrentToken();
misc::IntervalSet *expecting = getExpectedTokens(recognizer);
int expectedTokenType = expecting->getMinElement(); // get any element
std::wstring tokenText;
if (expectedTokenType == Token::_EOF) {
tokenText = L"<missing EOF>";
} else {
tokenText = std::wstring(L"<missing ") + recognizer->getTokenNames()[expectedTokenType].at(expectedTokenType) + std::wstring(L">");
}
Token *current = currentSymbol;
Token *lookback = recognizer->getInputStream()->LT(-1);
if (current->getType() == Token::_EOF && lookback != nullptr) {
current = lookback;
}
return (Token*)recognizer->getTokenFactory()->create(new std::pair<TokenSource*, CharStream*>(current->getTokenSource(), current->getTokenSource()->getInputStream()), expectedTokenType, tokenText, Token::DEFAULT_CHANNEL, -1, -1, current->getLine(), current->getCharPositionInLine());
}
misc::IntervalSet *DefaultErrorStrategy::getExpectedTokens(Parser *recognizer) {
return recognizer->getExpectedTokens();
}
std::wstring DefaultErrorStrategy::getTokenErrorDisplay(Token *t) {
if (t == nullptr) {
return L"<no token>";
}
std::wstring s = getSymbolText(t);
if (s == L"") {
if (getSymbolType(t) == Token::_EOF) {
s = L"<EOF>";
} else {
s = std::wstring(L"<") + std::to_wstring(getSymbolType(t)) + std::wstring(L">");
}
}
return escapeWSAndQuote(s);
}
std::wstring DefaultErrorStrategy::getSymbolText(Token *symbol) {
return symbol->getText();
}
int DefaultErrorStrategy::getSymbolType(Token *symbol) {
return symbol->getType();
}
std::wstring DefaultErrorStrategy::escapeWSAndQuote(std::wstring &s) {
// if ( s==null ) return s;
antlrcpp::replaceAll(s, L"\n", L"\\n");
antlrcpp::replaceAll(s, L"\r",L"\\r");
antlrcpp::replaceAll(s, L"\t",L"\\t");
return std::wstring(L"'") + s + std::wstring(L"'");
}
misc::IntervalSet *DefaultErrorStrategy::getErrorRecoverySet(Parser *recognizer) {
atn::ATN *atn = recognizer->getInterpreter()->atn;
RuleContext *ctx = recognizer->_ctx;
misc::IntervalSet *recoverSet = new misc::IntervalSet(0);
while (ctx != nullptr && ctx->invokingState >= 0) {
// compute what follows who invoked us
atn::ATNState *invokingState = atn->states[ctx->invokingState];
atn::RuleTransition *rt = dynamic_cast<atn::RuleTransition*>(invokingState->transition(0));
misc::IntervalSet *follow = atn->nextTokens(rt->followState);
recoverSet->addAll(follow);
ctx = ctx->parent;
}
recoverSet->remove(Token::EPSILON);
// System.out.println("recover set "+recoverSet.toString(recognizer.getTokenNames()));
return recoverSet;
}
void DefaultErrorStrategy::consumeUntil(Parser *recognizer, misc::IntervalSet *set) {
// System.err.println("consumeUntil("+set.toString(recognizer.getTokenNames())+")");
int ttype = recognizer->getInputStream()->LA(1);
while (ttype != Token::_EOF && !set->contains(ttype)) {
//System.out.println("consume during recover LA(1)="+getTokenNames()[input.LA(1)]);
// recognizer.getInputStream().consume();
recognizer->consume();
ttype = recognizer->getInputStream()->LA(1);
}
}
void DefaultErrorStrategy::InitializeInstanceFields() {
errorRecoveryMode = false;
lastErrorIndex = -1;
}
}
}
}
}

View File

@ -1,496 +0,0 @@
#pragma once
#include "ANTLRErrorStrategy.h"
#include "Declarations.h"
#include <string>
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
/// <summary>
/// This is the default error handling mechanism for ANTLR parsers
/// and tree parsers.
/// </summary>
class DefaultErrorStrategy : public ANTLRErrorStrategy {
/// <summary>
/// This is true after we see an error and before having successfully
/// matched a token. Prevents generation of more than one error message
/// per error.
/// </summary>
/// <seealso cref= #inErrorRecoveryMode </seealso>
protected:
bool errorRecoveryMode;
/// <summary>
/// The index into the input stream where the last error occurred.
/// This is used to prevent infinite loops where an error is found
/// but no token is consumed during recovery...another error is found,
/// ad nauseum. This is a failsafe mechanism to guarantee that at least
/// one token/tree node is consumed for two errors.
/// </summary>
int lastErrorIndex;
misc::IntervalSet *lastErrorStates;
/// <summary>
/// {@inheritDoc}
/// <p/>
/// The default implementation simply calls <seealso cref="#endErrorCondition"/> to
/// ensure that the handler is not in error recovery mode.
/// </summary>
public:
virtual void reset(Parser *recognizer) override;
/// <summary>
/// This method is called to enter error recovery mode when a recognition
/// exception is reported.
/// </summary>
/// <param name="recognizer"> the parser instance </param>
protected:
virtual void beginErrorCondition(Parser *recognizer);
/// <summary>
/// {@inheritDoc}
/// </summary>
public:
virtual bool inErrorRecoveryMode(Parser *recognizer) override;
/// <summary>
/// This method is called to leave error recovery mode after recovering from
/// a recognition exception.
/// </summary>
/// <param name="recognizer"> </param>
protected:
virtual void endErrorCondition(Parser *recognizer);
/// <summary>
/// {@inheritDoc}
/// <p/>
/// The default implementation simply calls <seealso cref="#endErrorCondition"/>.
/// </summary>
public:
virtual void reportMatch(Parser *recognizer) override;
/// <summary>
/// {@inheritDoc}
/// <p/>
/// The default implementation returns immediately if the handler is already
/// in error recovery mode. Otherwise, it calls <seealso cref="#beginErrorCondition"/>
/// and dispatches the reporting task based on the runtime type of {@code e}
/// according to the following table.
///
/// <ul>
/// <li><seealso cref="NoViableAltException"/>: Dispatches the call to
/// <seealso cref="#reportNoViableAlternative"/></li>
/// <li><seealso cref="InputMismatchException"/>: Dispatches the call to
/// <seealso cref="#reportInputMismatch"/></li>
/// <li><seealso cref="FailedPredicateException"/>: Dispatches the call to
/// <seealso cref="#reportFailedPredicate"/></li>
/// <li>All other types: calls <seealso cref="Parser#notifyErrorListeners"/> to report
/// the exception</li>
/// </ul>
/// </summary>
virtual void reportError(Parser *recognizer, RecognitionException *e) override;
/// <summary>
/// {@inheritDoc}
/// <p/>
/// The default implementation resynchronizes the parser by consuming tokens
/// until we find one in the resynchronization set--loosely the set of tokens
/// that can follow the current rule.
/// </summary>
virtual void recover(Parser *recognizer, RecognitionException *e) override;
/// <summary>
/// The default implementation of <seealso cref="ANTLRErrorStrategy#sync"/> makes sure
/// that the current lookahead symbol is consistent with what were expecting
/// at this point in the ATN. You can call this anytime but ANTLR only
/// generates code to check before subrules/loops and each iteration.
/// <p/>
/// Implements Jim Idle's magic sync mechanism in closures and optional
/// subrules. E.g.,
///
/// <pre>
/// a : sync ( stuff sync )* ;
/// sync : {consume to what can follow sync} ;
/// </pre>
///
/// At the start of a sub rule upon error, <seealso cref="#sync"/> performs single
/// token deletion, if possible. If it can't do that, it bails on the current
/// rule and uses the default error recovery, which consumes until the
/// resynchronization set of the current rule.
/// <p/>
/// If the sub rule is optional ({@code (...)?}, {@code (...)*}, or block
/// with an empty alternative), then the expected set includes what follows
/// the subrule.
/// <p/>
/// During loop iteration, it consumes until it sees a token that can start a
/// sub rule or what follows loop. Yes, that is pretty aggressive. We opt to
/// stay in the loop as long as possible.
/// <p/>
/// <strong>ORIGINS</strong>
/// <p/>
/// Previous versions of ANTLR did a poor job of their recovery within loops.
/// A single mismatch token or missing token would force the parser to bail
/// out of the entire rules surrounding the loop. So, for rule
///
/// <pre>
/// classDef : 'class' ID '{' member* '}'
/// </pre>
///
/// input with an extra token between members would force the parser to
/// consume until it found the next class definition rather than the next
/// member definition of the current class.
/// <p/>
/// This functionality cost a little bit of effort because the parser has to
/// compare token set at the start of the loop and at each iteration. If for
/// some reason speed is suffering for you, you can turn off this
/// functionality by simply overriding this method as a blank { }.
/// </summary>
virtual void sync(Parser *recognizer) override;
/// <summary>
/// This is called by <seealso cref="#reportError"/> when the exception is a
/// <seealso cref="NoViableAltException"/>.
/// </summary>
/// <seealso cref= #reportError
/// </seealso>
/// <param name="recognizer"> the parser instance </param>
/// <param name="e"> the recognition exception </param>
protected:
virtual void reportNoViableAlternative(Parser *recognizer, NoViableAltException *e);
/// <summary>
/// This is called by <seealso cref="#reportError"/> when the exception is an
/// <seealso cref="InputMismatchException"/>.
/// </summary>
/// <seealso cref= #reportError
/// </seealso>
/// <param name="recognizer"> the parser instance </param>
/// <param name="e"> the recognition exception </param>
virtual void reportInputMismatch(Parser *recognizer, InputMismatchException *e);
/// <summary>
/// This is called by <seealso cref="#reportError"/> when the exception is a
/// <seealso cref="FailedPredicateException"/>.
/// </summary>
/// <seealso cref= #reportError
/// </seealso>
/// <param name="recognizer"> the parser instance </param>
/// <param name="e"> the recognition exception </param>
virtual void reportFailedPredicate(Parser *recognizer, FailedPredicateException *e);
/// <summary>
/// This method is called to report a syntax error which requires the removal
/// of a token from the input stream. At the time this method is called, the
/// erroneous symbol is current {@code LT(1)} symbol and has not yet been
/// removed from the input stream. When this method returns,
/// {@code recognizer} is in error recovery mode.
/// <p/>
/// This method is called when <seealso cref="#singleTokenDeletion"/> identifies
/// single-token deletion as a viable recovery strategy for a mismatched
/// input error.
/// <p/>
/// The default implementation simply returns if the handler is already in
/// error recovery mode. Otherwise, it calls <seealso cref="#beginErrorCondition"/> to
/// enter error recovery mode, followed by calling
/// <seealso cref="Parser#notifyErrorListeners"/>.
/// </summary>
/// <param name="recognizer"> the parser instance </param>
virtual void reportUnwantedToken(Parser *recognizer);
/// <summary>
/// This method is called to report a syntax error which requires the
/// insertion of a missing token into the input stream. At the time this
/// method is called, the missing token has not yet been inserted. When this
/// method returns, {@code recognizer} is in error recovery mode.
/// <p/>
/// This method is called when <seealso cref="#singleTokenInsertion"/> identifies
/// single-token insertion as a viable recovery strategy for a mismatched
/// input error.
/// <p/>
/// The default implementation simply returns if the handler is already in
/// error recovery mode. Otherwise, it calls <seealso cref="#beginErrorCondition"/> to
/// enter error recovery mode, followed by calling
/// <seealso cref="Parser#notifyErrorListeners"/>.
/// </summary>
/// <param name="recognizer"> the parser instance </param>
virtual void reportMissingToken(Parser *recognizer);
/// <summary>
/// {@inheritDoc}
/// <p/>
/// The default implementation attempts to recover from the mismatched input
/// by using single token insertion and deletion as described below. If the
/// recovery attempt fails, this method throws an
/// <seealso cref="InputMismatchException"/>.
/// <p/>
/// <strong>EXTRA TOKEN</strong> (single token deletion)
/// <p/>
/// {@code LA(1)} is not what we are looking for. If {@code LA(2)} has the
/// right token, however, then assume {@code LA(1)} is some extra spurious
/// token and delete it. Then consume and return the next token (which was
/// the {@code LA(2)} token) as the successful result of the match operation.
/// <p/>
/// This recovery strategy is implemented by <seealso cref="#singleTokenDeletion"/>.
/// <p/>
/// <strong>MISSING TOKEN</strong> (single token insertion)
/// <p/>
/// If current token (at {@code LA(1)}) is consistent with what could come
/// after the expected {@code LA(1)} token, then assume the token is missing
/// and use the parser's <seealso cref="TokenFactory"/> to create it on the fly. The
/// "insertion" is performed by returning the created token as the successful
/// result of the match operation.
/// <p/>
/// This recovery strategy is implemented by <seealso cref="#singleTokenInsertion"/>.
/// <p/>
/// <strong>EXAMPLE</strong>
/// <p/>
/// For example, Input {@code i=(3;} is clearly missing the {@code ')'}. When
/// the parser returns from the nested call to {@code expr}, it will have
/// call chain:
///
/// <pre>
/// stat -> expr -> atom
/// </pre>
///
/// and it will be trying to match the {@code ')'} at this point in the
/// derivation:
///
/// <pre>
/// => ID '=' '(' INT ')' ('+' atom)* ';'
/// ^
/// </pre>
///
/// The attempt to match {@code ')'} will fail when it sees {@code ';'} and
/// call <seealso cref="#recoverInline"/>. To recover, it sees that {@code LA(1)==';'}
/// is in the set of tokens that can follow the {@code ')'} token reference
/// in rule {@code atom}. It can assume that you forgot the {@code ')'}.
/// </summary>
public:
virtual Token *recoverInline(Parser *recognizer) override;
/// <summary>
/// This method implements the single-token insertion inline error recovery
/// strategy. It is called by <seealso cref="#recoverInline"/> if the single-token
/// deletion strategy fails to recover from the mismatched input. If this
/// method returns {@code true}, {@code recognizer} will be in error recovery
/// mode.
/// <p/>
/// This method determines whether or not single-token insertion is viable by
/// checking if the {@code LA(1)} input symbol could be successfully matched
/// if it were instead the {@code LA(2)} symbol. If this method returns
/// {@code true}, the caller is responsible for creating and inserting a
/// token with the correct type to produce this behavior.
/// </summary>
/// <param name="recognizer"> the parser instance </param>
/// <returns> {@code true} if single-token insertion is a viable recovery
/// strategy for the current mismatched input, otherwise {@code false} </returns>
protected:
virtual bool singleTokenInsertion(Parser *recognizer);
/// <summary>
/// This method implements the single-token deletion inline error recovery
/// strategy. It is called by <seealso cref="#recoverInline"/> to attempt to recover
/// from mismatched input. If this method returns null, the parser and error
/// handler state will not have changed. If this method returns non-null,
/// {@code recognizer} will <em>not</em> be in error recovery mode since the
/// returned token was a successful match.
/// <p/>
/// If the single-token deletion is successful, this method calls
/// <seealso cref="#reportUnwantedToken"/> to report the error, followed by
/// <seealso cref="Parser#consume"/> to actually "delete" the extraneous token. Then,
/// before returning <seealso cref="#reportMatch"/> is called to signal a successful
/// match.
/// </summary>
/// <param name="recognizer"> the parser instance </param>
/// <returns> the successfully matched <seealso cref="Token"/> instance if single-token
/// deletion successfully recovers from the mismatched input, otherwise
/// {@code null} </returns>
virtual Token *singleTokenDeletion(Parser *recognizer);
/// <summary>
/// Conjure up a missing token during error recovery.
///
/// The recognizer attempts to recover from single missing
/// symbols. But, actions might refer to that missing symbol.
/// For example, x=ID {f($x);}. The action clearly assumes
/// that there has been an identifier matched previously and that
/// $x points at that token. If that token is missing, but
/// the next token in the stream is what we want we assume that
/// this token is missing and we keep going. Because we
/// have to return some token to replace the missing token,
/// we have to conjure one up. This method gives the user control
/// over the tokens returned for missing tokens. Mostly,
/// you will want to create something special for identifier
/// tokens. For literals such as '{' and ',', the default
/// action in the parser or tree parser works. It simply creates
/// a CommonToken of the appropriate type. The text will be the token.
/// If you change what tokens must be created by the lexer,
/// override this method to create the appropriate tokens.
/// </summary>
virtual Token *getMissingSymbol(Parser *recognizer);
virtual misc::IntervalSet *getExpectedTokens(Parser *recognizer);
/// <summary>
/// How should a token be displayed in an error message? The default
/// is to display just the text, but during development you might
/// want to have a lot of information spit out. Override in that case
/// to use t.toString() (which, for CommonToken, dumps everything about
/// the token). This is better than forcing you to override a method in
/// your token objects because you don't have to go modify your lexer
/// so that it creates a new Java type.
/// </summary>
virtual std::wstring getTokenErrorDisplay(Token *t);
virtual std::wstring getSymbolText(Token *symbol);
virtual int getSymbolType(Token *symbol);
virtual std::wstring escapeWSAndQuote(std::wstring &s);
/* Compute the error recovery set for the current rule. During
* rule invocation, the parser pushes the set of tokens that can
* follow that rule reference on the stack; this amounts to
* computing FIRST of what follows the rule reference in the
* enclosing rule. See LinearApproximator.FIRST().
* This local follow set only includes tokens
* from within the rule; i.e., the FIRST computation done by
* ANTLR stops at the end of a rule.
*
* EXAMPLE
*
* When you find a "no viable alt exception", the input is not
* consistent with any of the alternatives for rule r. The best
* thing to do is to consume tokens until you see something that
* can legally follow a call to r *or* any rule that called r.
* You don't want the exact set of viable next tokens because the
* input might just be missing a token--you might consume the
* rest of the input looking for one of the missing tokens.
*
* Consider grammar:
*
* a : '[' b ']'
* | '(' b ')'
* ;
* b : c '^' INT ;
* c : ID
* | INT
* ;
*
* At each rule invocation, the set of tokens that could follow
* that rule is pushed on a stack. Here are the various
* context-sensitive follow sets:
*
* FOLLOW(b1_in_a) = FIRST(']') = ']'
* FOLLOW(b2_in_a) = FIRST(')') = ')'
* FOLLOW(c_in_b) = FIRST('^') = '^'
*
* Upon erroneous input "[]", the call chain is
*
* a -> b -> c
*
* and, hence, the follow context stack is:
*
* depth follow set start of rule execution
* 0 <EOF> a (from main())
* 1 ']' b
* 2 '^' c
*
* Notice that ')' is not included, because b would have to have
* been called from a different context in rule a for ')' to be
* included.
*
* For error recovery, we cannot consider FOLLOW(c)
* (context-sensitive or otherwise). We need the combined set of
* all context-sensitive FOLLOW sets--the set of all tokens that
* could follow any reference in the call chain. We need to
* resync to one of those tokens. Note that FOLLOW(c)='^' and if
* we resync'd to that token, we'd consume until EOF. We need to
* sync to context-sensitive FOLLOWs for a, b, and c: {']','^'}.
* In this case, for input "[]", LA(1) is ']' and in the set, so we would
* not consume anything. After printing an error, rule c would
* return normally. Rule b would not find the required '^' though.
* At this point, it gets a mismatched token error and throws an
* exception (since LA(1) is not in the viable following token
* set). The rule exception handler tries to recover, but finds
* the same recovery set and doesn't consume anything. Rule b
* exits normally returning to rule a. Now it finds the ']' (and
* with the successful match exits errorRecovery mode).
*
* So, you can see that the parser walks up the call chain looking
* for the token that was a member of the recovery set.
*
* Errors are not generated in errorRecovery mode.
*
* ANTLR's error recovery mechanism is based upon original ideas:
*
* "Algorithms + Data Structures = Programs" by Niklaus Wirth
*
* and
*
* "A note on error recovery in recursive descent parsers":
* http://portal.acm.org/citation.cfm?id=947902.947905
*
* Later, Josef Grosch had some good ideas:
*
* "Efficient and Comfortable Error Recovery in Recursive Descent
* Parsers":
* ftp://www.cocolab.com/products/cocktail/doca4.ps/ell.ps.zip
*
* Like Grosch I implement context-sensitive FOLLOW sets that are combined
* at run-time upon error to avoid overhead during parsing.
*/
virtual misc::IntervalSet *getErrorRecoverySet(Parser *recognizer);
/// <summary>
/// Consume tokens until one matches the given token set. </summary>
virtual void consumeUntil(Parser *recognizer, misc::IntervalSet *set);
private:
void InitializeInstanceFields();
public:
DefaultErrorStrategy() {
InitializeInstanceFields();
}
};
}
}
}
}

View File

@ -1,116 +0,0 @@
#include "DiagnosticErrorListener.h"
#include "ATNConfig.h"
#include "ATNConfigSet.h"
#include "Parser.h"
#include "Interval.h"
#include "DFA.h"
#include "DecisionState.h"
#include "stdio.h"
#include "StringBuilder.h"
#include "ATNState.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
//JAVA TO C++ CONVERTER TODO TASK: Calls to same-class constructors are not supported in C++ prior to C++11:
DiagnosticErrorListener::DiagnosticErrorListener() : exactOnly(true) {
}
DiagnosticErrorListener::DiagnosticErrorListener(bool exactOnly) : exactOnly(exactOnly) {
}
void DiagnosticErrorListener::reportAmbiguity(Parser *recognizer, dfa::DFA *dfa, int startIndex, int stopIndex, bool exact, antlrcpp::BitSet *ambigAlts, atn::ATNConfigSet *configs) {
if (exactOnly && !exact) {
return;
}
wchar_t buf[16];
std::wstring decision = getDecisionDescription(recognizer, dfa);
antlrcpp::BitSet *conflictingAlts = getConflictingAlts(ambigAlts, configs);
std::wstring text = recognizer->getTokenStream()->getText(misc::Interval::of(startIndex, stopIndex));
std::wstring message = L"reportAmbiguity d=" + decision + L": ambigAlts=" + conflictingAlts->toString() + L", input='" + text + L"'";
swprintf(buf, sizeof(buf) / sizeof(*buf), L"%d", 5);
recognizer->notifyErrorListeners(message);
}
void DiagnosticErrorListener::reportAttemptingFullContext(Parser *recognizer, dfa::DFA *dfa, int startIndex, int stopIndex, antlrcpp::BitSet *conflictingAlts, atn::ATNConfigSet *configs) {
std::wstring decision = getDecisionDescription(recognizer, dfa);
std::wstring text = recognizer->getTokenStream()->getText(misc::Interval::of(startIndex, stopIndex));
std::wstring message = L"reportAttemptingFullContext d=" + decision + L", input='" + text + L"'";
recognizer->notifyErrorListeners(message);
}
void DiagnosticErrorListener::reportContextSensitivity(Parser *recognizer, dfa::DFA *dfa, int startIndex, int stopIndex, int prediction, atn::ATNConfigSet *configs) {
std::wstring decision = getDecisionDescription(recognizer, dfa);
std::wstring text = recognizer->getTokenStream()->getText(misc::Interval::of(startIndex, stopIndex));
std::wstring message = L"reportContextSensitivity d=" + decision + L", input='" + text + L"'";
recognizer->notifyErrorListeners(message);
}
std::wstring DiagnosticErrorListener::getDecisionDescription(Parser *recognizer, dfa::DFA *dfa) {
int decision = dfa->decision;
int ruleIndex = ((atn::ATNState*)dfa->atnStartState)->ruleIndex;
const std::vector<std::wstring>& ruleNames = recognizer->getRuleNames();
if (ruleIndex < 0 || ruleIndex >= (int)ruleNames.size()) {
return antlrcpp::StringConverterHelper::toString(decision);
}
std::wstring ruleName = ruleNames[ruleIndex];
if (ruleName == L"" || ruleName.empty()) {
return antlrcpp::StringConverterHelper::toString(decision);
}
return std::to_wstring(decision) + L"(" + ruleName + L")";
}
antlrcpp::BitSet *DiagnosticErrorListener::getConflictingAlts(antlrcpp::BitSet *reportedAlts, atn::ATNConfigSet *configs) {
if (reportedAlts != nullptr) {
return reportedAlts;
}
antlrcpp::BitSet *result = new antlrcpp::BitSet();
for (size_t i = 0; i < configs->size(); i++) {
atn::ATNConfig *config = configs->get((int)i);
result->set(config->alt);
}
return result;
}
}
}
}
}

View File

@ -1,114 +0,0 @@
#pragma once
#include <string>
#include "stringconverter.h"
#include "Declarations.h"
#include "BaseErrorListener.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
/// <summary>
/// This implementation of <seealso cref="ANTLRErrorListener"/> can be used to identify
/// certain potential correctness and performance problems in grammars. "Reports"
/// are made by calling <seealso cref="Parser#notifyErrorListeners"/> with the appropriate
/// message.
///
/// <ul>
/// <li><b>Ambiguities</b>: These are cases where more than one path through the
/// grammar can match the input.</li>
/// <li><b>Weak context sensitivity</b>: These are cases where full-context
/// prediction resolved an SLL conflict to a unique alternative which equaled the
/// minimum alternative of the SLL conflict.</li>
/// <li><b>Strong (forced) context sensitivity</b>: These are cases where the
/// full-context prediction resolved an SLL conflict to a unique alternative,
/// <em>and</em> the minimum alternative of the SLL conflict was found to not be
/// a truly viable alternative. Two-stage parsing cannot be used for inputs where
/// this situation occurs.</li>
/// </ul>
///
/// @author Sam Harwell
/// </summary>
class DiagnosticErrorListener : public BaseErrorListener {
/// <summary>
/// When {@code true}, only exactly known ambiguities are reported.
/// </summary>
protected:
const bool exactOnly;
/// <summary>
/// Initializes a new instance of <seealso cref="DiagnosticErrorListener"/> which only
/// reports exact ambiguities.
/// </summary>
public:
DiagnosticErrorListener(); //this(true);
/// <summary>
/// Initializes a new instance of <seealso cref="DiagnosticErrorListener"/>, specifying
/// whether all ambiguities or only exact ambiguities are reported.
/// </summary>
/// <param name="exactOnly"> {@code true} to report only exact ambiguities, otherwise
/// {@code false} to report all ambiguities. </param>
DiagnosticErrorListener(bool exactOnly);
virtual void reportAmbiguity(Parser *recognizer, dfa::DFA *dfa, int startIndex, int stopIndex, bool exact, antlrcpp::BitSet *ambigAlts, atn::ATNConfigSet *configs) override;
virtual void reportAttemptingFullContext(Parser *recognizer, dfa::DFA *dfa, int startIndex, int stopIndex, antlrcpp::BitSet *conflictingAlts, atn::ATNConfigSet *configs) override;
virtual void reportContextSensitivity(Parser *recognizer, dfa::DFA *dfa, int startIndex, int stopIndex, int prediction, atn::ATNConfigSet *configs) override;
protected:
virtual std::wstring getDecisionDescription(Parser *recognizer, dfa::DFA *dfa);
/// <summary>
/// Computes the set of conflicting or ambiguous alternatives from a
/// configuration set, if that information was not already provided by the
/// parser.
/// </summary>
/// <param name="reportedAlts"> The set of conflicting or ambiguous alternatives, as
/// reported by the parser. </param>
/// <param name="configs"> The conflicting or ambiguous configuration set. </param>
/// <returns> Returns {@code reportedAlts} if it is not {@code null}, otherwise
/// returns the set of alternatives represented in {@code configs}. </returns>
virtual antlrcpp::BitSet *getConflictingAlts(antlrcpp::BitSet *reportedAlts, atn::ATNConfigSet *configs);
};
}
}
}
}

View File

@ -1,120 +0,0 @@
/*
* [The "BSD license"]
* Copyright (c) 2013 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.
*/
#pragma once
#include "Declarations.h"
#include <iostream>
#include <exception>
#include <string>
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
class ANTLRException : public std::exception {
private:
std::wstring errormsg;
public:
ANTLRException() {}
ANTLRException(const std::wstring msg) {
this->errormsg = msg;
}
std::wstring getMessage() {
return errormsg;
}
};
class IllegalClassException : public ANTLRException {
public:
IllegalClassException(const std::wstring msg) : ANTLRException(msg) {};
IllegalClassException() {};
};
class IllegalStateException : public ANTLRException {
public:
IllegalStateException(const std::wstring msg) : ANTLRException(msg) {};
IllegalStateException(){};
};
class IllegalArgumentException : public ANTLRException {
public:
IllegalArgumentException(const std::wstring msg) : ANTLRException(msg) {};
IllegalArgumentException(const std::wstring msg, std::exception e);
IllegalArgumentException(){};
};
class NoSuchElementException : public ANTLRException {
public:
NoSuchElementException(const std::wstring msg) : ANTLRException(msg) {};
NoSuchElementException(){};
};
class NullPointerException : public ANTLRException {
public:
NullPointerException(const std::wstring msg) : ANTLRException(msg) {};
NullPointerException(){};
};
class IndexOutOfBoundsException : public ANTLRException {
public:
IndexOutOfBoundsException(const std::wstring msg) : ANTLRException(msg) {};
IndexOutOfBoundsException(){};
};
class UnsupportedOperationException : public ANTLRException {
public:
UnsupportedOperationException(const std::wstring msg) : ANTLRException(msg) {};
UnsupportedOperationException(){};
};
class IOException : public ANTLRException {
public:
IOException(const std::wstring msg) : ANTLRException(msg) {};
IOException(){};
};
class TODOException : public ANTLRException {
public:
TODOException(const std::wstring msg) : ANTLRException(msg) {};
TODOException();
};
class ASSERTException : public ANTLRException {
public:
ASSERTException(const std::wstring location,
const std::wstring condition)
: ANTLRException(location + L" condition= " + condition) {};
ASSERTException();
};
}
}
}
}

View File

@ -1,89 +0,0 @@
#include "FailedPredicateException.h"
#include "ATNState.h"
#include "AbstractPredicateTransition.h"
#include "PredicateTransition.h"
#include "Parser.h"
#include "ParserATNSimulator.h"
#include "ATN.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
FailedPredicateException::FailedPredicateException(Parser *recognizer) : RecognitionException() {
}
FailedPredicateException::FailedPredicateException(Parser *recognizer, const std::wstring &predicate): RecognitionException() {
}
FailedPredicateException::FailedPredicateException(Parser *recognizer, const std::wstring &predicate, const std::wstring &message)
#ifdef TODO
// Huston, a problem. "trans" isn't defined until below
: RecognitionException(formatMessage(predicate, message), recognizer, recognizer->getInputStream(), recognizer->_ctx), ruleIndex((static_cast<atn::PredicateTransition*>(trans))->ruleIndex), predicateIndex((static_cast<atn::PredicateTransition*>(trans))->predIndex), predicate(predicate)
#endif
{
atn::ATNState *s = recognizer->getInterpreter()->atn->states[recognizer->getState()];
atn::AbstractPredicateTransition *trans = static_cast<atn::AbstractPredicateTransition*>(s->transition(0));
if (dynamic_cast<atn::PredicateTransition*>(trans) != nullptr) {
} else {
this->ruleIndex = 0;
this->predicateIndex = 0;
}
this->setOffendingToken(recognizer->getCurrentToken());
}
int FailedPredicateException::getRuleIndex() {
return ruleIndex;
}
int FailedPredicateException::getPredIndex() {
return predicateIndex;
}
std::wstring FailedPredicateException::getPredicate() {
return predicate;
}
std::wstring FailedPredicateException::formatMessage(const std::wstring &predicate, const std::wstring &message) {
if (message != L"") {
return message;
}
return L"failed predicate: " + predicate + L"?";
}
}
}
}
}

View File

@ -1,75 +0,0 @@
#pragma once
#include "RecognitionException.h"
#include "Declarations.h"
#include <string>
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
/// <summary>
/// A semantic predicate failed during validation. Validation of predicates
/// occurs when normally parsing the alternative just like matching a token.
/// Disambiguating predicate evaluation occurs when we test a predicate during
/// prediction.
/// </summary>
class FailedPredicateException : public RecognitionException {
private:
int ruleIndex;
int predicateIndex;
const std::wstring predicate;
public:
FailedPredicateException(Parser *recognizer); //this(recognizer, nullptr);
FailedPredicateException(Parser *recognizer, const std::wstring &predicate); //this(recognizer, predicate, nullptr);
FailedPredicateException(Parser *recognizer, const std::wstring &predicate, const std::wstring &message);
virtual int getRuleIndex();
virtual int getPredIndex();
virtual std::wstring getPredicate();
private:
static std::wstring formatMessage(const std::wstring &predicate, const std::wstring &message);
};
}
}
}
}

View File

@ -1,249 +0,0 @@
#pragma once
#include <string>
#include <ios>
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
/// <summary>
/// A simple stream of symbols whose values are represented as integers. This
/// interface provides <em>marked ranges</em> with support for a minimum level
/// of buffering necessary to implement arbitrary lookahead during prediction.
/// For more information on marked ranges, see <seealso cref="#mark"/>.
/// <p/>
/// <strong>Initializing Methods:</strong> Some methods in this interface have
/// unspecified behavior if no call to an initializing method has occurred after
/// the stream was constructed. The following is a list of initializing methods:
///
/// <ul>
/// <li><seealso cref="#LA"/></li>
/// <li><seealso cref="#consume"/></li>
/// <li><seealso cref="#size"/></li>
/// </ul>
/// </summary>
class IntStream {
/// <summary>
/// The value returned by <seealso cref="#LA LA()"/> when the end of the stream is
/// reached.
/// </summary>
public:
// EOF Conflict with OS X, change to _EOF
static const int _EOF = std::ios::eofbit;
/// <summary>
/// The value returned by <seealso cref="#getSourceName"/> when the actual name of the
/// underlying source is not known.
/// </summary>
static const std::wstring UNKNOWN_SOURCE_NAME;
/// <summary>
/// Consumes the current symbol in the stream. This method has the following
/// effects:
///
/// <ul>
/// <li><strong>Forward movement:</strong> The value of <seealso cref="#index index()"/>
/// before calling this method is less than the value of {@code index()}
/// after calling this method.</li>
/// <li><strong>Ordered lookahead:</strong> The value of {@code LA(1)} before
/// calling this method becomes the value of {@code LA(-1)} after calling
/// this method.</li>
/// </ul>
///
/// Note that calling this method does not guarantee that {@code index()} is
/// incremented by exactly 1, as that would preclude the ability to implement
/// filtering streams (e.g. <seealso cref="CommonTokenStream"/> which distinguishes
/// between "on-channel" and "off-channel" tokens).
/// </summary>
/// <exception cref="IllegalStateException"> if an attempt is made to consume the the
/// end of the stream (i.e. if {@code LA(1)==}<seealso cref="#EOF EOF"/> before calling
/// {@code consume}). </exception>
virtual void consume() = 0;
/// <summary>
/// Gets the value of the symbol at offset {@code i} from the current
/// position. When {@code i==1}, this method returns the value of the current
/// symbol in the stream (which is the next symbol to be consumed). When
/// {@code i==-1}, this method returns the value of the previously read
/// symbol in the stream. It is not valid to call this method with
/// {@code i==0}, but the specific behavior is unspecified because this
/// method is frequently called from performance-critical code.
/// <p/>
/// This method is guaranteed to succeed if any of the following are true:
///
/// <ul>
/// <li>{@code i>0}</li>
/// <li>{@code i==-1} and <seealso cref="#index index()"/> returns a value greater
/// than the value of {@code index()} after the stream was constructed
/// and {@code LA(1)} was called in that order. Specifying the current
/// {@code index()} relative to the index after the stream was created
/// allows for filtering implementations that do not return every symbol
/// from the underlying source. Specifying the call to {@code LA(1)}
/// allows for lazily initialized streams.</li>
/// <li>{@code LA(i)} refers to a symbol consumed within a marked region
/// that has not yet been released.</li>
/// </ul>
///
/// If {@code i} represents a position at or beyond the end of the stream,
/// this method returns <seealso cref="#EOF"/>.
/// <p/>
/// The return value is unspecified if {@code i<0} and fewer than {@code -i}
/// calls to <seealso cref="#consume consume()"/> have occurred from the beginning of
/// the stream before calling this method.
/// </summary>
/// <exception cref="UnsupportedOperationException"> if the stream does not support
/// retrieving the value of the specified symbol </exception>
virtual int LA(int i) = 0;
/// <summary>
/// A mark provides a guarantee that <seealso cref="#seek seek()"/> operations will be
/// valid over a "marked range" extending from the index where {@code mark()}
/// was called to the current <seealso cref="#index index()"/>. This allows the use of
/// streaming input sources by specifying the minimum buffering requirements
/// to support arbitrary lookahead during prediction.
/// <p/>
/// The returned mark is an opaque handle (type {@code int}) which is passed
/// to <seealso cref="#release release()"/> when the guarantees provided by the marked
/// range are no longer necessary. When calls to
/// {@code mark()}/{@code release()} are nested, the marks must be released
/// in reverse order of which they were obtained. Since marked regions are
/// used during performance-critical sections of prediction, the specific
/// behavior of invalid usage is unspecified (i.e. a mark is not released, or
/// a mark is released twice, or marks are not released in reverse order from
/// which they were created).
/// <p/>
/// The behavior of this method is unspecified if no call to an
/// <seealso cref="IntStream initializing method"/> has occurred after this stream was
/// constructed.
/// <p/>
/// This method does not change the current position in the input stream.
/// <p/>
/// The following example shows the use of <seealso cref="#mark mark()"/>,
/// <seealso cref="#release release(mark)"/>, <seealso cref="#index index()"/>, and
/// <seealso cref="#seek seek(index)"/> as part of an operation to safely work within a
/// marked region, then restore the stream position to its original value and
/// release the mark.
/// <pre>
/// IntStream stream = ...;
/// int index = -1;
/// int mark = stream.mark();
/// try {
/// index = stream.index();
/// // perform work here...
/// } finally {
/// if (index != -1) {
/// stream.seek(index);
/// }
/// stream.release(mark);
/// }
/// </pre>
/// </summary>
/// <returns> An opaque marker which should be passed to
/// <seealso cref="#release release()"/> when the marked range is no longer required. </returns>
virtual int mark() = 0;
/// <summary>
/// This method releases a marked range created by a call to
/// <seealso cref="#mark mark()"/>. Calls to {@code release()} must appear in the
/// reverse order of the corresponding calls to {@code mark()}. If a mark is
/// released twice, or if marks are not released in reverse order of the
/// corresponding calls to {@code mark()}, the behavior is unspecified.
/// <p/>
/// For more information and an example, see <seealso cref="#mark"/>.
/// </summary>
/// <param name="marker"> A marker returned by a call to {@code mark()}. </param>
/// <seealso cref= #mark </seealso>
virtual void release(int marker) = 0;
/// <summary>
/// Return the index into the stream of the input symbol referred to by
/// {@code LA(1)}.
/// <p/>
/// The behavior of this method is unspecified if no call to an
/// <seealso cref="IntStream initializing method"/> has occurred after this stream was
/// constructed.
/// </summary>
virtual int index() = 0;
/// <summary>
/// Set the input cursor to the position indicated by {@code index}. If the
/// specified index lies past the end of the stream, the operation behaves as
/// though {@code index} was the index of the EOF symbol. After this method
/// returns without throwing an exception, the at least one of the following
/// will be true.
///
/// <ul>
/// <li><seealso cref="#index index()"/> will return the index of the first symbol
/// appearing at or after the specified {@code index}. Specifically,
/// implementations which filter their sources should automatically
/// adjust {@code index} forward the minimum amount required for the
/// operation to target a non-ignored symbol.</li>
/// <li>{@code LA(1)} returns <seealso cref="#EOF"/></li>
/// </ul>
///
/// This operation is guaranteed to not throw an exception if {@code index}
/// lies within a marked region. For more information on marked regions, see
/// <seealso cref="#mark"/>. The behavior of this method is unspecified if no call to
/// an <seealso cref="IntStream initializing method"/> has occurred after this stream
/// was constructed.
/// </summary>
/// <param name="index"> The absolute index to seek to.
/// </param>
/// <exception cref="IllegalArgumentException"> if {@code index} is less than 0 </exception>
/// <exception cref="UnsupportedOperationException"> if the stream does not support
/// seeking to the specified index </exception>
virtual void seek(int index) = 0;
/// <summary>
/// Returns the total number of symbols in the stream, including a single EOF
/// symbol.
/// </summary>
/// <exception cref="UnsupportedOperationException"> if the size of the stream is
/// unknown. </exception>
virtual size_t size() = 0;
/// <summary>
/// Gets the name of the underlying symbol source. This method returns a
/// non-null, non-empty string. If such a name is not known, this method
/// returns <seealso cref="#UNKNOWN_SOURCE_NAME"/>.
/// </summary>
virtual std::string getSourceName() = 0;
};
}
}
}
}

View File

@ -1,365 +0,0 @@
#include "Lexer.h"
#include "LexerATNSimulator.h"
#include "Exceptions.h"
#include "ANTLRErrorListener.h"
#include "Interval.h"
#include "StringBuilder.h"
#include "CommonTokenFactory.h"
#include "LexerNoViableAltException.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
Lexer::Lexer() {
InitializeInstanceFields();
}
Lexer::Lexer(CharStream *input) {
InitializeInstanceFields();
this->_input = input;
this->_tokenFactorySourcePair = new std::pair<TokenSource*, CharStream*>(this, input);
}
void Lexer::reset() {
// wack Lexer state variables
if (_input != nullptr) {
_input->seek(0); // rewind the input
}
delete _token;
_type = Token::INVALID_TYPE;
_channel = Token::DEFAULT_CHANNEL;
_tokenStartCharIndex = -1;
_tokenStartCharPositionInLine = -1;
_tokenStartLine = -1;
_text = L"";
_hitEOF = false;
_mode = Lexer::DEFAULT_MODE;
_modeStack.clear();
getInterpreter()->reset();
}
Token *Lexer::nextToken() {
if (_input == nullptr) {
throw new IllegalStateException(L"nextToken requires a non-null input stream.");
}
// Mark start location in char stream so unbuffered streams are
// guaranteed at least have text of current token
int tokenStartMarker = _input->mark();
try {
while (true) {
outerContinue:
if (_hitEOF) {
emitEOF();
return _token;
}
delete _token;
_channel = Token::DEFAULT_CHANNEL;
_tokenStartCharIndex = _input->index();
_tokenStartCharPositionInLine = getInterpreter()->getCharPositionInLine();
_tokenStartLine = getInterpreter()->getLine();
_text = L"";
do {
_type = Token::INVALID_TYPE;
// System.out.println("nextToken line "+tokenStartLine+" at "+((char)input.LA(1))+
// " in mode "+mode+
// " at index "+input.index());
int ttype;
try {
ttype = getInterpreter()->match(_input, _mode);
} catch (LexerNoViableAltException *e) {
notifyListeners(e); // report error
recover(e);
ttype = SKIP;
}
if (_input->LA(1) == IntStream::_EOF) {
_hitEOF = true;
}
if (_type == Token::INVALID_TYPE) {
_type = ttype;
}
if (_type == SKIP) {
goto outerContinue;
}
} while (_type == MORE);
if (_token == nullptr) {
emit();
}
return _token;
}
}
catch(...) {
#ifdef TODO
// Do something intelligent here for once
#endif
}
// make sure we release marker after match or
// unbuffered char stream will keep buffering
_input->release(tokenStartMarker);
return nullptr;
}
void Lexer::skip() {
_type = SKIP;
}
void Lexer::more() {
_type = MORE;
}
void Lexer::mode(int m) {
_mode = m;
}
void Lexer::pushMode(int m) {
if (atn::LexerATNSimulator::debug) {
std::wcout << std::wstring(L"pushMode ") << m << std::endl;
}
_modeStack.push_back(_mode);
mode(m);
}
int Lexer::popMode() {
if (_modeStack.empty()) {
throw EmptyStackException();
}
if (atn::LexerATNSimulator::debug) {
std::wcout << std::wstring(L"popMode back to ") << _modeStack.back() << std::endl;
}
mode(_modeStack.back());
_modeStack.pop_back();
return _mode;
}
TokenFactory<CommonToken*> *Lexer::getTokenFactory() {
return _factory;
}
void Lexer::setInputStream(IntStream *input) {
delete this->_input;
this->_tokenFactorySourcePair = new std::pair<TokenSource*, CharStream*>(this, _input);
reset();
this->_input = static_cast<CharStream*>(input);
this->_tokenFactorySourcePair = new std::pair<TokenSource*, CharStream*>(this, _input);
}
std::string Lexer::getSourceName() {
return _input->getSourceName();
}
CharStream *Lexer::getInputStream() {
return _input;
}
void Lexer::emit(Token *token) {
//System.err.println("emit "+token);
this->_token = token;
}
Token *Lexer::emit() {
Token *t = (Token*)_factory->create(_tokenFactorySourcePair, _type, _text, _channel, _tokenStartCharIndex, getCharIndex() - 1, _tokenStartLine, _tokenStartCharPositionInLine);
emit(t);
return t;
}
Token *Lexer::emitEOF() {
int cpos = getCharPositionInLine();
// The character position for EOF is one beyond the position of
// the previous token's last character
if (_token != nullptr) {
int n = _token->getStopIndex() - _token->getStartIndex() + 1;
cpos = _token->getCharPositionInLine() + n;
}
Token *eof = (Token*)_factory->create(_tokenFactorySourcePair, Token::_EOF, L"", Token::DEFAULT_CHANNEL, _input->index(), _input->index() - 1, getLine(), cpos);
emit(eof);
return eof;
}
int Lexer::getLine() {
return getInterpreter()->getLine();
}
int Lexer::getCharPositionInLine() {
return getInterpreter()->getCharPositionInLine();
}
void Lexer::setLine(int line) {
getInterpreter()->setLine(line);
}
void Lexer::setCharPositionInLine(int charPositionInLine) {
getInterpreter()->setCharPositionInLine(charPositionInLine);
}
int Lexer::getCharIndex() {
return _input->index();
}
std::wstring Lexer::getText() {
if (_text != L"") {
return _text;
}
return getInterpreter()->getText(_input);
}
void Lexer::setText(const std::wstring &text) {
this->_text = text;
}
Token *Lexer::getToken() {
return _token;
}
void Lexer::setToken(Token *_token) {
this->_token = _token;
}
void Lexer::setType(int ttype) {
_type = ttype;
}
int Lexer::getType() {
return _type;
}
void Lexer::setChannel(int channel) {
_channel = channel;
}
int Lexer::getChannel() {
return _channel;
}
const std::vector<std::wstring>& Lexer::getModeNames() {
return _modeNames;
}
const std::vector<std::wstring>& Lexer::getTokenNames() {
return _tokenNames;
}
std::vector<Token*> Lexer::getAllTokens() {
std::vector<Token*> tokens = std::vector<Token*>();
Token *t = nextToken();
while (t->getType() != Token::_EOF) {
tokens.push_back(t);
t = nextToken();
}
return tokens;
}
void Lexer::recover(LexerNoViableAltException *e) {
if (_input->LA(1) != IntStream::_EOF) {
// skip a char and try again
getInterpreter()->consume(_input);
}
}
void Lexer::notifyListeners(LexerNoViableAltException *e) {
std::wstring text = _input->getText(misc::Interval::of(_tokenStartCharIndex, _input->index()));
std::wstring msg = std::wstring(L"token recognition error at: '") + getErrorDisplay(text) + std::wstring(L"'");
ANTLRErrorListener *listener = getErrorListenerDispatch();
listener->syntaxError(this, nullptr, _tokenStartLine, _tokenStartCharPositionInLine, msg, e);
}
std::wstring Lexer::getErrorDisplay(const std::wstring &s) {
antlrcpp::StringBuilder *buf = new antlrcpp::StringBuilder();
for (size_t i = 0; i < s.length(); i++) {
char c = ((char*)s.c_str())[i];
buf->append(getErrorDisplay(c));
}
/*
for (auto c : s.toCharArray()) {
buf->append(getErrorDisplay(c));
}*/
return buf->toString();
}
std::wstring Lexer::getErrorDisplay(int c) {
std::wstring s = antlrcpp::StringConverterHelper::toString(static_cast<wchar_t>(c));
switch (c) {
case Token::_EOF :
s = L"<EOF>";
break;
case L'\n' :
s = L"\\n";
break;
case L'\t' :
s = L"\\t";
break;
case L'\r' :
s = L"\\r";
break;
}
return s;
}
std::wstring Lexer::getCharErrorDisplay(int c) {
std::wstring s = getErrorDisplay(c);
return std::wstring(L"'") + s + std::wstring(L"'");
}
void Lexer::recover(RecognitionException *re) {
//System.out.println("consuming char "+(char)input.LA(1)+" during recovery");
//re.printStackTrace();
// TODO: Do we lose character or line position information?
_input->consume();
}
void Lexer::InitializeInstanceFields() {
_factory = CommonTokenFactory::DEFAULT;
_tokenStartCharIndex = -1;
_tokenStartLine = 0;
_tokenStartCharPositionInLine = 0;
_hitEOF = false;
_channel = 0;
_type = 0;
_mode = Lexer::DEFAULT_MODE;
}
}
}
}
}

View File

@ -1,268 +0,0 @@
#pragma once
#include "Declarations.h"
#include "Recognizer.h"
#include "Token.h"
#include "TokenSource.h"
#include "stringconverter.h"
#include <iostream>
#include <string>
#include <utility>
#include <vector>
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
/// <summary>
/// A lexer is recognizer that draws input symbols from a character stream.
/// lexer grammars result in a subclass of this object. A Lexer object
/// uses simplified match() and error recovery mechanisms in the interest
/// of speed.
/// </summary>
class Lexer : public Recognizer<int, atn::LexerATNSimulator*>, public TokenSource {
public:
static const int DEFAULT_MODE = 0;
static const int MORE = -2;
static const int SKIP = -3;
static const int DEFAULT_TOKEN_CHANNEL = Token::DEFAULT_CHANNEL;
static const int HIDDEN = Token::HIDDEN_CHANNEL;
static const wchar_t MIN_CHAR_VALUE = L'\0';
static const wchar_t MAX_CHAR_VALUE = L'\uFFFE';
CharStream *_input;
protected:
std::pair<TokenSource*, CharStream*> *_tokenFactorySourcePair;
std::vector<std::wstring> _modeNames;
std::vector<std::wstring> _tokenNames;
/// <summary>
/// How to create token objects </summary>
TokenFactory<CommonToken*> *_factory;
/// <summary>
/// The goal of all lexer rules/methods is to create a token object.
/// This is an instance variable as multiple rules may collaborate to
/// create a single token. nextToken will return this object after
/// matching lexer rule(s). If you subclass to allow multiple token
/// emissions, then set this to the last token to be matched or
/// something nonnull so that the auto token emit mechanism will not
/// emit another token.
/// </summary>
public:
Token *_token;
/// <summary>
/// What character index in the stream did the current token start at?
/// Needed, for example, to get the text for current token. Set at
/// the start of nextToken.
/// </summary>
int _tokenStartCharIndex;
/// <summary>
/// The line on which the first character of the token resides </summary>
int _tokenStartLine;
/// <summary>
/// The character position of first character within the line </summary>
int _tokenStartCharPositionInLine;
/// <summary>
/// Once we see EOF on char stream, next token will be EOF.
/// If you have DONE : EOF ; then you see DONE EOF.
/// </summary>
bool _hitEOF;
/// <summary>
/// The channel number for the current token </summary>
int _channel;
/// <summary>
/// The token type for the current token </summary>
int _type;
// Use the vector as a stack.
std::vector<int> _modeStack;
int _mode;
/// <summary>
/// You can set the text for the current token to override what is in
/// the input char buffer. Use setText() or can set this instance var.
/// </summary>
std::wstring _text;
Lexer();
Lexer(CharStream *input);
virtual void reset();
/// <summary>
/// Return a token from this source; i.e., match a token on the char
/// stream.
/// </summary>
virtual Token *nextToken();
/// <summary>
/// Instruct the lexer to skip creating a token for current lexer rule
/// and look for another token. nextToken() knows to keep looking when
/// a lexer rule finishes with token set to SKIP_TOKEN. Recall that
/// if token==null at end of any token rule, it creates one for you
/// and emits it.
/// </summary>
virtual void skip();
virtual void more();
virtual void mode(int m);
virtual void pushMode(int m);
virtual int popMode();
template<typename T1>
void setTokenFactory(TokenFactory<T1> *factory) {
this->_factory = factory;
}
virtual TokenFactory<CommonToken*> *getTokenFactory() override;
/// <summary>
/// Set the char stream and reset the lexer </summary>
virtual void setInputStream(IntStream *input);
virtual std::string getSourceName() override;
virtual CharStream *getInputStream() override;
/// <summary>
/// By default does not support multiple emits per nextToken invocation
/// for efficiency reasons. Subclass and override this method, nextToken,
/// and getToken (to push tokens into a list and pull from that list
/// rather than a single variable as this implementation does).
/// </summary>
virtual void emit(Token *token);
/// <summary>
/// The standard method called to automatically emit a token at the
/// outermost lexical rule. The token object should point into the
/// char buffer start..stop. If there is a text override in 'text',
/// use that to set the token's text. Override this method to emit
/// custom Token objects or provide a new factory.
/// </summary>
virtual Token *emit();
virtual Token *emitEOF();
virtual int getLine() override;
virtual int getCharPositionInLine() override;
virtual void setLine(int line);
virtual void setCharPositionInLine(int charPositionInLine);
/// <summary>
/// What is the index of the current character of lookahead? </summary>
virtual int getCharIndex();
/// <summary>
/// Return the text matched so far for the current token or any
/// text override.
/// </summary>
virtual std::wstring getText();
/// <summary>
/// Set the complete text of this token; it wipes any previous
/// changes to the text.
/// </summary>
virtual void setText(const std::wstring &text);
/// <summary>
/// Override if emitting multiple tokens. </summary>
virtual Token *getToken();
virtual void setToken(Token *_token);
virtual void setType(int ttype);
virtual int getType();
virtual void setChannel(int channel);
virtual int getChannel();
virtual const std::vector<std::wstring>& getModeNames();
/// <summary>
/// Used to print out token names like ID during debugging and
/// error reporting. The generated parsers implement a method
/// that overrides this to point to their String[] tokenNames.
/// </summary>
virtual const std::vector<std::wstring>& getTokenNames() override;
/// <summary>
/// Return a list of all Token objects in input char stream.
/// Forces load of all tokens. Does not include EOF token.
/// </summary>
virtual std::vector<Token*> getAllTokens();
virtual void recover(LexerNoViableAltException *e);
virtual void notifyListeners(LexerNoViableAltException *e);
virtual std::wstring getErrorDisplay(const std::wstring &s);
virtual std::wstring getErrorDisplay(int c);
virtual std::wstring getCharErrorDisplay(int c);
/// <summary>
/// Lexers can normally match any char in it's vocabulary after matching
/// a token, so do the easy thing and just kill a character and hope
/// it all works out. You can instead use the rule invocation stack
/// to do sophisticated error recovery if you are in a fragment rule.
/// </summary>
virtual void recover(RecognitionException *re);
private:
void InitializeInstanceFields();
};
}
}
}
}

View File

@ -1,86 +0,0 @@
#include "LexerInterpreter.h"
#include "ATNType.h"
#include "LexerATNSimulator.h"
#include "ATN.h"
#include "DFA.h"
#include "Exceptions.h"
#include "PredictionContextCache.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
LexerInterpreter::LexerInterpreter(const std::wstring &grammarFileName, std::vector<std::wstring> *tokenNames, std::vector<std::wstring> *ruleNames, std::vector<std::wstring> *modeNames, atn::ATN *atn, CharStream *input) : Lexer(_input), grammarFileName(grammarFileName), atn(atn), _sharedContextCache(new atn::PredictionContextCache()) {
if (atn->grammarType != atn::ATNType::LEXER) {
throw new IllegalArgumentException(L"The ATN must be a lexer ATN.");
}
for (int i = 0; i < (int)_decisionToDFA.size(); i++) {
_decisionToDFA[i] = new dfa::DFA(atn->getDecisionState(i), i);
}
this->_interp = new atn::LexerATNSimulator(atn,_decisionToDFA,_sharedContextCache);
if (tokenNames) {
_tokenNames = *tokenNames;
}
if (ruleNames) {
_ruleNames = *ruleNames;
}
if (modeNames) {
_modeNames = *modeNames;
}
}
atn::ATN *LexerInterpreter::getATN() {
return atn;
}
std::wstring LexerInterpreter::getGrammarFileName() {
return grammarFileName;
}
const std::vector<std::wstring>& LexerInterpreter::getTokenNames() {
return _tokenNames;
}
const std::vector<std::wstring>& LexerInterpreter::getRuleNames() {
return _ruleNames;
}
const std::vector<std::wstring>& LexerInterpreter::getModeNames() {
return _modeNames;
}
}
}
}
}

View File

@ -1,73 +0,0 @@
#include "LexerNoViableAltException.h"
#include "RecognitionException.h"
#include "Interval.h"
#include "CPPUtils.h"
#include "CharStream.h"
#include <stdio.h>
#include <wchar.h>
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
LexerNoViableAltException::LexerNoViableAltException(Lexer *lexer, CharStream *input, int startIndex, atn::ATNConfigSet *deadEndConfigs) : RecognitionException()/*TODO RecognitionException(lexer, input, nullptr)*/, startIndex(startIndex), deadEndConfigs(deadEndConfigs) {
}
int LexerNoViableAltException::getStartIndex() {
return startIndex;
}
atn::ATNConfigSet *LexerNoViableAltException::getDeadEndConfigs() {
return deadEndConfigs;
}
runtime::CharStream *LexerNoViableAltException::getInputStream() {
return (CharStream*)(RecognitionException::getInputStream());
}
std::wstring LexerNoViableAltException::toString() {
std::wstring symbol = L"";
if (startIndex >= 0 && startIndex < (int)getInputStream()->size()) {
symbol = getInputStream()->getText(misc::Interval::of(startIndex,startIndex));
symbol = antlrcpp::escapeWhitespace(symbol, false);
}
std::wstring format = L"LexerNoViableAltException('" + symbol + L"')";
return format;
}
}
}
}
}

View File

@ -1,157 +0,0 @@
#include "ListTokenSource.h"
#include "Token.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
int ListTokenSource::getCharPositionInLine() {
if (i < tokens.size()) {
return ((Token*)tokens[i])->getCharPositionInLine();
} else if (eofToken != nullptr) {
return eofToken->getCharPositionInLine();
} else if (tokens.size() > 0) {
// have to calculate the result from the line/column of the previous
// token, along with the text of the token.
Token *lastToken = tokens[tokens.size() - 1];
std::wstring tokenText = lastToken->getText();
if (tokenText != L"") {
int lastNewLine = (int)tokenText.rfind(L'\n');
if (lastNewLine >= 0) {
return (int)tokenText.length() - lastNewLine - 1;
}
}
return lastToken->getCharPositionInLine() + lastToken->getStopIndex() - lastToken->getStartIndex() + 1;
}
// only reach this if tokens is empty, meaning EOF occurs at the first
// position in the input
return 0;
}
Token *ListTokenSource::nextToken() {
if (i >= tokens.size()) {
if (eofToken == nullptr) {
int start = -1;
if (tokens.size() > 0) {
int previousStop = ((Token*)tokens[tokens.size() - 1])->getStopIndex();
if (previousStop != -1) {
start = previousStop + 1;
}
}
int stop = std::max(-1, start - 1);
eofToken = _factory->create(new std::pair<TokenSource*, CharStream*>(this, getInputStream()), Token::_EOF, L"EOF", Token::DEFAULT_CHANNEL, start, stop, getLine(), getCharPositionInLine());
}
return eofToken;
}
Token *t = tokens[i];
if (i == tokens.size() - 1 && t->getType() == Token::_EOF) {
eofToken = t;
}
i++;
return t;
}
int ListTokenSource::getLine() {
if (i < tokens.size()) {
return tokens[i]->getLine();
} else if (eofToken != nullptr) {
return eofToken->getLine();
} else if (tokens.size() > 0) {
// have to calculate the result from the line/column of the previous
// token, along with the text of the token.
Token *lastToken = tokens[tokens.size() - 1];
int line = lastToken->getLine();
std::wstring tokenText = lastToken->getText();
if (tokenText != L"") {
for (size_t i = 0; i < tokenText.length(); i++) {
if (tokenText[i] == L'\n') {
line++;
}
}
}
// if no text is available, assume the token did not contain any newline characters.
return line;
}
// only reach this if tokens is empty, meaning EOF occurs at the first
// position in the input
return 1;
}
CharStream *ListTokenSource::getInputStream() {
if (i < tokens.size()) {
return tokens[i]->getInputStream();
} else if (eofToken != nullptr) {
return eofToken->getInputStream();
} else if (tokens.size() > 0) {
return tokens[tokens.size() - 1]->getInputStream();
}
// no input stream information is available
return nullptr;
}
std::string ListTokenSource::getSourceName() {
if (sourceName != "") {
return sourceName;
}
CharStream *inputStream = getInputStream();
if (inputStream != nullptr) {
return inputStream->getSourceName();
}
return "List";
}
TokenFactory<CommonToken*> *ListTokenSource::getTokenFactory() {
return _factory;
}
void ListTokenSource::InitializeInstanceFields() {
i = 0;
_factory = CommonTokenFactory::DEFAULT;
}
}
}
}
}

View File

@ -1,170 +0,0 @@
#pragma once
#include "TokenSource.h"
#include "TokenFactory.h"
#include "CharStream.h"
#include "CommonTokenFactory.h"
#include <string>
#include <vector>
#include <algorithm>
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
/// <summary>
/// Provides an implementation of <seealso cref="TokenSource"/> as a wrapper around a list
/// of <seealso cref="Token"/> objects.
/// <p/>
/// If the final token in the list is an <seealso cref="Token#EOF"/> token, it will be used
/// as the EOF token for every call to <seealso cref="#nextToken"/> after the end of the
/// list is reached. Otherwise, an EOF token will be created.
/// </summary>
class ListTokenSource : public TokenSource {
/// <summary>
/// The wrapped collection of <seealso cref="Token"/> objects to return.
/// </summary>
protected:
const std::vector<Token *> tokens;
/// <summary>
/// The name of the input source. If this value is {@code null}, a call to
/// <seealso cref="#getSourceName"/> should return the source name used to create the
/// the next token in <seealso cref="#tokens"/> (or the previous token if the end of
/// the input has been reached).
/// </summary>
private:
const std::string sourceName;
/// <summary>
/// The index into <seealso cref="#tokens"/> of token to return by the next call to
/// <seealso cref="#nextToken"/>. The end of the input is indicated by this value
/// being greater than or equal to the number of items in <seealso cref="#tokens"/>.
/// </summary>
protected:
size_t i;
/// <summary>
/// This field caches the EOF token for the token source.
/// </summary>
Token *eofToken;
/// <summary>
/// This is the backing field for <seealso cref="#getTokenFactory"/> and
/// <seealso cref="setTokenFactory"/>.
/// </summary>
private:
TokenFactory<CommonToken *> *_factory = CommonTokenFactory::DEFAULT;
/// <summary>
/// Constructs a new <seealso cref="ListTokenSource"/> instance from the specified
/// collection of <seealso cref="Token"/> objects.
/// </summary>
/// <param name="tokens"> The collection of <seealso cref="Token"/> objects to provide as a
/// <seealso cref="TokenSource"/>. </param>
/// <exception cref="NullPointerException"> if {@code tokens} is {@code null} </exception>
public:
template<typename T1> //where T1 : Token
ListTokenSource(std::vector<T1> tokens) //this(tokens, nullptr);
{}
/// <summary>
/// Constructs a new <seealso cref="ListTokenSource"/> instance from the specified
/// collection of <seealso cref="Token"/> objects and source name.
/// </summary>
/// <param name="tokens"> The collection of <seealso cref="Token"/> objects to provide as a
/// <seealso cref="TokenSource"/>. </param>
/// <param name="sourceName"> The name of the <seealso cref="TokenSource"/>. If this value is
/// {@code null}, <seealso cref="#getSourceName"/> will attempt to infer the name from
/// the next <seealso cref="Token"/> (or the previous token if the end of the input has
/// been reached).
/// </param>
/// <exception cref="NullPointerException"> if {@code tokens} is {@code null} </exception>
template<typename T1> //where T1 : Token
ListTokenSource(std::vector<T1> tokens, const std::string &sourceName) {
InitializeInstanceFields();
if (tokens.empty()) {
throw L"tokens cannot be null";
}
}
/// <summary>
/// @inheritDoc
/// </summary>
virtual int getCharPositionInLine() override;
/// <summary>
/// @inheritDoc
/// </summary>
virtual Token *nextToken() override;
/// <summary>
/// @inheritDoc
/// </summary>
virtual int getLine() override;
/// <summary>
/// @inheritDoc
/// </summary>
virtual CharStream *getInputStream() override;
/// <summary>
/// @inheritDoc
/// </summary>
virtual std::string getSourceName() override;
/// <summary>
/// @inheritDoc
/// </summary>
template<typename T1>
void setTokenFactory(TokenFactory<T1> *factory) {
this->_factory = factory;
}
/// <summary>
/// @inheritDoc
/// </summary>
virtual TokenFactory<CommonToken *> *getTokenFactory();
private:
void InitializeInstanceFields();
};
}
}
}
}

View File

@ -1,77 +0,0 @@
#pragma once
#include "RecognitionException.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
using org::antlr::v4::runtime::atn::ATNConfigSet;
using org::antlr::v4::runtime::misc::NotNull;
/// <summary>
/// Indicates that the parser could not decide which of two or more paths
/// to take based upon the remaining input. It tracks the starting token
/// of the offending input and also knows where the parser was
/// in the various paths when the error. Reported by reportNoViableAlternative()
/// </summary>
class NoViableAltException : public RecognitionException {
/// <summary>
/// Which configurations did we try at input.index() that couldn't match input.LT(1)? </summary>
private:
ATNConfigSet *const deadEndConfigs;
/// <summary>
/// The token object at the start index; the input stream might
/// not be buffering tokens so get a reference to it. (At the
/// time the error occurred, of course the stream needs to keep a
/// buffer all of the tokens but later we might not have access to those.)
/// </summary>
Token *const startToken;
public:
NoViableAltException(Parser *recognizer); // LL(1) error - this(recognizer, recognizer.getInputStream(), recognizer.getCurrentToken(), recognizer.getCurrentToken(), nullptr, recognizer._ctx);
NoViableAltException(Parser *recognizer, TokenStream *input, Token *startToken, Token *offendingToken, ATNConfigSet *deadEndConfigs, ParserRuleContext *ctx);
virtual Token *getStartToken();
virtual ATNConfigSet *getDeadEndConfigs();
};
}
}
}
}

View File

@ -1,625 +0,0 @@
#include <locale>
#include <vector>
#include "Parser.h"
#include "ATNSimulator.h"
#include "ATNDeserializationOptions.h"
#include "ATNDeserializer.h"
#include "TokenSource.h"
#include "tree/pattern/ParseTreePatternMatcher.h"
#include "ANTLRErrorListener.h"
#include "ATNState.h"
#include "DFA.h"
#include "ParserRuleContext.h"
#include "Token.h"
#include "TerminalNode.h"
#include "TokenStream.h"
#include "ANTLRErrorStrategy.h"
#include "Exceptions.h"
#include "ParseTreeListener.h"
#include "ParseTree.h"
#include "Lexer.h"
#include "ATN.h"
#include "ParserATNSimulator.h"
#include "IntervalSet.h"
#include "RuleStartState.h"
#include "DefaultErrorStrategy.h"
#include "Strings.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
std::map<std::wstring, atn::ATN*> * Parser::bypassAltsAtnCache = new std::map<std::wstring, atn::ATN*>();
Parser::TraceListener::TraceListener(Parser *outerInstance) : outerInstance(outerInstance) {
}
void Parser::TraceListener::enterEveryRule(ParserRuleContext *ctx) {
std::cout << "enter "
<< antlrcpp::ws2s(outerInstance->getRuleNames()[ctx->getRuleIndex()])
<< ", LT(1)=" << antlrcpp::ws2s(outerInstance->_input->LT(1)->getText())
<< std::endl;
}
void Parser::TraceListener::visitTerminal(tree::TerminalNode *node) {
std::cout << "consume "
<< node->getSymbol() << " rule "
<< antlrcpp::ws2s(outerInstance->getRuleNames()[outerInstance->_ctx->getRuleIndex()])
<< std::endl;
}
void Parser::TraceListener::visitErrorNode(tree::ErrorNode *node) {
}
void Parser::TraceListener::exitEveryRule(ParserRuleContext *ctx) {
std::cout << "exit "
<< antlrcpp::ws2s(outerInstance->getRuleNames()[ctx->getRuleIndex()])
<< ", LT(1)=" << antlrcpp::ws2s(outerInstance->_input->LT(1)->getText())
<< std::endl;
}
Parser::TrimToSizeListener *const Parser::TrimToSizeListener::INSTANCE = new Parser::TrimToSizeListener();
void Parser::TrimToSizeListener::enterEveryRule(ParserRuleContext *ctx) {
}
void Parser::TrimToSizeListener::visitTerminal(tree::TerminalNode *node) {
}
void Parser::TrimToSizeListener::visitErrorNode(tree::ErrorNode *node) {
}
void Parser::TrimToSizeListener::exitEveryRule(ParserRuleContext *ctx) {
// TODO: Need to figure out what type this is going to be. In Java we expect it to be set by the generator.
std::vector<tree::ParseTree*>* tmp = dynamic_cast<std::vector<tree::ParseTree*>*>(&ctx->children);
if (tmp != nullptr) {
tmp->shrink_to_fit();
}
}
Parser::Parser(TokenStream* input) {
InitializeInstanceFields();
setInputStream(input);
// TODO: Initialize this safely and handle concurrent accesses.
// TODO: For now treat this as a member variable but it should be shared across instances for speed.
Parser::bypassAltsAtnCache =
new std::map<std::wstring, atn::ATN*>();
}
void Parser::reset() {
if (getInputStream() != nullptr) {
getInputStream()->seek(0);
}
_errHandler->reset(this);
delete _ctx;
_syntaxErrors = 0;
setTrace(false);
_precedenceStack.clear();
_precedenceStack.push_back(0);
atn::ATNSimulator *interpreter = getInterpreter();
if (interpreter != nullptr) {
interpreter->reset();
}
}
Token *Parser::match(int ttype) {
Token *t = getCurrentToken();
if (t->getType() == ttype) {
_errHandler->reportMatch(this);
consume();
} else {
t = _errHandler->recoverInline(this);
if (_buildParseTrees && t->getTokenIndex() == -1) {
// we must have conjured up a new token during single token insertion
// if it's not the current symbol
_ctx->addErrorNode(t);
}
}
return t;
}
Token *Parser::matchWildcard() {
Token *t = getCurrentToken();
if (t->getType() > 0) {
_errHandler->reportMatch(this);
consume();
} else {
t = _errHandler->recoverInline(this);
if (_buildParseTrees && t->getTokenIndex() == -1) {
// we must have conjured up a new token during single token insertion
// if it's not the current symbol
_ctx->addErrorNode(t);
}
}
return t;
}
void Parser::setBuildParseTree(bool buildParseTrees) {
this->_buildParseTrees = buildParseTrees;
}
bool Parser::getBuildParseTree() {
return _buildParseTrees;
}
void Parser::setTrimParseTree(bool trimParseTrees) {
if (trimParseTrees) {
if (getTrimParseTree()) {
return;
}
addParseListener(TrimToSizeListener::INSTANCE);
} else {
removeParseListener(TrimToSizeListener::INSTANCE);
}
}
bool Parser::getTrimParseTree() {
return std::find(getParseListeners().begin(), getParseListeners().end(), TrimToSizeListener::INSTANCE) != getParseListeners().end();
}
std::vector<tree::ParseTreeListener*> Parser::getParseListeners() {
std::vector<tree::ParseTreeListener*> listeners = _parseListeners;
if (listeners.empty()) {
std::vector<tree::ParseTreeListener*> emptyList;
return emptyList;
}
return listeners;
}
void Parser::addParseListener(tree::ParseTreeListener *listener) {
if (listener == nullptr) {
throw NullPointerException(L"listener");
}
if (_parseListeners.empty()) {
_parseListeners = std::vector<tree::ParseTreeListener*>();
}
this->_parseListeners.push_back(listener);
}
void Parser::removeParseListener(tree::ParseTreeListener *listener) {
if (!_parseListeners.empty()) {
auto it = std::find(_parseListeners.begin(), _parseListeners.end(), listener);
if (it != _parseListeners.end()) {
_parseListeners.erase(it);
}
}
}
void Parser::removeParseListeners() {
_parseListeners.clear();
}
void Parser::triggerEnterRuleEvent() {
for (auto listener : _parseListeners) {
listener->enterEveryRule(_ctx);
_ctx->enterRule(listener);
}
}
void Parser::triggerExitRuleEvent() {
// reverse order walk of listeners
for (auto it = _parseListeners.rbegin(); it != _parseListeners.rend(); ++it) {
tree::ParseTreeListener *listener = *it;
_ctx->exitRule(*it);
listener->exitEveryRule(_ctx);
}
}
int Parser::getNumberOfSyntaxErrors() {
return _syntaxErrors;
}
TokenFactory<CommonToken*> *Parser::getTokenFactory() {
return _input->getTokenSource()->getTokenFactory();
}
atn::ATN *Parser::getATNWithBypassAlts() {
std::wstring serializedAtn = getSerializedATN();
if (serializedAtn == L"") {
throw UnsupportedOperationException(L"The current parser does not support an ATN with bypass alternatives.");
}
if (bypassAltsAtnCache != nullptr) {
std::lock_guard<std::mutex> lck(mtx);
atn::ATN *result = bypassAltsAtnCache->at(serializedAtn);
if (result == nullptr) {
atn::ATNDeserializationOptions *deserializationOptions = new atn::ATNDeserializationOptions();
deserializationOptions->setGenerateRuleBypassTransitions(true);
result = (new atn::ATNDeserializer(deserializationOptions))->deserialize(serializedAtn);
bypassAltsAtnCache->emplace(serializedAtn, result);
}
return result;
}
return nullptr;
}
tree::pattern::ParseTreePattern *Parser::compileParseTreePattern(const std::wstring &pattern, int patternRuleIndex) {
if (getTokenStream() != nullptr) {
TokenSource *tokenSource = getTokenStream()->getTokenSource();
if (dynamic_cast<Lexer*>(tokenSource) != nullptr) {
Lexer *lexer = static_cast<Lexer*>(tokenSource);
return compileParseTreePattern(pattern, patternRuleIndex, lexer);
}
}
throw UnsupportedOperationException(L"Parser can't discover a lexer to use");
}
tree::pattern::ParseTreePattern *Parser::compileParseTreePattern(const std::wstring &pattern, int patternRuleIndex, Lexer *lexer) {
tree::pattern::ParseTreePatternMatcher *m = new tree::pattern::ParseTreePatternMatcher(lexer, this);
return m->compile(pattern, patternRuleIndex);
}
ANTLRErrorStrategy *Parser::getErrorHandler() {
return _errHandler;
}
void Parser::setErrorHandler(ANTLRErrorStrategy *handler) {
this->_errHandler = handler;
}
TokenStream *Parser::getInputStream() {
return getTokenStream();
}
void Parser::setInputStream(IntStream *input) {
setTokenStream(static_cast<TokenStream*>(input));
}
TokenStream *Parser::getTokenStream() {
return _input;
}
void Parser::setTokenStream(TokenStream *input) {
delete this->_input;
reset();
this->_input = input;
}
Token *Parser::getCurrentToken() {
return _input->LT(1);
}
void Parser::notifyErrorListeners(const std::wstring &msg) {
notifyErrorListeners(getCurrentToken(), msg, nullptr);
}
void Parser::notifyErrorListeners(Token *offendingToken, const std::wstring &msg, RecognitionException *e) {
_syntaxErrors++;
int line = -1;
int charPositionInLine = -1;
line = offendingToken->getLine();
charPositionInLine = offendingToken->getCharPositionInLine();
ANTLRErrorListener *listener = getErrorListenerDispatch();
listener->syntaxError(this, offendingToken, line, charPositionInLine, msg, e);
}
Token *Parser::consume() {
Token *o = getCurrentToken();
if (o->getType() != EOF) {
getInputStream()->consume();
}
bool hasListener = _parseListeners.size() > 0 && !_parseListeners.empty();
if (_buildParseTrees || hasListener) {
if (_errHandler->inErrorRecoveryMode(this)) {
tree::ErrorNode *node = _ctx->addErrorNode(o);
if (_parseListeners.size() > 0) {
for (auto listener : _parseListeners) {
listener->visitErrorNode(node);
}
}
} else {
tree::TerminalNode *node = _ctx->addChild(o);
if (_parseListeners.size() > 0) {
for (auto listener : _parseListeners) {
listener->visitTerminal(node);
}
}
}
}
return o;
}
void Parser::addContextToParseTree() {
ParserRuleContext *parent = static_cast<ParserRuleContext*>(_ctx->parent);
// add current context to parent if we have a parent
if (parent != nullptr) {
parent->addChild(_ctx);
}
}
void Parser::enterRule(ParserRuleContext *localctx, int state, int ruleIndex) {
setState(state);
_ctx = localctx;
_ctx->start = _input->LT(1);
if (_buildParseTrees) {
addContextToParseTree();
}
if (_parseListeners.size() > 0) {
triggerEnterRuleEvent();
}
}
void Parser::exitRule() {
_ctx->stop = _input->LT(-1);
// trigger event on _ctx, before it reverts to parent
if (_parseListeners.size() > 0) {
triggerExitRuleEvent();
}
setState(_ctx->invokingState);
_ctx = static_cast<ParserRuleContext*>(_ctx->parent);
}
void Parser::enterOuterAlt(ParserRuleContext *localctx, int altNum) {
// if we have new localctx, make sure we replace existing ctx
// that is previous child of parse tree
if (_buildParseTrees && _ctx != localctx) {
ParserRuleContext *parent = static_cast<ParserRuleContext*>(_ctx->parent);
if (parent != nullptr) {
parent->removeLastChild();
parent->addChild(localctx);
}
}
_ctx = localctx;
}
void Parser::enterRecursionRule(ParserRuleContext *localctx, int ruleIndex) {
enterRecursionRule(localctx, getATN()->ruleToStartState[ruleIndex]->stateNumber, ruleIndex, 0);
}
void Parser::enterRecursionRule(ParserRuleContext *localctx, int state, int ruleIndex, int precedence) {
setState(state);
_precedenceStack.push_back(precedence);
_ctx = localctx;
_ctx->start = _input->LT(1);
if (_parseListeners.size() > 0) {
triggerEnterRuleEvent(); // simulates rule entry for left-recursive rules
}
}
void Parser::pushNewRecursionContext(ParserRuleContext *localctx, int state, int ruleIndex) {
ParserRuleContext *previous = _ctx;
previous->parent = localctx;
previous->invokingState = state;
previous->stop = _input->LT(-1);
_ctx = localctx;
_ctx->start = previous->start;
if (_buildParseTrees) {
_ctx->addChild(previous);
}
if (_parseListeners.size() > 0) {
triggerEnterRuleEvent(); // simulates rule entry for left-recursive rules
}
}
void Parser::unrollRecursionContexts(ParserRuleContext *_parentctx) {
_precedenceStack.pop_back();
_ctx->stop = _input->LT(-1);
ParserRuleContext *retctx = _ctx; // save current ctx (return value)
// unroll so _ctx is as it was before call to recursive method
if (_parseListeners.size() > 0) {
while (_ctx != _parentctx) {
triggerExitRuleEvent();
_ctx = static_cast<ParserRuleContext*>(_ctx->parent);
}
} else {
_ctx = _parentctx;
}
// hook into tree
retctx->parent = _parentctx;
if (_buildParseTrees && _parentctx != nullptr) {
// add return ctx into invoking rule's tree
_parentctx->addChild(retctx);
}
}
ParserRuleContext *Parser::getInvokingContext(int ruleIndex) {
ParserRuleContext *p = _ctx;
while (p != nullptr) {
if (p->getRuleIndex() == ruleIndex) {
return p;
}
p = static_cast<ParserRuleContext*>(p->parent);
}
return nullptr;
}
ParserRuleContext *Parser::getContext() {
return _ctx;
}
void Parser::setContext(ParserRuleContext *ctx) {
_ctx = ctx;
}
bool Parser::precpred(RuleContext *localctx, int precedence) {
return precedence >= _precedenceStack.back();
}
bool Parser::inContext(const std::wstring &context) {
// TODO: useful in parser?
return false;
}
bool Parser::isExpectedToken(int symbol) {
// return getInterpreter().atn.nextTokens(_ctx);
atn::ATN *atn = getInterpreter()->atn;
ParserRuleContext *ctx = _ctx;
atn::ATNState *s = atn->states[getState()];
misc::IntervalSet *following = atn->nextTokens(s);
if (following->contains(symbol)) {
return true;
}
// System.out.println("following "+s+"="+following);
if (!following->contains(Token::EPSILON)) {
return false;
}
while (ctx != nullptr && ctx->invokingState >= 0 && following->contains(Token::EPSILON)) {
atn::ATNState *invokingState = atn->states[ctx->invokingState];
atn::RuleTransition *rt = static_cast<atn::RuleTransition*>(invokingState->transition(0));
following = atn->nextTokens(rt->followState);
if (following->contains(symbol)) {
return true;
}
ctx = static_cast<ParserRuleContext*>(ctx->parent);
}
if (following->contains(Token::EPSILON) && symbol == Token::_EOF) {
return true;
}
return false;
}
misc::IntervalSet *Parser::getExpectedTokens() {
return getATN()->getExpectedTokens(getState(), getContext());
}
misc::IntervalSet *Parser::getExpectedTokensWithinCurrentRule() {
atn::ATN *atn = getInterpreter()->atn;
atn::ATNState *s = atn->states[getState()];
return atn->nextTokens(s);
}
int Parser::getRuleIndex(const std::wstring &ruleName) {
std::map<std::wstring, int>* m = getRuleIndexMap();
if (m->find(ruleName) == m->end()) {
return -1;
}
return m->at(ruleName);
}
ParserRuleContext *Parser::getRuleContext() {
return _ctx;
}
std::vector<std::wstring> Parser::getRuleInvocationStack() {
return getRuleInvocationStack(_ctx);
}
std::vector<std::wstring> Parser::getRuleInvocationStack(RuleContext *p) {
std::vector<std::wstring> ruleNames = getRuleNames();
std::vector<std::wstring> stack = std::vector<std::wstring>();
while (p != nullptr) {
// compute what follows who invoked us
int ruleIndex = p->getRuleIndex();
if (ruleIndex < 0) {
stack.push_back(L"n/a");
} else {
stack.push_back(ruleNames[ruleIndex]);
}
p = p->parent;
}
return stack;
}
std::vector<std::wstring> Parser::getDFAStrings() {
if (!_interp->_decisionToDFA.empty()) {
std::lock_guard<std::mutex> lck(mtx);
std::vector<std::wstring> s = std::vector<std::wstring>();
for (size_t d = 0; d < _interp->_decisionToDFA.size(); d++) {
dfa::DFA *dfa = &_interp->_decisionToDFA[d];
s.push_back(dfa->toString(getTokenNames()));
}
return s;
}
return std::vector<std::wstring>();
}
void Parser::dumpDFA() {
if (!_interp->_decisionToDFA.empty()) {
std::lock_guard<std::mutex> lck(mtx);
bool seenOne = false;
for (size_t d = 0; d < _interp->_decisionToDFA.size(); d++) {
dfa::DFA *dfa = &_interp->_decisionToDFA[d];
if (!dfa->states->empty()) {
if (seenOne) {
std::cout << std::endl;
}
std::cout << L"Decision " << dfa->decision << L":" << std::endl;
dfa->toString(getTokenNames());
std::wcout << dfa->toString(getTokenNames());
seenOne = true;
}
}
}
}
std::string Parser::getSourceName() {
return _input->getSourceName();
}
void Parser::setTrace(bool trace) {
if (!trace) {
removeParseListener(_tracer);
// TODO
//JAVA TO C++ CONVERTER WARNING: Java to C++ Converter converted the original 'null' assignment to a call to 'delete', but you should review memory allocation of all pointer variables in the converted code:
delete _tracer;
} else {
if (_tracer != nullptr) {
removeParseListener(_tracer);
} else {
_tracer = new TraceListener(this);
}
addParseListener(_tracer);
}
}
void Parser::InitializeInstanceFields() {
_errHandler = new DefaultErrorStrategy();
_precedenceStack.clear();
_precedenceStack.push_back(0);
_buildParseTrees = true;
_syntaxErrors = 0;
}
}
}
}
}

View File

@ -1,490 +0,0 @@
#pragma once
#include <mutex>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <map>
#include "Recognizer.h"
#include "ParseTreeListener.h"
#include "TokenStream.h"
#include "BitSet.h"
#include "Declarations.h"
#include "TokenSource.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
/// <summary>
/// This is all the parsing support code essentially; most of it is error recovery stuff. </summary>
class Parser : public Recognizer<Token*, atn::ParserATNSimulator*> {
public:
class TraceListener : public tree::ParseTreeListener {
private:
Parser *const outerInstance;
public:
TraceListener(Parser *outerInstance);
virtual ~TraceListener() {};
virtual void enterEveryRule(ParserRuleContext *ctx) override;
virtual void visitTerminal(tree::TerminalNode *node) override;
virtual void visitErrorNode(tree::ErrorNode *node) override;
virtual void exitEveryRule(ParserRuleContext *ctx) override;
};
public:
class TrimToSizeListener : public tree::ParseTreeListener {
public:
static TrimToSizeListener *const INSTANCE;
virtual void enterEveryRule(ParserRuleContext *ctx) override;
virtual void visitTerminal(tree::TerminalNode *node) override;
virtual void visitErrorNode(tree::ErrorNode *node) override;
virtual void exitEveryRule(ParserRuleContext *ctx) override;
};
/// <summary>
/// This field maps from the serialized ATN string to the deserialized <seealso cref="ATN"/> with
/// bypass alternatives.
/// </summary>
/// <seealso cref= ATNDeserializationOptions#isGenerateRuleBypassTransitions() </seealso>
private:
static std::map<std::wstring, atn::ATN*> * bypassAltsAtnCache;
/// <summary>
/// The error handling strategy for the parser. The default value is a new
/// instance of <seealso cref="DefaultErrorStrategy"/>.
/// </summary>
/// <seealso cref= #getErrorHandler </seealso>
/// <seealso cref= #setErrorHandler </seealso>
protected:
ANTLRErrorStrategy *_errHandler;
/// <summary>
/// The input stream.
/// </summary>
/// <seealso cref= #getInputStream </seealso>
/// <seealso cref= #setInputStream </seealso>
TokenStream *_input;
std::vector<int> _precedenceStack;
//Mutex to manage synchronized access for multithreading in the parser
std::mutex mtx;
/// <summary>
/// The <seealso cref="ParserRuleContext"/> object for the currently executing rule.
/// This is always non-null during the parsing process.
/// </summary>
public:
ParserRuleContext *_ctx;
/// <summary>
/// Specifies whether or not the parser should construct a parse tree during
/// the parsing process. The default value is {@code true}.
/// </summary>
/// <seealso cref= #getBuildParseTree </seealso>
/// <seealso cref= #setBuildParseTree </seealso>
protected:
bool _buildParseTrees;
/// <summary>
/// When <seealso cref="#setTrace"/>{@code (true)} is called, a reference to the
/// <seealso cref="TraceListener"/> is stored here so it can be easily removed in a
/// later call to <seealso cref="#setTrace"/>{@code (false)}. The listener itself is
/// implemented as a parser listener so this field is not directly used by
/// other parser methods.
/// </summary>
private:
TraceListener *_tracer;
/// <summary>
/// The list of <seealso cref="ParseTreeListener"/> listeners registered to receive
/// events during the parse.
/// </summary>
/// <seealso cref= #addParseListener </seealso>
protected:
std::vector<tree::ParseTreeListener*> _parseListeners;
/// <summary>
/// The number of syntax errors reported during parsing. This value is
/// incremented each time <seealso cref="#notifyErrorListeners"/> is called.
/// </summary>
int _syntaxErrors;
public:
Parser(TokenStream *input);
/// <summary>
/// reset the parser's state </summary>
virtual void reset();
/// <summary>
/// Match current input symbol against {@code ttype}. If the symbol type
/// matches, <seealso cref="ANTLRErrorStrategy#reportMatch"/> and <seealso cref="#consume"/> are
/// called to complete the match process.
/// <p/>
/// If the symbol type does not match,
/// <seealso cref="ANTLRErrorStrategy#recoverInline"/> is called on the current error
/// strategy to attempt recovery. If <seealso cref="#getBuildParseTree"/> is
/// {@code true} and the token index of the symbol returned by
/// <seealso cref="ANTLRErrorStrategy#recoverInline"/> is -1, the symbol is added to
/// the parse tree by calling <seealso cref="ParserRuleContext#addErrorNode"/>.
/// </summary>
/// <param name="ttype"> the token type to match </param>
/// <returns> the matched symbol </returns>
/// <exception cref="RecognitionException"> if the current input symbol did not match
/// {@code ttype} and the error strategy could not recover from the
/// mismatched symbol </exception>
virtual Token *match(int ttype);
/// <summary>
/// Match current input symbol as a wildcard. If the symbol type matches
/// (i.e. has a value greater than 0), <seealso cref="ANTLRErrorStrategy#reportMatch"/>
/// and <seealso cref="#consume"/> are called to complete the match process.
/// <p/>
/// If the symbol type does not match,
/// <seealso cref="ANTLRErrorStrategy#recoverInline"/> is called on the current error
/// strategy to attempt recovery. If <seealso cref="#getBuildParseTree"/> is
/// {@code true} and the token index of the symbol returned by
/// <seealso cref="ANTLRErrorStrategy#recoverInline"/> is -1, the symbol is added to
/// the parse tree by calling <seealso cref="ParserRuleContext#addErrorNode"/>.
/// </summary>
/// <returns> the matched symbol </returns>
/// <exception cref="RecognitionException"> if the current input symbol did not match
/// a wildcard and the error strategy could not recover from the mismatched
/// symbol </exception>
virtual Token *matchWildcard();
/// <summary>
/// Track the <seealso cref="ParserRuleContext"/> objects during the parse and hook
/// them up using the <seealso cref="ParserRuleContext#children"/> list so that it
/// forms a parse tree. The <seealso cref="ParserRuleContext"/> returned from the start
/// rule represents the root of the parse tree.
/// <p/>
/// Note that if we are not building parse trees, rule contexts only point
/// upwards. When a rule exits, it returns the context but that gets garbage
/// collected if nobody holds a reference. It points upwards but nobody
/// points at it.
/// <p/>
/// When we build parse trees, we are adding all of these contexts to
/// <seealso cref="ParserRuleContext#children"/> list. Contexts are then not candidates
/// for garbage collection.
/// </summary>
virtual void setBuildParseTree(bool buildParseTrees);
/// <summary>
/// Gets whether or not a complete parse tree will be constructed while
/// parsing. This property is {@code true} for a newly constructed parser.
/// </summary>
/// <returns> {@code true} if a complete parse tree will be constructed while
/// parsing, otherwise {@code false} </returns>
virtual bool getBuildParseTree();
/// <summary>
/// Trim the internal lists of the parse tree during parsing to conserve memory.
/// This property is set to {@code false} by default for a newly constructed parser.
/// </summary>
/// <param name="trimParseTrees"> {@code true} to trim the capacity of the <seealso cref="ParserRuleContext#children"/>
/// list to its size after a rule is parsed. </param>
virtual void setTrimParseTree(bool trimParseTrees);
/// <returns> {@code true} if the <seealso cref="ParserRuleContext#children"/> list is trimmed
/// using the default <seealso cref="Parser.TrimToSizeListener"/> during the parse process. </returns>
virtual bool getTrimParseTree();
virtual std::vector<tree::ParseTreeListener*> getParseListeners();
/// <summary>
/// Registers {@code listener} to receive events during the parsing process.
/// <p/>
/// To support output-preserving grammar transformations (including but not
/// limited to left-recursion removal, automated left-factoring, and
/// optimized code generation), calls to listener methods during the parse
/// may differ substantially from calls made by
/// <seealso cref="ParseTreeWalker#DEFAULT"/> used after the parse is complete. In
/// particular, rule entry and exit events may occur in a different order
/// during the parse than after the parser. In addition, calls to certain
/// rule entry methods may be omitted.
/// <p/>
/// With the following specific exceptions, calls to listener events are
/// <em>deterministic</em>, i.e. for identical input the calls to listener
/// methods will be the same.
///
/// <ul>
/// <li>Alterations to the grammar used to generate code may change the
/// behavior of the listener calls.</li>
/// <li>Alterations to the command line options passed to ANTLR 4 when
/// generating the parser may change the behavior of the listener calls.</li>
/// <li>Changing the version of the ANTLR Tool used to generate the parser
/// may change the behavior of the listener calls.</li>
/// </ul>
/// </summary>
/// <param name="listener"> the listener to add
/// </param>
/// <exception cref="NullPointerException"> if {@code} listener is {@code null} </exception>
virtual void addParseListener(tree::ParseTreeListener *listener);
/// <summary>
/// Remove {@code listener} from the list of parse listeners.
/// <p/>
/// If {@code listener} is {@code null} or has not been added as a parse
/// listener, this method does nothing.
/// </summary>
/// <seealso cref= #addParseListener
/// </seealso>
/// <param name="listener"> the listener to remove </param>
virtual void removeParseListener(tree::ParseTreeListener *listener);
/// <summary>
/// Remove all parse listeners.
/// </summary>
/// <seealso cref= #addParseListener </seealso>
virtual void removeParseListeners();
/// <summary>
/// Notify any parse listeners of an enter rule event.
/// </summary>
/// <seealso cref= #addParseListener </seealso>
protected:
virtual void triggerEnterRuleEvent();
/// <summary>
/// Notify any parse listeners of an exit rule event.
/// </summary>
/// <seealso cref= #addParseListener </seealso>
virtual void triggerExitRuleEvent();
/// <summary>
/// Gets the number of syntax errors reported during parsing. This value is
/// incremented each time <seealso cref="#notifyErrorListeners"/> is called.
/// </summary>
/// <seealso cref= #notifyErrorListeners </seealso>
public:
virtual int getNumberOfSyntaxErrors();
virtual TokenFactory<CommonToken*> *getTokenFactory() override;
/// <summary>
/// Tell our token source and error strategy about a new way to create tokens. </summary>
template<typename T1>
void setTokenFactory(TokenFactory<T1> *factory) {
_input->getTokenSource()->setTokenFactory(factory);
}
/// <summary>
/// The ATN with bypass alternatives is expensive to create so we create it
/// lazily.
/// </summary>
/// <exception cref="UnsupportedOperationException"> if the current parser does not
/// implement the <seealso cref="#getSerializedATN()"/> method. </exception>
virtual atn::ATN *getATNWithBypassAlts();
/// <summary>
/// The preferred method of getting a tree pattern. For example, here's a
/// sample use:
///
/// <pre>
/// ParseTree t = parser.expr();
/// ParseTreePattern p = parser.compileParseTreePattern("<ID>+0", MyParser.RULE_expr);
/// ParseTreeMatch m = p.match(t);
/// String id = m.get("ID");
/// </pre>
/// </summary>
virtual tree::pattern::ParseTreePattern *compileParseTreePattern(const std::wstring &pattern, int patternRuleIndex);
/// <summary>
/// The same as <seealso cref="#compileParseTreePattern(String, int)"/> but specify a
/// <seealso cref="Lexer"/> rather than trying to deduce it from this parser.
/// </summary>
virtual tree::pattern::ParseTreePattern *compileParseTreePattern(const std::wstring &pattern, int patternRuleIndex, Lexer *lexer);
virtual ANTLRErrorStrategy *getErrorHandler();
virtual void setErrorHandler(ANTLRErrorStrategy *handler);
virtual TokenStream *getInputStream() override;
void setInputStream(IntStream *input) override;
virtual TokenStream *getTokenStream();
/// <summary>
/// Set the token stream and reset the parser. </summary>
virtual void setTokenStream(TokenStream *input);
/// <summary>
/// Match needs to return the current input symbol, which gets put
/// into the label for the associated token ref; e.g., x=ID.
/// </summary>
virtual Token *getCurrentToken();
void notifyErrorListeners(const std::wstring &msg);
virtual void notifyErrorListeners(Token *offendingToken, const std::wstring &msg, RecognitionException *e);
/// <summary>
/// Consume and return the <seealso cref="#getCurrentToken current symbol"/>.
/// <p/>
/// E.g., given the following input with {@code A} being the current
/// lookahead symbol, this function moves the cursor to {@code B} and returns
/// {@code A}.
///
/// <pre>
/// A B
/// ^
/// </pre>
///
/// If the parser is not in error recovery mode, the consumed symbol is added
/// to the parse tree using <seealso cref="ParserRuleContext#addChild(Token)"/>, and
/// <seealso cref="ParseTreeListener#visitTerminal"/> is called on any parse listeners.
/// If the parser <em>is</em> in error recovery mode, the consumed symbol is
/// added to the parse tree using
/// <seealso cref="ParserRuleContext#addErrorNode(Token)"/>, and
/// <seealso cref="ParseTreeListener#visitErrorNode"/> is called on any parse
/// listeners.
/// </summary>
virtual Token *consume();
protected:
virtual void addContextToParseTree();
/// <summary>
/// Always called by generated parsers upon entry to a rule. Access field
/// <seealso cref="#_ctx"/> get the current context.
/// </summary>
public:
virtual void enterRule(ParserRuleContext *localctx, int state, int ruleIndex);
virtual void exitRule();
virtual void enterOuterAlt(ParserRuleContext *localctx, int altNum);
/// @deprecated Use
/// <seealso cref="#enterRecursionRule(ParserRuleContext, int, int, int)"/> instead.
virtual void enterRecursionRule(ParserRuleContext *localctx, int ruleIndex);
virtual void enterRecursionRule(ParserRuleContext *localctx, int state, int ruleIndex, int precedence);
/// <summary>
/// Like <seealso cref="#enterRule"/> but for recursive rules.
/// </summary>
virtual void pushNewRecursionContext(ParserRuleContext *localctx, int state, int ruleIndex);
virtual void unrollRecursionContexts(ParserRuleContext *_parentctx);
virtual ParserRuleContext *getInvokingContext(int ruleIndex);
virtual ParserRuleContext *getContext();
virtual void setContext(ParserRuleContext *ctx);
virtual bool precpred(RuleContext *localctx, int precedence) override;
virtual bool inContext(const std::wstring &context);
/// <summary>
/// Checks whether or not {@code symbol} can follow the current state in the
/// ATN. The behavior of this method is equivalent to the following, but is
/// implemented such that the complete context-sensitive follow set does not
/// need to be explicitly constructed.
///
/// <pre>
/// return getExpectedTokens().contains(symbol);
/// </pre>
/// </summary>
/// <param name="symbol"> the symbol type to check </param>
/// <returns> {@code true} if {@code symbol} can follow the current state in
/// the ATN, otherwise {@code false}. </returns>
virtual bool isExpectedToken(int symbol);
/// <summary>
/// Computes the set of input symbols which could follow the current parser
/// state and context, as given by <seealso cref="#getState"/> and <seealso cref="#getContext"/>,
/// respectively.
/// </summary>
/// <seealso cref= ATN#getExpectedTokens(int, RuleContext) </seealso>
virtual misc::IntervalSet *getExpectedTokens();
virtual misc::IntervalSet *getExpectedTokensWithinCurrentRule();
/// <summary>
/// Get a rule's index (i.e., {@code RULE_ruleName} field) or -1 if not found. </summary>
virtual int getRuleIndex(const std::wstring &ruleName);
virtual ParserRuleContext *getRuleContext();
/// <summary>
/// Return List&lt;String&gt; of the rule names in your parser instance
/// leading up to a call to the current rule. You could override if
/// you want more details such as the file/line info of where
/// in the ATN a rule is invoked.
///
/// This is very useful for error messages.
/// </summary>
virtual std::vector<std::wstring> getRuleInvocationStack();
virtual std::vector<std::wstring> getRuleInvocationStack(RuleContext *p);
/// <summary>
/// For debugging and other purposes. </summary>
virtual std::vector<std::wstring> getDFAStrings();
/// <summary>
/// For debugging and other purposes. </summary>
virtual void dumpDFA();
virtual std::string getSourceName();
/// <summary>
/// During a parse is sometimes useful to listen in on the rule entry and exit
/// events as well as token matches. This is for quick and dirty debugging.
/// </summary>
virtual void setTrace(bool trace);
private:
void InitializeInstanceFields();
};
}
}
}
}

View File

@ -1,243 +0,0 @@
#include <deque>
#include "ParserInterpreter.h"
#include "ATN.h"
#include "DFA.h"
#include "RuleStartState.h"
#include "InterpreterRuleContext.h"
#include "ParserATNSimulator.h"
#include "DecisionState.h"
#include "Transition.h"
#include "ANTLRErrorStrategy.h"
#include "Token.h"
#include "AtomTransition.h"
#include "ActionTransition.h"
#include "Exceptions.h"
#include "RuleTransition.h"
#include "PrecedencePredicateTransition.h"
#include "PredicateTransition.h"
#include "LoopEndState.h"
#include "FailedPredicateException.h"
#include "RuleStartState.h"
#include "StarLoopEntryState.h"
#include "PredictionContextCache.h"
#include "IntervalSet.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
ParserInterpreter::ParserInterpreter(const std::wstring &grammarFileName, const std::vector<std::wstring>& tokenNames, const std::vector<std::wstring>& ruleNames, atn::ATN *atn, TokenStream *input) : Parser(_input), grammarFileName(grammarFileName), _tokenNames(tokenNames), atn(atn), _ruleNames(ruleNames), pushRecursionContextStates(new antlrcpp::BitSet()), sharedContextCache(new atn::PredictionContextCache()), _parentContextStack(new std::deque<std::pair<ParserRuleContext *, int>*>()) {
for (int i = 0; i < atn->getNumberOfDecisions(); i++) {
_decisionToDFA.emplace_back(atn->getDecisionState(i), i);
}
// identify the ATN states where pushNewRecursionContext must be called
for (auto state : atn->states) {
if (!(dynamic_cast<atn::StarLoopEntryState*>(state) != nullptr)) {
continue;
}
atn::RuleStartState *ruleStartState = atn->ruleToStartState[state->ruleIndex];
if (!ruleStartState->isPrecedenceRule) {
continue;
}
atn::ATNState *maybeLoopEndState = state->transition(state->getNumberOfTransitions() - 1)->target;
if (!(dynamic_cast<atn::LoopEndState*>(maybeLoopEndState) != nullptr)) {
continue;
}
if (maybeLoopEndState->epsilonOnlyTransitions && dynamic_cast<atn::RuleStopState*>(maybeLoopEndState->transition(0)->target) != nullptr) {
this->pushRecursionContextStates->set(state->stateNumber);
}
}
// get atn simulator that knows how to do predictions
setInterpreter(new atn::ParserATNSimulator(this, atn, _decisionToDFA, sharedContextCache));
}
org::antlr::v4::runtime::atn::ATN *ParserInterpreter::getATN() {
return atn;
}
const std::vector<std::wstring>& ParserInterpreter::getTokenNames() {
return _tokenNames;
}
const std::vector<std::wstring>& ParserInterpreter::getRuleNames() {
return _ruleNames;
}
std::wstring ParserInterpreter::getGrammarFileName() {
return grammarFileName;
}
ParserRuleContext *ParserInterpreter::parse(int startRuleIndex) {
atn::RuleStartState *startRuleStartState = atn->ruleToStartState[startRuleIndex];
InterpreterRuleContext *rootContext = new InterpreterRuleContext(nullptr, atn::ATNState::INVALID_STATE_NUMBER, startRuleIndex);
if (startRuleStartState->isPrecedenceRule) {
enterRecursionRule(rootContext, startRuleStartState->stateNumber, startRuleIndex, 0);
} else {
enterRule(rootContext, startRuleStartState->stateNumber, startRuleIndex);
}
while (true) {
atn::ATNState *p = getATNState();
switch (p->getStateType()) {
case atn::ATNState::RULE_STOP :
// pop; return from rule
if (_ctx->isEmpty()) {
exitRule();
return rootContext;
}
visitRuleStopState(p);
break;
default :
visitState(p);
break;
}
}
}
void ParserInterpreter::enterRecursionRule(ParserRuleContext *localctx, int state, int ruleIndex, int precedence) {
_parentContextStack->push_back(new std::pair<ParserRuleContext*, int>(_ctx, localctx->invokingState));
Parser::enterRecursionRule(localctx, state, ruleIndex, precedence);
}
atn::ATNState *ParserInterpreter::getATNState() {
return atn->states.at(getState());
}
void ParserInterpreter::visitState(atn::ATNState *p) {
int edge;
if (p->getNumberOfTransitions() > 1) {
edge = getInterpreter()->adaptivePredict(_input, ((atn::DecisionState*)p)->decision, _ctx);
} else {
edge = 1;
}
atn::Transition *transition = p->transition(edge - 1);
switch (transition->getSerializationType()) {
case atn::Transition::EPSILON:
if (pushRecursionContextStates->data[p->stateNumber] == 1 && !(dynamic_cast<atn::LoopEndState*>(transition->target) != nullptr)) {
InterpreterRuleContext *ctx = new InterpreterRuleContext(_parentContextStack->front()->first, _parentContextStack->front()->second, _ctx->getRuleIndex());
pushNewRecursionContext(ctx, atn->ruleToStartState[p->ruleIndex]->stateNumber, _ctx->getRuleIndex());
}
break;
case atn::Transition::ATOM:
match(((atn::AtomTransition*)(transition))->_label);
break;
case atn::Transition::RANGE:
case atn::Transition::SET:
case atn::Transition::NOT_SET:
if (!transition->matches(_input->LA(1), Token::MIN_USER_TOKEN_TYPE, 65535)) {
_errHandler->recoverInline(this);
}
matchWildcard();
break;
case atn::Transition::WILDCARD:
matchWildcard();
break;
case atn::Transition::RULE:
{
atn::RuleStartState *ruleStartState = (atn::RuleStartState*)(transition->target);
int ruleIndex = ruleStartState->ruleIndex;
InterpreterRuleContext *ctx = new InterpreterRuleContext(_ctx, p->stateNumber, ruleIndex);
if (ruleStartState->isPrecedenceRule) {
enterRecursionRule(ctx, ruleStartState->stateNumber, ruleIndex, ((atn::RuleTransition*)(transition))->precedence);
} else {
enterRule(ctx, transition->target->stateNumber, ruleIndex);
}
}
break;
case atn::Transition::PREDICATE:
{
atn::PredicateTransition *predicateTransition = (atn::PredicateTransition*)(transition);
if (!sempred(_ctx, predicateTransition->ruleIndex, predicateTransition->predIndex)) {
throw new FailedPredicateException(this);
}
}
break;
case atn::Transition::ACTION:
{
atn::ActionTransition *actionTransition = (atn::ActionTransition*)(transition);
action(_ctx, actionTransition->ruleIndex, actionTransition->actionIndex);
}
break;
case atn::Transition::PRECEDENCE:
{
if (!precpred(_ctx, ((atn::PrecedencePredicateTransition*)(transition))->precedence)) {
throw new FailedPredicateException(this, L"precpred(_ctx, " + std::to_wstring(((atn::PrecedencePredicateTransition*)(transition))->precedence) + L")");
}
}
break;
default:
throw UnsupportedOperationException(L"Unrecognized ATN transition type.");
}
setState(transition->target->stateNumber);
}
void ParserInterpreter::visitRuleStopState(atn::ATNState *p) {
atn::RuleStartState *ruleStartState = atn->ruleToStartState[p->ruleIndex];
if (ruleStartState->isPrecedenceRule) {
std::pair<ParserRuleContext*, int> *parentContext = _parentContextStack->back(); // Dan - make sure this is equivalent
_parentContextStack->pop_back();
unrollRecursionContexts(parentContext->first);
setState(parentContext->second);
} else {
exitRule();
}
atn::RuleTransition *ruleTransition = static_cast<atn::RuleTransition*>(atn->states.at(getState())->transition(0));
setState(ruleTransition->followState->stateNumber);
}
}
}
}
}

View File

@ -1,106 +0,0 @@
#pragma once
#include <string>
#include <deque>
#include "Parser.h"
#include "Declarations.h"
/*
* [The "BSD license"]
* Copyright (c) 2013 Terence Parr
* Copyright (c) 2013 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.
*/
namespace org {
namespace antlr {
namespace v4 {
namespace runtime {
/// <summary>
/// A parser simulator that mimics what ANTLR's generated
/// parser code does. A ParserATNSimulator is used to make
/// predictions via adaptivePredict but this class moves a pointer through the
/// ATN to simulate parsing. ParserATNSimulator just
/// makes us efficient rather than having to backtrack, for example.
///
/// This properly creates parse trees even for left recursive rules.
///
/// We rely on the left recursive rule invocation and special predicate
/// transitions to make left recursive rules work.
///
/// See TestParserInterpreter for examples.
/// </summary>
class ParserInterpreter : public Parser {
protected:
//TODO check this
static const int DEFAULT_BITSET_SIZE = 1024; // atn->states.size() ideally
const std::wstring grammarFileName;
std::vector<std::wstring> _tokenNames;
atn::ATN *const atn;
std::vector<std::wstring> _ruleNames;
antlrcpp::BitSet *const pushRecursionContextStates;
std::vector<dfa::DFA> _decisionToDFA; // not shared like it is for generated parsers
atn::PredictionContextCache *const sharedContextCache;
std::deque<std::pair<ParserRuleContext*, int>*> *const _parentContextStack;
public:
ParserInterpreter(const std::wstring &grammarFileName, const std::vector<std::wstring>& tokenNames, const std::vector<std::wstring>& ruleNames, atn::ATN *atn, TokenStream *input);
virtual atn::ATN *getATN() override;
virtual const std::vector<std::wstring>& getTokenNames() override;
virtual const std::vector<std::wstring>& getRuleNames() override;
virtual std::wstring getGrammarFileName() override;
/// <summary>
/// Begin parsing at startRuleIndex </summary>
virtual ParserRuleContext *parse(int startRuleIndex);
virtual void enterRecursionRule(ParserRuleContext *localctx, int state, int ruleIndex, int precedence) override;
protected:
virtual atn::ATNState *getATNState();
virtual void visitState(atn::ATNState *p);
virtual void visitRuleStopState(atn::ATNState *p);
};
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More