Commit Graph

2832 Commits

Author SHA1 Message Date
Kyle Sletten a7f3efb7eb
Remove unused parameter in `_loadString`
The usage of this method was removed in commit 51edf3cece, but the parameter remained.
2017-12-20 11:39:57 -07:00
parrt 74779f334a tweak comment to be consistent with code. Fixes #2172 2017-12-19 12:33:09 -08:00
Mike Lischke 4c8fd4e4bb Reference can be const. 2017-12-19 15:19:44 +01:00
Mike Lischke 4ea90b5976 Fixes #2175 (mem-leak) 2017-12-19 15:14:03 +01:00
Ajay Panyala 505f672ca1 Remove suggested fix comment 2017-12-17 08:09:55 -08:00
Ajay Panyala 18bdbb5a22 suggest alternative fix 2017-12-16 17:36:06 -08:00
Ajay Panyala 07d7bd1f36 Add missing -std=c++11 flag when using non-appleclang compiler on macosx 2017-12-16 17:20:54 -08:00
Nicolas e7b6521431 Merge branch 'master' into vs2017projects 2017-12-15 19:57:07 +13:00
Nicolas 26d0d3143e Update projects to the static library configurations define
ANTLR4CPP_STATIC rather than ANTLR4CPP_EXPORT.
2017-12-15 19:33:32 +13:00
Nicolas f3f8cb877f Add visual studio 2017 version of cpp runtime projects. 2017-12-15 19:22:28 +13:00
Mike Lischke ceb4ca7ce7 Merge branch 'master-upstream' 2017-12-14 13:26:02 +01:00
Mike Lischke f17319a9a5 Fixed multi-threading issue in C++ runtime.
The shared s0 state in a DFA was deleted when setting a new one (from the DFA entries possibly). That could led to a situation where a valid reference was deleted, even though it's still needed.

Additionally fixed some formattings and updated the XCode projects in the demo.
2017-12-14 13:25:12 +01:00
Jan Lindemann 4e3c5ddffb Make C++ Parser::exitRule() non-virtual
Parser::exitRule() in the C++ runtime is a virtual function which is not
reimplemented anywhere. OTOH, it is invoked during the execution of
every rule, which can cause a noticeable performance hit. This commit
removes its virtual qualifier. It should make a difference particularly
for large grammars, because the number of rules corresponds to the
number of the Parser object's virtual functions, and, consequently, its
vtable lookup time.

Tested with a VHDL grammar of 436 rules, where it brings down parsing
time from 75 to 44 seconds on unoptimized compilation, i.e. a 40% speed
gain.  Still a lot slower than an equivalent java parser, though, which
takes 2.64 seconds for the same input.
2017-12-13 12:07:19 +01:00
Jan Lindemann 2634246b07 Add missing override keyword to virtual functions
Add missing override markers to the following functions of the C++
runtime:

  - TokensStartState::getStateType()
  - TagChunk::toString()
  - TextChunk::toString()

The missing markers made builds against the API with -Wsuggest-override
choke.
2017-12-13 12:04:50 +01:00
enessoylu 0668b53083 update license string 2017-12-13 02:14:57 -05:00
parrt ba47b092e9 update setup.py to use setuptools not distutils (Python 3) 2017-12-10 12:32:52 -08:00
parrt d674274f99 update setup.py to use setuptools not distutils 2017-12-10 12:28:05 -08:00
parrt 17b6277502 [maven-release-plugin] prepare for next development iteration 2017-12-09 12:04:26 -08:00
parrt bdc05c87be [maven-release-plugin] prepare release 4.7.1 2017-12-09 12:04:17 -08:00
Ewan Mellor 35b9bbfe17
[Swift] Minor tidyups in the stream code.
No semantic change.
2017-12-08 16:36:00 -08:00
Ewan Mellor b4f3a619fd
[Swift] Make ATNDeserializationOptions a simple struct.
The previous code was ported from Java, which resulted in 70 lines of code
to hold two bools.  Use a struct instead.
2017-12-08 16:35:21 -08:00
Ewan Mellor f8e63d53c5
[Swift] Remove HashMap and fix Parser caches.
Remove HashMap, and replace all uses of it with dictionaries.  There's
no need for us to have a custom HashMap implementation (mirroring the Java
standard library) when Swift's standard dictionaries work just fine.

Fix Parser.bypassAltsAtnCache.  This was declared as a Parser instance
variable, when in the Java runtime it is static (and therefore the cache
outlives the Parser instances).  It was also being handled in a
thread-unsafe manner, because the cache was being read outside of the
mutex that was supposed to be protecting it.  Fix both issues by moving
the cache and the mutex so that they are static to the Parser module and
rewriting getATNWithBypassAlts.

