forked from jasder/antlr
Merge branch 'master_upstream'
This commit is contained in:
commit
189d390481
|
@ -127,3 +127,5 @@ YYYY/MM/DD, github id, Full name, email
|
|||
2016/12/01, samtatasurya, Samuel Tatasurya, xemradiant@gmail.com
|
||||
2016/12/03, redxdev, Samuel Bloomberg, sam@redxdev.com
|
||||
2016/12/11, Gaulouis, Gaulouis, gaulouis.com@gmail.com
|
||||
2016/12/22, akosthekiss, Akos Kiss, akiss@inf.u-szeged.hu
|
||||
2016/12/24, adrpo, Adrian Pop, adrian.pop@liu.se
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/runtime/src
|
||||
${PROJECT_SOURCE_DIR}/runtime/src/atn
|
||||
|
@ -50,6 +51,12 @@ elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
|||
set(disabled_compile_warnings "${disabled_compile_warnings} -Wno-multichar")
|
||||
endif()
|
||||
|
||||
set(extra_share_compile_flags "")
|
||||
set(extra_static_compile_flags "")
|
||||
if (WIN32)
|
||||
set(extra_share_compile_flags "-DANTLR4CPP_EXPORTS")
|
||||
set(extra_static_compile_flags "-DANTLR4CPP_STATIC")
|
||||
endif(WIN32)
|
||||
|
||||
set_target_properties(antlr4_shared
|
||||
PROPERTIES VERSION ${ANTLR_VERSION}
|
||||
|
@ -59,14 +66,15 @@ set_target_properties(antlr4_shared
|
|||
# TODO: test in windows. DLL is treated as runtime.
|
||||
# see https://cmake.org/cmake/help/v3.0/prop_tgt/LIBRARY_OUTPUT_DIRECTORY.html
|
||||
RUNTIME_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
|
||||
COMPILE_FLAGS "${disabled_compile_warnings}")
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
|
||||
COMPILE_FLAGS "${disabled_compile_warnings} ${extra_share_compile_flags}")
|
||||
|
||||
set_target_properties(antlr4_static
|
||||
PROPERTIES VERSION ${ANTLR_VERSION}
|
||||
SOVERSION ${ANTLR_VERSION}
|
||||
OUTPUT_NAME antlr4-runtime
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
|
||||
COMPILE_FLAGS "${disabled_compile_warnings}")
|
||||
COMPILE_FLAGS "${disabled_compile_warnings} ${extra_static_compile_flags}")
|
||||
|
||||
install(TARGETS antlr4_shared
|
||||
DESTINATION lib)
|
||||
|
|
|
@ -20,7 +20,7 @@ void ANTLRFileStream::loadFromFile(const std::string &fileName) {
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
std::ifstream stream(antlrcpp::s2ws(fileName), std::ios::binary);
|
||||
#else
|
||||
std::ifstream stream(fileName, std::ios::binary);
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace antlr4 {
|
|||
/// <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.
|
||||
/// or EOF.
|
||||
/// </summary>
|
||||
virtual std::vector<Token *> getHiddenTokensToRight(size_t tokenIndex);
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
// Defines for the Guid class and other platform dependent stuff.
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable: 4250) // Class inherits by dominance.
|
||||
#pragma warning (disable: 4512) // assignment operator could not be generated
|
||||
|
||||
|
@ -43,6 +44,7 @@
|
|||
// Before VS 2015 code like "while (true)" will create a (useless) warning in level 4.
|
||||
#pragma warning (disable: 4127) // conditional expression is constant
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define GUID_WINDOWS
|
||||
|
||||
|
@ -69,7 +71,9 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
class ANTLR4CPP_PUBLIC std::exception; // Needed for VS 2015.
|
||||
#endif
|
||||
|
||||
#elif __APPLE__
|
||||
#define GUID_CFUUID
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "antlr4-common.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4521) // 'antlrcpp::Any': multiple copy constructors specified
|
||||
#endif
|
||||
|
@ -139,6 +139,6 @@ private:
|
|||
|
||||
} // namespace antlrcpp
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
var ATNInvalidAltNumber int
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import "fmt"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
var ATNDeserializationOptionsdefaultOptions = &ATNDeserializationOptions{true, false, false}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
var ATNSimulatorError = NewDFAState(0x7FFFFFFF, NewBaseATNConfigSet(false))
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import "strconv"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
// Represent the type of recognizer an ATN applies to.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
type CharStream interface {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
// TokenFactory creates CommonToken objects.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import "sort"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
// The root of the ANTLR exception hierarchy. In general, ANTLR tracks just
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
type InputStream struct {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
type IntStream interface {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import "strconv"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
// Represents an executor for a sequence of lexer actions which traversed during
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
type LL1Analyzer struct {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
// A rule context is a record of a single rule invocation. It knows
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
type TokenSource interface {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
type TokenStream interface {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import "fmt"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
// The basic notion of a tree has a parent, a payload, and a list of children.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import "fmt"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Use of this file is governed by the BSD 3-clause license that
|
||||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package antlr
|
||||
|
||||
import (
|
||||
|
|
|
@ -372,7 +372,7 @@ public class BufferedTokenStream implements TokenStream {
|
|||
|
||||
/** 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.
|
||||
* or EOF.
|
||||
*/
|
||||
public List<Token> getHiddenTokensToRight(int tokenIndex) {
|
||||
return getHiddenTokensToRight(tokenIndex, -1);
|
||||
|
|
|
@ -164,7 +164,7 @@ class IntervalSet(object):
|
|||
# split existing range
|
||||
elif v<i.stop-1:
|
||||
x = Interval(i.start, v)
|
||||
self.intervals[k] = range(v + 1, i.stop)
|
||||
self.intervals[k] = Interval(v + 1, i.stop)
|
||||
self.intervals.insert(k, x)
|
||||
return
|
||||
k += 1
|
||||
|
|
|
@ -59,12 +59,12 @@ class ListTokenSource(TokenSource):
|
|||
# have to calculate the result from the line/column of the previous
|
||||
# token, along with the text of the token.
|
||||
lastToken = self.tokens[len(self.tokens) - 1]
|
||||
tokenText = lastToken.getText()
|
||||
tokenText = lastToken.text
|
||||
if tokenText is not None:
|
||||
lastNewLine = tokenText.rfind('\n')
|
||||
if lastNewLine >= 0:
|
||||
return len(tokenText) - lastNewLine - 1
|
||||
return lastToken.column + lastToken.stopIndex - lastToken.startIndex + 1
|
||||
return lastToken.column + lastToken.stop - lastToken.start + 1
|
||||
|
||||
# only reach this if tokens is empty, meaning EOF occurs at the first
|
||||
# position in the input
|
||||
|
@ -78,7 +78,7 @@ class ListTokenSource(TokenSource):
|
|||
if self.eofToken is None:
|
||||
start = -1
|
||||
if len(self.tokens) > 0:
|
||||
previousStop = self.tokens[len(self.tokens) - 1].stopIndex
|
||||
previousStop = self.tokens[len(self.tokens) - 1].stop
|
||||
if previousStop != -1:
|
||||
start = previousStop + 1
|
||||
stop = max(-1, start - 1)
|
||||
|
|
|
@ -59,12 +59,12 @@ class ListTokenSource(TokenSource):
|
|||
# have to calculate the result from the line/column of the previous
|
||||
# token, along with the text of the token.
|
||||
lastToken = self.tokens[len(self.tokens) - 1]
|
||||
tokenText = lastToken.getText()
|
||||
tokenText = lastToken.text
|
||||
if tokenText is not None:
|
||||
lastNewLine = tokenText.rfind('\n')
|
||||
if lastNewLine >= 0:
|
||||
return len(tokenText) - lastNewLine - 1
|
||||
return lastToken.column + lastToken.stopIndex - lastToken.startIndex + 1
|
||||
return lastToken.column + lastToken.stop - lastToken.start + 1
|
||||
|
||||
# only reach this if tokens is empty, meaning EOF occurs at the first
|
||||
# position in the input
|
||||
|
@ -78,7 +78,7 @@ class ListTokenSource(TokenSource):
|
|||
if self.eofToken is None:
|
||||
start = -1
|
||||
if len(self.tokens) > 0:
|
||||
previousStop = self.tokens[len(self.tokens) - 1].stopIndex
|
||||
previousStop = self.tokens[len(self.tokens) - 1].stop
|
||||
if previousStop != -1:
|
||||
start = previousStop + 1
|
||||
stop = max(-1, start - 1)
|
||||
|
|
|
@ -402,7 +402,7 @@ public class BufferedTokenStream: TokenStream {
|
|||
|
||||
/** 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.
|
||||
* or EOF.
|
||||
*/
|
||||
public func getHiddenTokensToRight(_ tokenIndex: Int) throws -> Array<Token>? {
|
||||
return try getHiddenTokensToRight(tokenIndex, -1)
|
||||
|
|
|
@ -400,7 +400,7 @@ public class OutputModelController {
|
|||
public List<SrcOp> wildcard(GrammarAST ast, GrammarAST labelAST) {
|
||||
List<SrcOp> ops = delegate.wildcard(ast, labelAST);
|
||||
for (CodeGeneratorExtension ext : extensions) {
|
||||
ops = ext.set(ops);
|
||||
ops = ext.wildcard(ops);
|
||||
}
|
||||
return ops;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.antlr.v4.codegen.model.SemPred;
|
|||
import org.antlr.v4.codegen.model.SrcOp;
|
||||
import org.antlr.v4.codegen.model.StarBlock;
|
||||
import org.antlr.v4.codegen.model.TestSetInline;
|
||||
import org.antlr.v4.codegen.model.Wildcard;
|
||||
import org.antlr.v4.codegen.model.decl.Decl;
|
||||
import org.antlr.v4.codegen.model.decl.RuleContextDecl;
|
||||
import org.antlr.v4.codegen.model.decl.TokenDecl;
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
package org.antlr.v4.codegen;
|
||||
package org.antlr.v4.codegen.model;
|
||||
|
||||
import org.antlr.v4.codegen.model.MatchToken;
|
||||
import org.antlr.v4.codegen.OutputModelFactory;
|
||||
import org.antlr.v4.tool.ast.GrammarAST;
|
||||
|
||||
public class Wildcard extends MatchToken {
|
Loading…
Reference in New Issue