Commit Graph

6859 Commits

Author SHA1 Message Date
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
Mike Lischke 16242e43c0 Merge branch 'master' into interpreter2 2017-10-22 13:48:10 +02:00
Mike Lischke 593da3df5e Reapplied changes that got lost during merge. 2017-10-22 12:27:49 +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
Terence Parr 8a551095dc Merge branch 'master' into export-lexer-methods 2017-10-21 12:58:22 -07:00
Terence Parr eacbe23ea1 Merge pull request #2064 from antlr/revert-2011-master
Revert "CMake build fixes for Visual Studio"
2017-10-21 12:55:31 -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
Terence Parr f8ae3e8cad Merge pull request #2063 from hanjoes/hanjoes-updates
Update boot.py and swift-target.md to reflect Swift 4 migration changes.
2017-10-21 12:47:24 -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 ae0f139dc4 Merge pull request #2062 from antlr/revert-1978-go-target
Revert "[Go] Interval"
2017-10-21 12:00:48 -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 daecc851d6 Merge pull request #2055 from ewanmellor/appveyor-version-4.7.1
Update AppVeyor version number to 4.7.1-SNAPSHOT.
2017-10-21 09:20:56 -07:00
Terence Parr 33066e2ab1 Merge pull request #2058 from simkimsia/patch-1
Change all mentions of 4.5.3 in getting-started to 4.7
2017-10-21 09:20:27 -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 897b4339a3
Switch the Linux Swift tests to Trusty and Swift 4.0.
This uses Travis's new(ish) Ubuntu Trusty image, and changes the
version number of the Swift binaries that we download.

We now install clang-3.6.  This is not the default on Trusty, but
it's required by the Swift 4.0 toolchain.

This also removes the lines to upgrade libicu-dev and sqlite3.  These
are sufficiently up-to-date in the Trusty image.
2017-10-20 10:12:47 -07:00
Ewan Mellor cfb0041328
Switch all the macOS Travis jobs to use the Xcode 9 image.
We require Xcode 9 for the Swift target, and the C++ and .NET tests
shouldn't care either way.

We no longer need to install cmake: this is already in the Travis
Xcode 9.0 image (and it barfs if we try to install it again).

We no longer need the rvm bug workarounds; a newer version of rvm is
in the Xcode 9.0 image so this is no longer a problem.

The openssl package is already installed and up-to-date now, so there is
no need to install that.

These changes mean that we don't need before-install-osx-cpp.sh
or before-install-os-swift.sh at all, and before-install-osx-dotnet.sh
gets a bit shorter.  .travis.yml gets a small change to handle the
fact that some platform / target combos don't need before-install any more.
2017-10-20 10:12:47 -07:00
Ewan Mellor 39c01f6da7
Update the Swift tests for Swift Package Manager 4.0.
SwiftPM has changed its default layout for new packages (i.e. when we
use "swift package init --type executable" during the test).  It now is
<projectName>/Sources/<projectName>/main.swift, so we need to adjust the
paths appropriately.

This includes a small change to print stdout as well as stderr if a
unit test fails to build.  swift-build-tool takes the compiler subprocess's
stderr and puts it on stdout.  *sheesh*  This meant that we were losing
critical error messages.
2017-10-20 10:12:47 -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
Ewan Mellor 4d628174df
Update Swift runtime documentation.
We now use boot.py and Swift Package Manager to generate the .xcodeproj
rather than having those committed in the source repo.
2017-10-20 10:12:44 -07:00
Ewan Mellor 7df0c2f478
Split the C++ tests into three groups.
Running these as a single test still intermittently times out after 40
minutes, even with the other recent csets.
2017-10-20 00:30:53 -07:00
simkimsia 3def33fdd5 Update contributors.txt 2017-10-15 16:17:23 +08:00
simkimsia 51fc50dbcb Update getting-started.md
change all mentions of 4.5.3 to 4.7 since that's what the quickstart on http://www.antlr.org/ homepage is already showing
2017-10-15 16:14:50 +08:00