Remove Parser.decisionToDFAMutex.  The Java code uses a synchronized block
on ParserATNSimulator.decisionToDFA, but the translation to Swift had put
a mutex in Parser.  The decisionToDFA value is shared between Parser,
ParserATNSimulator, and the generated parser, so a mutex in
ParserATNSimulator isn't blocking all possible accesses, so it's useless.
Since this is only code for debugging anyway, just remove the useless mutex
and simplify getDFAStrings and dumpDFA.
2017-12-08 16:32:51 -08:00
parrt 763a1242b7 update version number and tweak doc 2017-12-08 12:47:11 -08:00
Mike Lischke baf8b95b1c Updated XCode project + fixed a gotcha in ATNState::removeTransition. 2017-12-08 09:33:33 +01:00
Terence Parr 7259baaf8a
Merge pull request #2151 from davesisson/hidden-tokens
Export GetHiddenTokens routines
2017-12-07 09:55:05 -08:00
Terence Parr 5987936a86
Merge pull request #2150 from davesisson/trees
Fix issue with tree finding when the underlying slice needs to be resized.
2017-12-07 09:54:52 -08:00
David Sisson a2bfeeb760 update tests too 2017-12-06 11:27:52 -08:00
David Sisson b66cc174b9 Export GetHiddenTokens routines. 2017-12-06 11:25:42 -08:00
David Sisson 1e1e132a91 Fix issue with tree finding when the underlying slice needs to be resized. 2017-12-06 11:22:22 -08:00
David Sisson 2d71d94386 Updated formatting. 2017-12-06 11:04:31 -08:00
David Sisson 7e39515dfe Changed rotation to support 32 and 64-bit architectures as noted in issue #2060. 2017-12-06 11:01:19 -08:00
parrt b9adef5878 set version for C# dotnet to 4.7.1.1 for publishing 2017-12-04 14:12:20 -08:00
Terence Parr b5e6147cd5
Merge pull request #2123 from ewanmellor/swift-fix-parse-cancellation
[Swift] Fix parse-cancellation in BailErrorStrategy.
2017-11-29 09:56:09 -08:00
Terence Parr bd4f1a9365
Merge pull request #2122 from ewanmellor/swift-remove-recognizer-caches
[Swift] Remove Recognizer.tokenTypeMapCache and .ruleIndexMapCache.
2017-11-29 09:55:53 -08:00
Terence Parr 756fcdd5ec
Merge pull request #2121 from ewanmellor/swift-fix-interpreter-dfas
[Swift] Fix initialization of {Lexer,Parser}Interpreter.decisionToDFA.
2017-11-29 09:55:38 -08:00
Terence Parr c586a592ce
Merge pull request #2120 from ewanmellor/swift-remove-arraylist
[Swift] Remove ArrayList.
2017-11-29 09:55:23 -08:00
Terence Parr 406b1816c8
Merge pull request #2119 from ewanmellor/swift-remove-triple
[Swift] Remove Triple.swift.
2017-11-29 09:55:11 -08:00
Terence Parr 633de4aeab
Merge pull request #2118 from ewanmellor/swift-let-sharedcontextcache
[Swift] Make ATNSimulator.sharedContextCache non-optional.
2017-11-29 09:54:52 -08:00
Terence Parr aec23acb24
Merge pull request #2117 from ewanmellor/swift-remove-modeNameToStartState
[Swift] Remove unused ATN.modeNameToStartState.
2017-11-29 09:54:26 -08:00
Terence Parr ed37fa23e6
Merge pull request #2115 from ewanmellor/swift-minor-tidups
[Swift] Some minor tidyups.
2017-11-29 09:54:13 -08:00
Terence Parr 3536a84b52
Merge pull request #2114 from ewanmellor/swift-let-precedencedfa
[Swift] Make DFA.precedenceDfa be a "let" rather than a "var".
2017-11-29 09:53:57 -08:00
Terence Parr aaca1b9f3c
Merge pull request #2113 from ewanmellor/swift-makereadonly
[Swift] Replace IntervalSet.setReadonly with makeReadonly.
2017-11-29 09:53:40 -08:00
Terence Parr 8c1a46d87a
Merge pull request #2112 from ewanmellor/swift-mutexes-let
[Swift] Make all the mutexes "let" rather than "var".
2017-11-29 09:53:11 -08:00
Terence Parr d691f4d086
Merge pull request #2108 from ewanmellor/swift-tidyups-parser
Tidy-ups inside the Swift runtime around ParseTree, ParserRuleContext
2017-11-29 09:52:54 -08:00
Terence Parr 84e9a46932
Merge pull request #2107 from ewanmellor/swift-fix-deprecated-string-methods
Remove use of deprecated String functions
2017-11-29 09:52:27 -08:00
Terence Parr 6bcde64abf
Merge pull request #2106 from ewanmellor/swift-open-error-strategy
Open the error strategies to subclasses.
2017-11-29 09:50:03 -08:00
Terence Parr e11e707a38
Merge pull request #2105 from gendalph/cmake
The correction for cmake depends on the demo
2017-11-29 09:49:38 -08:00
Terence Parr 14880cb3b4
Merge branch 'master' into support_intel_compiler 2017-11-29 09:47:51 -08:00
Terence Parr 9a701ef57f
Merge pull request #2103 from ewanmellor/swift-tidy-atndeserializer
Tidy ATNDeserializer.
2017-11-29 09:47:19 -08:00
Terence Parr 8b86af6654
Merge pull request #2102 from ewanmellor/swift-antlrfilestream-report-errors
Report errors in ANTLRFileStream.
2017-11-29 09:47:04 -08:00
Terence Parr a7af99b17f
Merge pull request #2101 from ewanmellor/swift-fix-uuid-extension
Implement UUID.init(mostSigBits, leastSigBits) in the Swift runtime.
2017-11-29 09:46:29 -08:00
Terence Parr afa2574862
Merge pull request #2100 from ewanmellor/swift-fix-parsetreepatternmatcher
Fix ParseTreePatternMatcher.split in the Swift runtime.
2017-11-29 09:46:03 -08:00
Terence Parr 963d44f930
Merge pull request #2024 from kaedvann/master
[CSharp] #2021 fixes nuget packaging options to avoid missing dll exceptions
2017-11-25 12:17:15 -08:00
zqlu.cn 88a7580b78 Fix interval usage
For JavaScript runtime, Interval class constructor assume start and stop
to be number.
2017-11-24 16:37:40 +08:00
Rostislav Listerenko 9ec6c665d5 #2021 nuget artifact in appveyor 2017-11-13 08:47:15 +03:00
Rostislav Listerenko 5b5f195b12 #2021 fixes nuget packaging options to avoid missing dll exceptions in transitive dependencies 2017-11-12 16:11:12 +03:00
Ewan Mellor eb9124fff8
[Swift] Fix parse-cancellation in BailErrorStrategy.
BailErrorStrategy is supposed to throw an error that's different from
the ordinary recognition error, specifically so that it can be handled
differently by client code.  This was not ported over from Java correctly.

Fix this by moving parseCancellation from ANTLRError to ANTLRException,
adding its RecognitionException argument, and throwing it from the
two handlers in BailErrorStrategy.

