Commit Graph

6675 Commits

Author SHA1 Message Date
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
Terence Parr d8996c74e3
Merge pull request #1930 from jm-mikkelsen/master
Rework C++ Runtime Interval, IntervalSet, ATN and ATNState
2017-10-29 15:57:06 -07: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
Terence Parr 6693ba73a5
Merge pull request #2083 from gendalph/master
Updating contributors file.
2017-10-29 09:18:08 -07:00
gendalph bd5620381c Updating contributors file. 2017-10-29 12:33:36 +03: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 1f8c5bdf6a
Merge pull request #1951 from Griffon26/coverity_fixes
C++ runtime: Fix two issues found by coverity
2017-10-27 10:45:26 -07:00
Terence Parr 5008c32084
Merge branch 'master' into coverity_fixes 2017-10-27 10:45:18 -07:00
Terence Parr 1230aa08ef
Merge branch 'master' into coverity_fixes 2017-10-27 10:44:29 -07:00
Maurice van der Pot 73c17ffbd2 Updated contributors.txt 2017-10-27 19:42:26 +02:00
Terence Parr 0ff8c60a1f Merge pull request #2068 from JavaDDD/patch-2
getting-started.md
2017-10-27 08:29:26 -07:00
Terence Parr 2c3f0c9f0c Merge pull request #2067 from JavaDDD/patch-1
Update getting-started.md
2017-10-27 08:28:56 -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
Terence Parr 20baa32b5a Merge pull request #2073 from ewanmellor/swift-RecognitionException-remove-generic
Tidy up the exception handling around RecognitionException.
2017-10-27 08:26:47 -07:00
Terence Parr 82854da434 Merge pull request #2072 from ewanmellor/swift-tidyups
Tidyups inside the Swift runtime
2017-10-27 08:26:03 -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
Terence Parr d248d386e3 Merge pull request #2077 from ewanmellor/fix-appveyor
Fix the AppVeyor tests.
2017-10-25 13:16:45 -07:00
Ewan Mellor e90662ba10
Fix the AppVeyor tests.
For some reason, possibly the new images that AppVeyor rolled out on Oct 22,
our AppVeyor tests now fail immediately, with msbuild complaining that there
are multiple solutions in the repository.

Address this by not using the default AppVeyor build section, but calling
msbuild ourselves explicitly in the build_script section.  This way, we can
specify which .slns we want to build.  I have specified the runtime and
runtime-testsuite Antlr4.vs2013.slns; the other ones didn't work for me in
this configuration.

Also, these builds were previously running with low / zero logging.  As
far as I can tell, this gave AppVeyor no way to know whether the build has
succeeded or not.  It certainly gives no way to diagnose any failures that do
occur.  I have dialed the logging up on everything.

Also, remove the os declaration.  That appears to be well out of date, and
isn't on AppVeyor's list of images any more.  I presume that we've been
using their default image for some time.
2017-10-25 12:03:32 -07:00
Terence Parr d432f94d3b Merge pull request #2070 from parrt/fix-2069
Fixes #2069 to catch env var security exception
2017-10-23 14:43:21 -07:00
parrt aaa4250328 Fixes #2069 to catch env var security exception 2017-10-23 14:40:13 -07:00
Terence Parr babf0bfa16 Merge pull request #2033 from ewanmellor/improve-murmurhash
Improve MurmurHash
2017-10-23 09:25:38 -07:00
JavaDDD 222e762c10 getting-started.md
Introduction to install on Unix based systems version mismatch.
2017-10-23 18:26:55 +03:30
JavaDDD d00b7333d8 Update getting-started.md
Introduction to install on Unix based systems version mismatch.
2017-10-23 18:15:47 +03:30
Terence Parr 0bd748d8f1 Merge pull request #1917 from rlfnb/master
added SVG export of parse tree
2017-10-22 08:52:30 -07:00
rlfnb 639a6995f1 added SVG export to the TestRig 2017-10-22 15:48:54 +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 5fe98b17fd Merge pull request #1996 from ereyes01/export-lexer-methods
Export Go lexer methods
2017-10-21 12:58:31 -07:00