Also remove ANTLRException.cannotInvokeStartRule, which is unused.
(The Java runtime uses it when ParseTreePatternMatcher throws a generic
exception, but we don't have that.)
2017-11-11 10:45:38 -08:00
Mike Lischke eaed562cb3 Merge branch 'master' into interpreter2 2017-11-11 11:06:53 +01:00
Ewan Mellor 7cf8ef7bc5
[Swift] Remove ArrayList.
This was only used in some commented-out debugging code.  Swift has
perfectly good array types, we don't need to implement our own.
2017-11-10 18:46:06 -08:00
Ewan Mellor 6cc35ad677
[Swift] Remove pointless do block from LexerATNSimulator.
Remove pointless do block from LexerATNSimulator.  This is a translation
from Java of a try/finally block, but we have the finally clause in a
defer block so we don't need the do block.
2017-11-10 18:12:19 -08:00
Ewan Mellor e2f4cdc68d
[Swift] Some minor tidyups.
Minor tidyups in the Swift runtime.  No semantic change.
2017-11-10 18:12:19 -08:00
Ewan Mellor e77d690e36
Report errors in ANTLRFileStream.
Change the initializer to ANTLRFileStream so that it throws any errors that
occur while reading the file.  Previously, it was just dropping any errors on
the floor (inside Utils.readFile).

Remove Utils.readFile, it's not used anywhere else.
2017-11-10 18:06:12 -08:00
Ewan Mellor 2b00ca06aa
[Swift] Fix initialization of {Lexer,Parser}Interpreter.decisionToDFA.
Fix initialization of {Lexer,Parser}Interpreter.decisionToDFA.  These
were always being created as empty arrays, which would never work.

I don't know if anyone's using this code; presumably not.
2017-11-10 17:52:50 -08:00
Ewan Mellor b2a55d1bec
[Swift] Remove unused ATN.modeNameToStartState.
Remove unused ATN.modeNameToStartState.  In the Java runtime this is
only used by LexerATNFactory (i.e. during lexer generation) and we don't
have the equivalent in the Swift runtime at all.
2017-11-10 16:50:43 -08:00
Ewan Mellor 167a3b8808
[Swift] Remove Recognizer.tokenTypeMapCache and .ruleIndexMapCache.
Remove Recognizer.tokenTypeMapCache and .ruleIndexMapCache.  These
were easily replaced in Swift with lazy vars.  The input to these
two caches are fixed fields on the Recognizer (the Vocabulary and
rule names respectively) so a lazy var suffices.

Note that these differed compared with the Java runtime -- they are
declared as static in Java and therefore the caches are shared across
all recognizer instances, but the Swift runtime had them as Recognizer
instance variables, which meant that at most we had a cache with one
entry which got destroyed along with the parser.  Regardless, using
lazy vars is still simpler.

This removes the only usage of ArrayWrapper in the Swift runtime, so
delete that too.
2017-11-10 16:45:24 -08:00
Ewan Mellor 19c0ecaedf
[Swift] Remove Triple.swift.
This is not in use.  It never has been, as far as I can see.
2017-11-10 15:02:05 -08:00
Ewan Mellor 4baedb5e7b
[Swift] Make ATNSimulator.sharedContextCache non-optional.
Make ATNSimulator.sharedContextCache declared as non-optional.  It
was used this way anyway, so it was just being pointlessly forced
at the use-sites.
2017-11-09 15:12:21 -08:00
Ewan Mellor b548999b16
[Swift] Make DFA.precedenceDfa be a "let" rather than a "var".
Make DFA.precedenceDfa be a "let" rather than a "var", and remove
setPrecedenceDfa.  This field never varies after construction.  The
code in setPrecedenceDfa was carried over from the Java runtime, but
it only threw an exception, and was deprecated.  There's no need for
that in the Swift runtime.
2017-11-09 14:56:39 -08:00
Ewan Mellor afdfb56b59
[Swift] Replace IntervalSet.setReadonly with makeReadonly.
Replace IntervalSet.setReadonly(Bool) with makeReadonly().  This
operation only ever works in one direction, and would throw an exception
if a caller attempted to make a read-only IntervalSet read-write again.
By changing the interface we remove the need to check this, and so we
don't need to declare the exception.  Unlike in the Java runtime, we
need to declare the possibility of the exception at the callsite, so this
was pointlessly cluttering.
2017-11-09 14:49:45 -08:00
Ewan Mellor 06300e82bc
[Swift] Make all the mutexes "let" rather than "var".
Make all the mutexes in the Swift runtime use "let" rather than "var".

They are never changed, and they wouldn't make good mutexes if they were.
2017-11-09 14:44:50 -08:00
Ewan Mellor 00753dd8c9
Simplify ParseTree and ParserRuleContext.
Make ParseTree, RuleNode, and TerminalNode be protocols rather than
classes.  These had no useful functionality (which is not surprising,
since they are interfaces in the Java implementation) so there is
no need for them to be classes.  This reduces the depth of the inheritance
tree.

Add a subscript getter to ParseTree (and corresponding implementations in
the concrete classes).  This has two advantages over Tree.getChild(_: Int):
it can be declared to return ParseTree rather than Tree, and it can fault
on index-out-of-range rather than returning nil.  Note that covariant
specialization of the return type is not supported through protocols in Swift
yet (https://bugs.swift.org/browse/SR-522).  This means that ParseTree
cannot specialize Tree.getChild()'s return type in the way that the Java
implementation does.

Remove the return value from addChild / addErrorNode / addAnyChild.
This kind of chaining where a function returns its parameter does not fit
well with Swift's generics / protocols model.
2017-11-07 17:16:10 -08:00
Ewan Mellor 8c2f80f1c7
Tidy-ups inside the Swift runtime.
Change ParserRuleContext.exception to be RecognitionException?
rather than AnyObject!.  I don't know why it was declared that
way because the Java code uses RecognitionException.

Remove ParserRuleContext.addChild(Token) and addErrorNode(Token).
These are deprecated in the Java code and there was no need to
bring them over to the Swift runtime.

Fix ParserRuleContext.toInfoString, which was mangled when it was
ported from Java.

Various other tidyups: removal of useless type annotations, use of
if let, etc.
2017-11-07 17:14:44 -08:00
Ewan Mellor 5dd835f0a1
Merge branch 'swift-fix-uuid-extension' into swift-fix-deprecated-string-methods 2017-11-07 17:06:20 -08:00
Ewan Mellor ba392be1af
Remove use of deprecated String functions in StringExtension.
Remove some functions that are no longer used, and update the
rest to Swift 4's String API.  lastIndexOf changes to lastIndex(of: ),
matching the standard library naming conventions, and returns a
String.Index? instead of an Int.

Add an implementation of Substring.hasPrefix for Linux; this
is in the Apple standard library but not the Linux one.
https://bugs.swift.org/browse/SR-5627

Add unit tests for StringExtension.

Bump the Swift download for the Travis Linux tests from 4.0
to 4.0.2.  There is a bug in Substring.range(of:) in 4.0.0
(https://bugs.swift.org/browse/SR-5663) that we need to avoid.
2017-11-07 17:06:15 -08:00
Ewan Mellor 15a7b3be24
Rewrite ParseTreePatternMatcher to use standard library
String functions and avoid our custom String extensions.
2017-11-07 17:06:15 -08:00
Ewan Mellor 73d90ec18b
Tidy up some uses of String.characters and integer indexing into Strings.
In Swift 4, Strings have a set of sequence operations that we can use, so
that we don't need our String extensions.  Tidy up a bunch of places where
the code has been converted from Java through Swift 3 and Swift 4, and
become a mess.
2017-11-07 17:06:15 -08:00
Ewan Mellor 775040e186
Remove the toString implementations.
In Swift, we use description for the same thing.  All these just stubbed-over
or replicated the description implementation, except for PredicateTransition
which now implements CustomStringConvertible.
2017-11-07 17:06:15 -08:00
Ewan Mellor 7cfdd9d124
Change TokenStreamRewriter to use an inout String as the execute(buf:)
parameter rather than StringBuilder.

Tidy up the rest of the class on the way through.

This is the last use of StringBuilder, so we can remove that class entirely.
2017-11-07 17:06:15 -08:00
Ewan Mellor 7933999fa6
Remove uses of StringBuilder.
Remove the uses of StringBuilder where it is simply accumulating a String
for us.  In Swift we can use a var String for this; there is no need for
a StringBuilder class like in Java.
2017-11-07 17:06:14 -08:00
Ewan Mellor e2b94c783a
Rewrite RuntimeMetaData.getMajorMinorVersion to use standard library
String functions and avoid our custom String extensions.
2017-11-07 17:06:14 -08:00
Ewan Mellor 08ba9379d8
Added tests for RuntimeMetaData.getMajorMinorVersion. 2017-11-07 17:06:14 -08:00
Ewan Mellor fd8fd175a6
Fix ParseTreePatternMatcher.split in the Swift runtime.
Fix the parsing inside ParseTreePatternMatcher.split.  It was trivially
broken in a number of ways, with bugs that aren't in the Java version
that it was ported from, so it's obviously never been run before.

This adds unit tests for ParseTreePatternMatcher.split, and makes Chunk
implement Equatable, so that it we can compare Chunk instances in the
tests.

Tidy up the description implementations at the same time.
2017-11-07 17:05:22 -08:00
Ewan Mellor 4edb37d136
Open the error strategies to subclasses.
Mark every method in BailErrorStrategy and DefaultErrorStrategy as "open",
so that they can be extended by subclasses in user code.
2017-11-07 17:02:46 -08:00
gendalph e1e6ce5c03 The correction for cmake depends on the demo,
the minimal rebuilding by the generated part.

Only if the grammar files (*.g4) have been changed
2017-11-06 17:53:18 +03:00
Ajay Panyala e8a2fbe524 Support building ANTLR Cpp Runtime with Intel compilers 2017-11-05 13:53:56 -08:00
Ewan Mellor fd58a8c4fd
Tidy ATNDeserializer.
Remove lots of unnecessary type annotations, replace unnecessarily
complicated static initializers, and use "if let" and "guard let" to remove
lots of casting.

Bring together a couple of hundred lines of copy-paste code between
the deserialize and deserializeFromJson paths.

Fix some obvious bugs in the deserialize path.  This code is entirely unused;
we use deserializeFromJson in the autogenerated parsers.  I'm inclined to
remove deserialize since it was so broken, but I'm leaving it for now, in
case someone needs compatibility with ATNs from different language targets
and wants to fix it.
2017-11-04 12:53:17 -07:00
Ewan Mellor f36a1558ca
Implement UUID.init(mostSigBits, leastSigBits).
The implementation here before just tried to make a UUID from the empty
string.

Remove the unused UUID.toUUID.  It was broken too.

Rename the file that this was in, since NSUUID and Foundation.UUID are not
the same thing.
2017-11-04 12:49:29 -07:00
Terence Parr 58ddf07905
Merge pull request #2093 from ewanmellor/swift-lexer-init-required
Make CharStream.init(CharStream) required (in the Swift runtime).
2017-11-04 10:50:51 -07:00
Ewan Mellor afd4e0bc3f
Fix UnbufferedCharStream.
The call to stream.read needs to use buffer.count, not buffer.capacity,
as the maxLength.  Otherwise, some bytes get dropped on the floor and the
stream is corrupted.

Remove the code to pad self.data back to up to its previous capacity when
copying data at the end of release.  This came over from the Java port, but
I don't think it makes sense in Swift, given the copy-on-write Array
value semantics.  Instead, just copy the tail of the buffer if there is
anything left to read (i.e. self.data gets smaller) and when there is nothing
in the buffer to read, reset to the specified bufferSize (i.e. self.data
goes back to the specified self.bufferSize.

Remove debug print statement that was accidentally left in.
2017-10-31 15:14:34 -07:00
Ewan Mellor 5bb93813a0
Make CharStream.init(CharStream) required (in the Swift runtime).
This makes it possible for client code to use CharStream as a generic type
constraint and construct Lexer subclasses generically.
2017-10-31 14:44:43 -07:00
gendalph aa143175c9 Fix destructor 2017-10-30 22:56:57 +03:00
gendalph 1a4f5770dd update CMAKE_POLICY CMP0026 NEW 2017-10-30 22:56:57 +03:00
gendalph 886e6b0ed2 CMake build fixes for Visual Studio
Remove unsupported cmd line options (gcc).
Disable warning for DLL.
2017-10-30 22:56:57 +03:00
Jan Mikkelsen 3041b8e012 Style changes for main antlr4 codebase
- Add "explicit" to Interval(size_t, size_t) constructor.
- Change an IntervalSet constructor to delegate part of the construction

- Add "explicit" to Interval(size_t, size_t) constructor.
- Change an IntervalSet constructor to delegate part of the construction
2017-10-30 07:42:20 +11:00
Jan Mikkelsen 0f6082eb15 Merge https://github.com/antlr/antlr4 2017-10-28 16:08:54 +11:00
Jan Mikkelsen 156ecb6c58 Revert "Remove byte order mark on utf8 files."
This reverts commit b106f8ee08.
2017-10-28 16:00:01 +11:00
Terence Parr 089550df8e
Merge pull request #1990 from milanaleksic/master
Allowing Go runtime compilation to succeed under ARM
2017-10-27 15:54:28 -07:00
Terence Parr 1230aa08ef
Merge branch 'master' into coverity_fixes 2017-10-27 10:44:29 -07:00
Terence Parr bce47ca744 Merge pull request #2076 from ewanmellor/swift-retain-cycles
Fix retain cycles in the Swift runtime
2017-10-27 08:28:14 -07:00
Terence Parr 2bfaec72ee Merge pull request #2075 from ewanmellor/swift-unbufferedcharstream
Implement UnbufferedCharStream in the Swift runtime.
2017-10-27 08:27:45 -07:00
Terence Parr 5f4b9b49da Merge pull request #2074 from ewanmellor/swift-intervalset-exceptions
Tidy up the exception behavior around IntervalSet and ATNConfigSet.
2017-10-27 08:27:09 -07:00
Ewan Mellor bb3f7e2c14
Make it possible for RecognitionException to release the parser and
token stream that triggered the error.

These are useful for error diagnostics, but if client code wants to throw
the RecognitionException but discard the parser and token stream, then
the fields in RecognitionException need to be cleared.

This adds RecognitionException.{clearRecognizer,clearInputStream} so that
client code can clear those fields if desired.  It also makes
RecognitionException.ctx weak, so it will go nil at the same time as
the parser is discarded.
2017-10-25 13:31:43 -07:00
Ewan Mellor cf011b57ee
Fix a retain cycle between a Token and the TokenSource that it came from.
This was causing all the tokens, streams, and lexers to be retained.  The
primary cycle was because of the backreference at CommonToken.source, and
the fact that the token streams buffer the tokens that they create.

Fix this by replacing the use of a (TokenSource?, CharStream?) pair with
TokenSourceAndStream, which does the same job but references its fields
weakly.  This means that Token.getTokenSource() and Token.getInputStream()
will return valid values as long as you retain the lexer / stream elsewhere,
but a Token won't itself retain those things.
2017-10-25 13:31:43 -07:00
Ewan Mellor 555c14956a
Fix retain cycle between Parser and ParserATNSimulator.
This was causing the entire parser to be retained, resulting in a large
memory leak.

This fix simply changes the reference from ParserATNSimulator to Parser
to be unowned.

Ditto between Lexer and LexerATNSimulator, except this reference is made
weak because LexerATNSimulator.recog is nullable.  (That difference is
dubious IMHO, but I'm leaving it intact for now.)
2017-10-25 13:31:43 -07:00
Ewan Mellor d0c9744305
Fix a retain cycle through TerminalNodeImpl.parent.
This refers back up the parse tree, and meant that the
whole tree was leaked.  Fix this by making the parent field weak.
2017-10-25 13:31:43 -07:00
Ewan Mellor 5885d54c25
Fix a retain cycle through RuleContext.parent.
This refers back up the tree of RuleContext instances, and meant that the
whole tree was leaked.  Fix this by making the parent field weak.
2017-10-25 13:31:43 -07:00
Ewan Mellor 64048caf12
Implement UnbufferedCharStream in the Swift runtime.
This is a port of the equivalent code in the Java runtime.

This required a change to the CharStream interface: getText was documented
as throwing exceptions, but it wasn't actually declared as such.  The
UnbufferedCharStream.getText implementation throws exceptions (in order to
match the semantics of the Java implementation), so this declaration is now
needed, and callsites need to be adjusted appropriately.
2017-10-25 13:31:19 -07:00
Ewan Mellor 7dd4017f41
Tidy up the exception behavior around IntervalSet and ATNConfigSet.
These classes throw exceptions if the instance is read-only, and only in
that case.  This means that there is no need for us to propagate exception
declarations in the cases where we have guaranteed by construction
that the instance is writable.  In particular, this means that IntervalSet
and ATNConfigSet's constructors won't throw exceptions(!)  The set options
that return a new set (e.g. complement) no longer throw either.

To help with this, this cset adds BitSet.firstSetBit().  This is equivalent
to BitSet.nextSetBit(0), but is guaranteed not to throw an exception.

As a consequence, ANTLRErrorListener / DiagnosticErrorListener no longer
throw exceptions through any of their functions (syntaxError and report*),
and DefaultErrorStrategy can no longer throw exceptions as part of its
internal operations (though of course it can still throw exceptions if
recovery fails and a real parsing error needs to be reported).
Also, LL1Analyzer no longer throws exceptions at all, and so ATN.nextTokens
doesn't throw either.
2017-10-25 13:30:40 -07:00
Ewan Mellor fbe8c0d2a6
Tidy up the exception handling around RecognitionException.
This removes the generic parameter on RecognitionException, to make it
easier to handle them.  This means that we no longer need to store them as
AnyObject and cast them back again.  To do this, we add RecognizerProtocol,
which is a non-generic equivalent of the Recognizer interface (at least, the
parts of it that we need for error handling).

Remove all paths where the RecognitionException subclasses were throwing
exceptions in their initializers.  This is just insane.
2017-10-25 13:30:08 -07:00
Ewan Mellor 7e03b0857a
Remove Utils.RuntimeException.
This was doing nothing for us that we couldn't already get with fatalError,
so it was just cluttering things.
2017-10-25 13:28:40 -07:00
Ewan Mellor 6c11160b51
Remove tokenNames / getTokenNames from the Recognizer interface.
This has been ported over from the Java code, but it was deprecated there.
There's no point having it in the Swift runtime because we don't have the
legacy code to support.  Also, it wasn't implemented properly, so it
never worked.

Remove {DFA,IntervalSet}.toString(_:[String?]?)
and the inits in ParserInterpreter and DFASerializer for the same reason.
Switch the unit tests to use the alternate toString(_:Vocabulary).
2017-10-25 13:28:40 -07:00
Ewan Mellor 23f532ddbd
Minor tidyups in the Swift runtime.
This fixes some hangovers from the port from Java:
* unnecessary type annotations;
* failure to use "if let" for nil checks;
* comments with Java code in them;
* a couple of fields that should have been declared private;
* some whitespace issues.

No semantic change.
2017-10-25 13:28:40 -07:00
Ewan Mellor f41316f934
Remove some stub functions from ATNSimulator.
These were ported over from the Java runtime, but they were all deprecated
there, and were commented as such here.  There is no point having them in
the Swift runtime because we don't have legacy code to support.
2017-10-25 13:28:40 -07:00
Ewan Mellor 8c03ef3138
Remove unused Utils.{readFile2String,readFile2StringByPath,writeFile}. 2017-10-25 13:28:39 -07:00
Ewan Mellor 5a99f1f7a8
Remove unused generic type parameter on UnbufferedTokenStream. 2017-10-25 13:28:38 -07:00
parrt aaa4250328 Fixes #2069 to catch env var security exception 2017-10-23 14:40:13 -07:00
Mike Lischke 16242e43c0 Merge branch 'master' into interpreter2 2017-10-22 13:48:10 +02:00
Ewan Mellor 70db334a58
Improve MurmurHash in a number of ways:
Use Swift's overflowing operators rather than multipliedReportingOverflow
etc.

Use UInt32 for the hash values.  This matches how MurmurHash3 is generally
defined (e.g. on Wikipedia).

Add support for decoding Strings (UTF-8, then little-endian) and hashing
the resultant UInt32 values.

Add a test set, using test patterns from Ian Boyd (public domain).
2017-10-21 15:23:27 -07:00
Terence Parr 98745bbdf8 Merge branch 'master' into master 2017-10-21 13:18:11 -07:00
Terence Parr b8fd54780a Merge pull request #1974 from matthauck/cmake-windows
Add MSVC support to c++ cmake build
2017-10-21 13:16:23 -07:00
Terence Parr db5a0aeaf2 Merge pull request #1955 from sharwell/fix-closurebusy
Avoid adding to closureBusy before all ATNConfig properties are set
2017-10-21 13:13:48 -07:00
Terence Parr 593b49fa3d Merge pull request #1983 from shirou/master
[Go] Add CommonTokenStream test.
2017-10-21 13:00:02 -07:00
Terence Parr 8a551095dc Merge branch 'master' into export-lexer-methods 2017-10-21 12:58:22 -07:00
Terence Parr 0839970e00 Revert "CMake build fixes for Visual Studio" 2017-10-21 12:55:16 -07:00
Terence Parr fa72e72de0 Merge pull request #2011 from gendalph/master
CMake build fixes for Visual Studio
2017-10-21 12:53:53 -07:00
Hanzhou Shi 0dce38109c Update boot.py and swift-target.md to reflect Swift 4 migration changes. 2017-10-21 12:44:44 -07:00
Terence Parr c9c7561701 Merge pull request #2032 from ewanmellor/swift-4
Migrate the Swift runtime to Swift 4.
2017-10-21 12:26:29 -07:00
Terence Parr 38aaf88097 Revert "[Go] Interval" 2017-10-21 12:00:25 -07:00
Terence Parr 24c149603d Merge pull request #1978 from neatnerd/go-target
[Go] Interval
2017-10-21 09:38:00 -07:00
Terence Parr 1985fede5d Merge pull request #2052 from ewanmellor/swift-remove-nullPointer
Remove ANTLRError.nullPointer from the Swift runtime.
2017-10-21 09:19:54 -07:00
Ewan Mellor 7aa6b544d9
Redo Package.swift for Swift Package Manager 4.0. 2017-10-20 10:12:47 -07:00
Ewan Mellor 8a292c0f4f
Migrate the Swift runtime to Swift 4.
Remove a number of generic type constraints, since these can now
be inferred by the compiler.

Match the syntax change when passing a tuple into a function (adding
an extra set of parens).

Change filterPrecedencePredicates to avoid a now-illegal cast.

Match the renames truncatingBitPattern -> truncatingIfNeeded,
multiplyWithOverflow -> multipliedReportingOverflow, etc.  In
some cases the multiplyWithOverflow calls are replaced by
overflowing operators (e.g. &*) instead.
2017-10-20 10:12:46 -07:00
Ewan Mellor 365d4f40bb
Refactor to avoid forced casts. 2017-10-20 10:12:46 -07:00
Ewan Mellor 4bafc74e6c
Remove unused functions from StringExtension.
Some of these are subject to change for Swift 4, but since they are unused
we should remove them anyway.
2017-10-20 10:12:46 -07:00
Ewan Mellor 8ba2c0ba4f
Add entries to .gitignore for the files that are generated by
Swift Package Manager.
2017-10-20 10:12:46 -07:00
Arshinskiy Mike 5297bf2697 Modified open interval logic
Added tests
2017-10-14 20:31:38 +02:00
Arshinskiy Mike d297c9ddda added initial tests for interval set 2017-10-14 15:15:41 +02:00
Terence Parr 7d2a0978b5 Merge branch 'master' into fix-unicode-2031 2017-10-12 09:38:16 -07:00
Ewan Mellor 5df3b2bbdf
Remove ANTLRError.nullPointer from the Swift runtime.
This was copied from the API of the equivalent code in Java when
the runtime was ported to Swift.  It is meaningless in Swift, and
was unused.
2017-10-12 00:52:44 -07:00
Terence Parr c861e09d39 Merge pull request #1977 from nielsbasjes/EmptyGetText
Fixed empty CodePointCharStream throwing exception on getText.
2017-10-10 12:47:00 -07:00
Terence Parr cb558ccb48 Merge pull request #1954 from kosak/no-attribute-on-enum-class
Remove the useless visibility attribute from this "enum class" declaration
2017-10-10 12:40:31 -07:00
Terence Parr a308cd5d8d Merge branch 'master' into ignore-cmake-policy-0054 2017-10-10 12:36:01 -07:00
Eric Vergnaud 44031b544d fix #2031 2017-09-30 17:07:40 +08:00
Ewan Mellor 99d32dc861
Add some version numbers to pom.xml.
This silences warnings from Maven.
2017-09-28 16:10:26 -07:00
Terence Parr e6d60007e7 Merge pull request #1956 from renatahodovan/syntax-errors
Python: add public getter to parsers to access syntax error count.
2017-09-17 11:20:56 -07:00
Terence Parr f86835928f Merge branch 'master' into master 2017-09-17 11:20:10 -07:00
Terence Parr 8f50bd0df6 Merge branch 'master' into master 2017-09-17 11:17:14 -07:00
Robert Jacobson 8f30ae6610 Import RuleContext into the antlr4 module namespace. See Issue #2012. 2017-09-16 16:16:01 -04:00
gendalph 50d2d3ef55 CMake build fixes for Visual Studio
Remove unsupported cmd line options (gcc).
Disable warning for DLL.
2017-09-12 22:10:59 +03:00
Eddy Reyes 168ac02b22 Export lexer method GetAllTokens 2017-08-29 19:11:36 -05:00
Eddy Reyes 2423359b28 Export Lexer methods
- They can be called in target-specific grammar actions, therefore must
  be exported.
- Their Java analogues are public methods.
2017-08-22 23:37:26 -05:00
Milan Aleksić 3beb771882 Fixed #1858: replacing implicit type with uint
This fix allows compilation and execution under ARM architecture, since default type couldn't handle all possible values
2017-08-21 13:13:37 +02:00
WAKAYAMA Shirou 06f2dfebdf [Go] remove assert lib and re-implement in this package. 2017-08-08 11:03:37 +09:00
WAKAYAMA Shirou bfd7a20e99 [Go] Add CommonTokenStream test.
This test is run by `go test`.
and also add test and testing utils.

Note: `github.com/stretchr/testify/assert` is required.
This assert library is almost same functionality for Java assert.
2017-08-07 20:31:55 +09:00
Jan Martin Mikkelsen 5fd7a6eadb Merge branch 'master' of https://github.com/jm-mikkelsen/antlr4 2017-08-05 15:39:01 +10:00
Jan Martin Mikkelsen b106f8ee08 Remove byte order mark on utf8 files. 2017-08-05 15:38:11 +10:00
Jan Martin Mikkelsen e70e41282c Style changes as requested 2017-08-05 13:46:24 +10:00
Jan Mikkelsen 7d36c5f6b8 Merge https://github.com/antlr/antlr4 2017-08-05 13:14:14 +10:00
Arshinskiy Mike ba75dc9550 Added additional interval math functionality 2017-08-03 01:03:28 +02:00
Niels Basjes ac9f75303e Fixed empty CodePointCharStream throwing exception on getText. Fixes #1949 2017-08-02 14:30:46 +02:00
Terence Parr 590fa8394c Merge pull request #1942 from neatnerd/master
[Go] Implemented TokenStreamRewriter
2017-08-01 15:08:35 -07:00
Terence Parr a0421807db Merge pull request #1969 from sharwell/propagate-error-sets
Report InputMismatchException with original context information
2017-08-01 13:36:10 -07:00
Hanzhou Shi 22caddc12f Autopass for doc conversion. 2017-07-29 23:28:15 -07:00
Hanzhou Shi 82b2480fe5 Tweak HTML comments. 2017-07-29 22:53:44 -07:00
Hanzhou Shi 0137218930 Removing dead code, malformed documentations, etc. 2017-07-29 17:27:33 -07:00
Arshinskiy Mike dced604c7c Corrected Start/Stop spelling 2017-07-29 22:05:46 +02:00
neatnerd c1c069cf5e Merge branch 'master' into master 2017-07-28 23:56:51 +02:00
neatnerd ca9409c7bc Remove duplicate comments 2017-07-28 23:55:40 +02:00
Matt Hauck a2fcad61f0 Differentiate windows static lib suffix to avoid being clobbered
Since the install target install static and shared libs into same
folder, and because on windows a shared lib also outputs a shared
.lib file to link against, need to make sure the static/shared
.lib files do not clobber each other.
2017-07-28 13:12:47 -07:00
Matt Hauck 11d185f744 add some missing flags; fix debug build 2017-07-27 22:08:13 -07:00
Matt Hauck b41782964b Add MSVC support to c++ cmake build 2017-07-27 21:37:09 -07:00
Matt Hauck 95338f710e Ignore Cmake policy CMP0054 2017-07-27 20:54:59 -07:00
Sam Harwell 0803c74eb2 Report InputMismatchException with original context information
Fixes #1922
2017-07-27 18:34:13 -05:00
WAKAYAMA Shirou 1b11cbed18 Merge remote-tracking branch 'upstream/master' 2017-07-27 21:52:12 +09:00
Venkat Peri e01af374d2 'requires' SUPERclass for Lexers in split mode, symbols/modes/channels available on Lexer prototype for use in lexer actions (this.SOME_MODE) like in Java actions, Utils.escapeWhiteSpace uses regex for global replace (was replacing only first occurnce of \n etc). 2017-07-22 18:11:37 -04:00
Mike Lischke 8149ff77fa Consequently use static_cast for (s)size_t casts.
Also fixed XCode tests.
2017-07-19 10:43:36 +02:00
Renata Hodovan 6e02088e6a Python: add public getter to parsers to access syntax error count.
ANTLR parsers in Java are allowed to access the number of encountered
syntax errors via the getNumberOfSyntaxErrors method. However, the
Python variants must use the protected _syntaxErrors member to get this
value. The patch defines the same getter for Python targets too.
2017-07-18 18:29:36 +02:00
Sam Harwell c8805ab584 Avoid adding to closureBusy before all ATNConfig properties are set
Setting ATNConfig properties can change the hash code of the instance, leading
to cases where the closureBusy set places objects in the wrong buckets. While
this has not led to known cases of stack overflow, it has led to cases where
one or more buckets contains a large number of duplicate objects, and the set's
add operation goes from O(1) to O(n).
2017-07-18 07:27:36 -05:00
Corey Kosak 2bce3a74d4 Remove the useless visibility attribute from this "enum class" declaration.
When compiling under gcc, ANTLR4CPP_PUBLIC macro expands to the following
gcc visibility attribute:
 __attribute__((visibility ("default")))

(when compiling under Windows it expands to the corresponding __declspec
attribute)

This change was introduced in commit 8ff852640a

Although the attribute makes perfect sense when applied to a "class"
declaration, it makes no sense (has no effect) when applied to an
"enum class" declaration. I assume that doing so was unintentional; that
when the change was introduced it was it was added mechanically to all
"class XXX" instances in the source code, a process which accidentally
picked up one "enum class XXX" instance.

Although it has no effect on the object code, it leads to the following
warning when compiling under gcc:
/usr/local/include/antlr4-runtime/atn/PredictionMode.h:18:31: error: type attributes ignored after type is already defined [-Werror=attributes]
   enum class ANTLR4CPP_PUBLIC PredictionMode {

This is a problem for people who would like their builds to be warning-free.

Happily, this declaration can be safely removed. The "enum class" construct
(just like with regular enum) does not cause any linker symbols to be
emitted. So having a linker attribute on the type does not actually have any
effect. It can therefore be safely removed.
2017-07-17 17:54:17 -04:00
vaibhavaingankar09 8b3da13259 fix to the ATN deserialiser issue on big endian architecture 2017-07-17 06:45:29 +00:00
Maurice van der Pot 162e2657b8 Fix two issues found by coverity 2017-07-15 17:20:59 +02:00
WAKAYAMA Shirou b36044108a [Go] Expose Start and Stop of Interval. 2017-07-10 09:51:07 +09:00
Arshinskiy Mike 1ce5f91573 [Go] Implemented TokenStreamRewriter
TokenStreamRewriter implementation was missing
Ported code from Java version; however, there are couple of deviations due to difference between composition (Go) and inheritance (Java) concepts
Ported tests from Swift for LexerA
2017-07-09 09:39:46 +02:00
WAKAYAMA Shirou 1054e658b2 [Go] change Interval.contains to public instead of add wrapper function. 2017-07-07 14:41:01 +09:00
WAKAYAMA Shirou 749fa81993 [Go] Add exported getter method to Interval. 2017-07-07 13:14:16 +09:00
Mike Lischke 6319d62409 Don't create VS 2013 packages anymore by default.
Can be enabled on demand.
2017-07-02 14:31:01 +02:00
Mike Lischke b7060ba1f5 Visual Studio build fixes for previous C++ patch.
VS 2013 doesn't accept certain C++11 constants like std::numeric_limits, so we have to return to the code used before that mentioned patch.
2017-07-02 14:29:54 +02:00
Mike Lischke f33fca6789 XCode build fixes for previous C++ patch. 2017-07-01 19:30:02 +02:00
Mike Lischke aa2d34bdfd Merge branch 'master' into interpreter2 2017-06-30 13:44:11 +02:00
Jan Martin Mikkelsen d4b18697f2 Fix unsafe usage on _edgeLock
Iterators on an unordered_map were being dereferenced after dropping a
read lock, leading to races where iterators could be invalidated before
they were used.
2017-06-30 10:47:43 +10:00
Jan Martin Mikkelsen d7f5e1834b Rework C++ Interval, IntervalSet, ATN and ATNState
- Remove the readonly status from IntervalSet.
- Remove virtual functions from IntervalSet and Interval. These are
  passed by value throughout the C++ runtime; meaningful inheritance is
  not possible anyway.
- Moving the atomic flag into ATNState as a "now cached" flag.
- Return a const reference from ATN::nextStates(ATNState*) so the readonly
  status is enforced by the compiler not at runtime in the code.
- Use value semantics using std::move to reduce the number of copies performed,
  constent with how these classes are used in the C++ runtime source.
- Remove type-unsafe varargs constructor in IntervalSet, replace with
  type-safe varadic templates implementation.
2017-06-27 11:04:50 +10:00
Jan Martin Mikkelsen 0c4473ea1a Merge https://github.com/antlr/antlr4 2017-06-26 17:22:44 +10:00
alimg 60cce436c2 Merge branch 'master' of https://github.com/antlr/antlr4 into py-input-mismatch-error 2017-06-25 19:02:26 +03:00
Terence Parr 645855a65a Merge pull request #1926 from ericvergnaud/fix-unicode-lexer
Fix #1925
2017-06-25 08:38:10 -07:00
Eric Vergnaud c3b742e090 also fix in go 2017-06-25 14:49:21 +08:00
Eric Vergnaud 0166ba95ac fix JavaScript too 2017-06-25 13:44:24 +08:00
Eric Vergnaud ff4ffa613b Fix ATN deserialisation for unicode chars FFFE and FFFF 2017-06-25 12:05:57 +08:00
alimg f0d1a093ed Python: fix reported input alternatives are not in par with Java version 2017-06-19 18:55:48 +03:00
Daniel Katz 952b971728 Update .Net NuGet package name to 4.7 with .NET Core target 2017-06-14 11:22:47 +03:00
Jan Martin Mikkelsen fdcfefa0a9 Convention: Change virtual dtor to empty bodies 2017-06-12 20:26:17 +10:00
Jan Martin Mikkelsen fad048897e SemanticContext::Operator: explicit virtual dtor 2017-06-12 19:44:34 +10:00
Jan Martin Mikkelsen 63fc7cb7a7 LexerActionType.h: Use antlr4-common.h for size_t 2017-06-12 19:42:04 +10:00
Jan Martin Mikkelsen aab2c043f0 Fix missed curly brace convention fix. 2017-06-12 11:26:06 +10:00
Jan Martin Mikkelsen 8c45d71673 Undo remove cast to same type in generated code 2017-06-12 11:13:42 +10:00
Jan Martin Mikkelsen 577b1d61bb Comply with curly brace conventions. 2017-06-12 11:10:32 +10:00
Jan Martin Mikkelsen 8fd4bcfa33 Add defined() before #if SYM > val evaluations
- Change "#if SYM > x" to "#if defined(SYM) && SYM > x" as a pattern. In
  StringUtils.h this follows the pattern used earlier in the file.
2017-06-12 10:46:29 +10:00
Jan Martin Mikkelsen 274e3c2d3b Change Lexer::{MORE,SKIP} def back to negative
- Explicitly cast negative values to size_t instead of using an offset
  from std::numeric_limts<size_t>::max().
2017-06-12 10:44:30 +10:00
Jan Martin Mikkelsen 6e46b168f5 Naming convention fix for qualifing shadowed args
- Change qualifying suffix from "_in" to "_" to confirm with
  conventions.
2017-06-12 10:23:47 +10:00
Jan Martin Mikkelsen dde893d365 Merge https://github.com/antlr/antlr4 2017-06-12 10:07:55 +10:00
Terence Parr e9155ef9cb Merge pull request #1908 from mike-lischke/master-build-fix
[C++] Build fix/correction for UTF32 conversion.
2017-06-11 08:54:46 -07:00
Terence Parr 35cf1ba4ff Merge pull request #1907 from mike-lischke/optimizations
[C++] Small optimizations
2017-06-11 08:54:21 -07:00
Mike Lischke ef49f61819 Formatting 2017-06-11 13:31:33 +02:00
Jan Martin Mikkelsen 70402f8eff ATN: Remove race condition in addState(ATNState*)
This is a proposed fix to bug #1826 which removes a race condition where
multiple threads could update ATNState::nextTokenWithinRule, leading to
corrupted std::vector instances in an InstanceSet.
2017-06-11 11:23:33 +10:00
Jan Martin Mikkelsen 4a359c1831 ATN: Handle empty, read-only, nextTokenWithinRule
ATN::nextTokens(ATNState* s) updates s->nextTokenWithinRule if the
IntervalSet is empty, and then sets it to be read only. However, if the
updated IntervalSet value was also empty, it becomes a read-only empty
set, causing an exception on a second call on the same state.

This was exposed a change I made to make IntervalSet::operator=()
respect the _readonly flag. (Which in turn was found by compiling with a
high warningly level.)

The approach in this update is to perform the update if the updated
value is not empty or if the current value is not read only. This
preserves the previous behaviour of creating a read-only empty set and
working on subsequent calls. It will throw on an attempt to update a
read-only value, where previously the read-only value would be silently
discarded and set to updatable.
2017-06-11 09:53:47 +10:00
Jan Martin Mikkelsen eb02a05efb Possible fix for max_align_t breakage in Travis CI
The Travis CI build is failing after an include of <cstddef> -- This is
an attempt to work around that by including <stddef.h> instead. Problem
not apparent in my FreeBSD environment.
2017-06-10 19:56:31 +10:00
Jan Martin Mikkelsen 2d011c8e3a Remove C++14 auto return type on utf8_to_utf32
- Also remove static instance of std::wstring_convert. Access to
  std::wstring_convert<>::{from,to}_bytes() is not guaranteed to be thread
  safe.
2017-06-10 18:46:46 +10:00
Jan Martin Mikkelsen 092afb283e C++ runtime changes for high warning levels
These changes are for compiling with high warning levels and -Werror.
There are no functional changes in this commit. Compiled with gcc 5.4
and clang 3.8.

Summary:

- Put virtual destructors into the appropriate .cpp file instead
  of the inline version in the header to avoid many vtables.
- Change C-style casts to modern C++ casts.
- Add explicit casts in some signed to/from unsigned conversions.
- Remove unreached code in BufferedTokenStream.cpp and
  LexerATNSimulator.cpp.
- Remove shadowed variables by qualifying constructor arguments with
  the name name as a member variable.
- Add explicitly defined copy constructors and assignment operators
  where required by gcc's -Weff-c++.
- Use std::numeric_limits<size_t>::max() instead of assigning a negative
  number.
- Remove semi-colons after function definitions.
- Remove unneccessary casts.
- In preprocessor statements "#if label > value" change to
  "#if defined(label) && label > value" to avoid warnings about the
  undefined symbol being seen as zero.
- Remove ANTLR4CPP_PUBLIC from "enum class" definitions.
- Change the FinalAction move constructor to move instead of copy the
  _cleanUp std::function object. (A side-effect of explicitly
  initialising member variables as required by gcc's -Weff-c++. I turned
  this one off because most constructors needed to be touched,
  especially the classes implemented with InitializeInstanceFields()).
- Mark hex digit conversion functions as file static in guid.cpp.
2017-06-10 17:29:25 +10:00
Jan Martin Mikkelsen 9845382e86 Implement IntervalSet::operator=() using the same semantics as the copy
constructor, put the destructor into the .cpp file so the vtable doesn't
get generated everywhere.
2017-06-10 16:47:01 +10:00
Mike Lischke cec714f745 Corrections for VS 2015. 2017-06-04 14:26:55 +02:00
Mike Lischke 19f584da05 Fixed build after UTF32 string convesion patch.
Also made converter local vars in conversion routines, instead of static global vars.
2017-06-04 12:24:06 +02:00
Mike Lischke 4fdcff6f05 Merge branch 'master-upstream' 2017-06-04 12:13:56 +02:00
Hanzhou Shi 4c0bbfd768 Marking Mutex.synchronized with rethrow. 2017-06-03 22:57:22 -07:00
Hanzhou Shi 53b83d7184 Refactored synchronization by using mutex. 2017-06-03 22:57:22 -07:00
Hanzhou Shi 13769268c9 fixing string issue. 2017-06-03 22:57:21 -07:00
Hanzhou Shi a64ec12e73 fixing tests, and some cleanups. 2017-06-03 22:57:21 -07:00
Hanzhou Shi a879297bb5 swift build & swift test support Linux platform 2017-06-03 22:57:21 -07:00
Hanzhou Shi d66f89db52 Removed xcworkspace. 2017-06-03 22:57:20 -07:00
Hanzhou Shi 67f683d0ac Adding generation of dyanmically linked lib. 2017-06-03 22:57:20 -07:00
Mike Lischke 47d639e7b7 Merge branch 'master-upstream' 2017-06-01 09:04:43 +02:00
lys0716 22034daf25 Typo in the comments of IntStream.java
An extra word is in the comments.

Signed-off-by: Yishuang Lu luyscmu@gmail.com
2017-05-31 21:17:29 -07:00
Terence Parr fd5efc250d Merge pull request #1891 from kosak/master
Make ParseTreeWalker::DEFAULT provide an IterativeParseTreeWalker
2017-05-31 10:22:19 -07:00
Terence Parr 053c594fec Merge pull request #1886 from ericvergnaud/nuget-version
Set version to 4.7.1 because 4.7.0 already exists on Nuget
2017-05-31 10:21:49 -07:00
Terence Parr 7ce775dcaa Merge pull request #1862 from hanjoes/swift-py-script
Supporting Script for Swift Runtime
2017-05-31 10:19:19 -07:00
Terence Parr 745c88a7c9 Merge pull request #1830 from mike-lischke/issue1827
Channel parameter in c-tor is now a size_t - fixes #1827.
2017-05-31 10:16:10 -07:00
Terence Parr 2c4a55c10a Merge pull request #1849 from shravanrn/master
Fix the utf8 convertor for VS2017
2017-05-31 08:01:31 -07:00
Corey Kosak 381fddebd5 Make ParseTreeWalker::DEFAULT provide an IterativeParseTreeWalker
as intended.

The existing code intended for ParseTreeWalker::DEFAULT to provide a
IterativeParseTreeWalker. However, the implementation initialized
ParseTreeWalker::DEFAULT by doing a (value) copy of an
IterativeParseTreeWalker, which sliced the object and therefore,
unfortunately, transformed it back into a regular ParseTreeWalker.

This change implements the desired behavior. Furthermore by making DEFAULT
a reference, we are able to preserve the interface to existing code.
2017-05-29 22:21:01 -04:00
Eric Vergnaud 44ab88c6f9 Set version to 4.7.1 because 4.7.0 already exists on Nuget 2017-05-28 20:47:58 +08:00
Will Fuqua e39543a257 add build script and update docs 2017-05-27 00:02:54 +07:00
Will Fuqua e88eba13fb add dotnetcore dll to nuspec
as part of this, add OutputPath to the csproj so it matches the mono csproj OutputPath
2017-05-26 23:12:47 +07:00
Shravan Narayan 9220df2e37 Merge branch 'master' into master 2017-05-15 16:58:55 -07:00
shravanrn@gmail.com de6f04be0b Fix the utf8 convertor in VS2017 2017-05-15 16:53:05 -07:00
Terence Parr f2ee752a58 Merge pull request #1848 from davesisson/master
Fix tests for PR #1844.
2017-05-12 09:18:46 -07:00
Terence Parr c1663e7c0f Merge pull request #1845 from xied75/dotnetcore
[dotnet] speed up tests; rename runtime dll ready for nuget
2017-05-12 08:00:38 -07:00
Jim Allman 892aa4a376 Fix other calls to InputStream constructor. 2017-05-11 17:08:24 -04:00
Jim Allman 5e648f0867 Add `new` keyword to return proper InputStreams
Currently the JS runtime sometimes returns (and mangles) the global
`window` object instead of a proper InputStream. This is prevented by
using the `new` keyword in all cases.
2017-05-11 16:27:42 -04:00
Hanzhou Shi 834f1ede27 Find antlr4 runtime instead of hardcoding. 2017-05-09 21:31:32 -07:00
Hanzhou Shi c53bd27734 Get rid of xcodeproj file. 2017-05-08 22:37:21 -07:00
Hanzhou Shi 55f9c06509 Now can generate xcode project. 2017-05-08 22:36:29 -07:00
Hanzhou Shi 9f41e6fd9d Adding support for generating local ANTLR Swift repo. 2017-05-08 22:28:46 -07:00
Hanzhou Shi d5f37015ab Adding more commands and comments. 2017-05-07 22:48:36 -07:00