Commit Graph

7198 Commits

Author SHA1 Message Date
Terence Parr 5fc056d1d1
Merge pull request #2358 from KvanTTT/AssignTokenNamesToStringLiteralsInParseRuleContexts
Assign token names to string literals in parse rule contexts
2018-11-19 11:06:42 -08:00
Terence Parr 0308999f06
Merge pull request #2413 from nxtstep/fix/mutex-free
[Swift-runtime] Make sure mutexes are being freed accordingly
2018-11-18 09:13:57 -08:00
Terence Parr eaa7e32001
Merge pull request #2418 from ericvergnaud/fix-#1955-javascript
Fix #1955 javascript
2018-11-18 09:13:14 -08:00
Terence Parr be49141903
Merge pull request #2417 from ericvergnaud/fix-#1955-python
Fix #1955 python
2018-11-18 09:12:25 -08:00
Ivan Kochurkin 2f7c5bfe4a Add AssignTokenNamesToStringLiteralsInGeneratedParserRuleContexts and AssignTokenNamesToStringLiteralArraysInGeneratedParserRuleContexts unit-tests 2018-11-18 15:54:20 +03:00
Ivan Kochurkin 70e3e5de70 ElementFrequenciesVisitor: override stringRef(TerminalAST ref) for correct processing of arrays of string literals 2018-11-18 15:54:20 +03:00
Ivan Kochurkin d3745c7b93 RuleFunction: process STRING_LITERAL along with RULE_REF and TOKEN_REF. Add getRuleTokens method 2018-11-18 15:54:20 +03:00
Ivan Kochurkin 0a6dbc37b7 Grammar.java: add getTokenName(String literal) method 2018-11-18 15:54:20 +03:00
Eric Vergnaud 77c830e6e1 fix #1955 for Javascript 2018-11-18 19:44:33 +08:00
Eric Vergnaud 43e529ca73 fix #1955 for Python 2018-11-18 19:41:47 +08:00
Eric Vergnaud f6537bf4ac fix #1955 for Chsarp 2018-11-18 19:31:47 +08:00
Terence Parr d714d7ba9c
Merge pull request #2409 from amykyta3/master
Fix install dependency for 'typing' library in python3.4
2018-11-17 09:30:40 -08:00
Terence Parr 6080a0639c
Merge pull request #2411 from ewanmellor/swift-fix-2369
[Swift] Syntax error in antlr4/runtime/Swift/boot.py
2018-11-16 08:48:09 -08:00
Terence Parr 46a5f29fc8
Merge pull request #2410 from ewanmellor/swift-tidyups
Swift tidyups
2018-11-16 08:47:42 -08:00
nxtstep 4e744043a3 Make sure mutexes are being freed accordingly 2018-11-16 17:26:52 +01:00
Ewan Mellor 9d29f116cb
[Swift] Syntax error in antlr4/runtime/Swift/boot.py
Make boot.py work under both Python 2 and 3.  This fixes #2369.

Add an extra exception handler, for neater error messages.
2018-11-15 21:49:58 -08:00
Ewan Mellor 0f1614dd99
[Swift] Tidy-ups around addDFAEdge.
Do some tidy-ups around addDFAEdge, improving the handling of nils so that
we're not forcing or nil-checking so much.
2018-11-15 21:25:47 -08:00
Ewan Mellor 8f42439943
[Swift] Remove unused constructors.
Remove unused constructors from ATNConfig and DFAState, and merge two
by using a default parameter instead.
2018-11-15 21:25:47 -08:00
Ewan Mellor 176d92d373
[Swift] Tighten up the permissions on lots of fields
Tighten up the permissions on lots of fields, for debuggability.
2018-11-15 21:25:47 -08:00
Ewan Mellor 623fe00fb7
[Swift] Change a whole bunch of "final var" to "let".
I think that there was some confusion when the original port from Java
was done, because "final" in Java is not the same as "final" in Swift.
2018-11-15 21:25:47 -08:00
Ewan Mellor e01d0be92c
[Swift] Remove implicitly unwrapped optional from ATN.grammarType.
This is set in the constructor and is never nil, so this wasn't doing
anything.
2018-11-15 21:25:47 -08:00
Ewan Mellor 9ca1a9e158
[Swift] Remove ATNState.INITIAL_NUM_TRANSITIONS.
This was brought over from the Java runtime in the initial port, but there
it was used as an array capacity hint.  We're not using it in Swift so
this is useless.
2018-11-15 21:25:47 -08:00
Ewan Mellor 8a34dcdcf9
[Swift] Move doc-comment.
This was attached to the incorrect method in the initial port from Java.
2018-11-15 21:25:47 -08:00
Ewan Mellor 3deb4d91e6
[Swift] Remove OrderedATNConfigSet.
This is a subclass that only exists to have a different constructor.  There
is no need for this construction in Swift, since we have named parameters,
so we can remove the entire subclass and make ATNConfigSet final instead.
2018-11-15 21:25:47 -08:00
Ewan Mellor 657ab4b3b4
[Swift] Remove OrderedATNConfig.
This is unused.
2018-11-15 21:25:47 -08:00
Alex Mykyta 2a3530f513 Fix install dependency for python3.4
Add install dependency for "typing" backport if using anything older than Python3.5
2018-11-15 20:15:39 -08:00
Terence Parr f08de81805
Merge pull request #2405 from ewanmellor/testability-and-build-improvements
Testability and build improvements
2018-11-15 16:01:33 -08:00
Terence Parr 9611faaf5b
Merge pull request #2408 from ewanmellor/swift-fix-perf-tests
[Swift] Make ParserATNSimulator.precedenceTransition return a nullable value.
2018-11-15 15:59:59 -08:00
Ewan Mellor 443a1d2454
Make all the Travis test scripts exit in the event of error.
Test scripts that ignore errors aren't very helpful.
2018-11-15 15:33:10 -08:00
Ewan Mellor 481f517fec
[.NET] Make the .NET Travis tests use netstandard1.3.
Add -f netstandard1.3 to the dotnet build command used on Travis.

This has been necessary since PR #2024, and the build has been silently failing
all this time.
2018-11-15 15:33:10 -08:00
Ewan Mellor 768a0a66e6
[Swift] Build and test error checking.
Change all the subprocess calls in boot.py to check whether they succeeded,
and set the script status appropriately.

In particular, when our unit tests fail, we need the script to exit
with a failure code so that we actually notice on Travis.
2018-11-15 15:33:10 -08:00
Ewan Mellor 4201dd9cf3
[Swift] Don't catch exceptions inside the test apps.
We get much more info if we let the exception rise to the top level.
2018-11-15 15:33:10 -08:00
Ewan Mellor e54607d2ae
Change the test asserts so that we can see all the values.
Change the unit test asserts so that we can see all the values in the
event of a failure.  When debugging an error, it's useful to see both
the stdout and stderr for the failure.  Previously we would only see
one or the other (whichever one failed the assert).

This adds a helper function BaseRuntimeTest.assertCorrectOutput.

This also removes SpecialRuntimeTestAssert, which has not been used for
2 years.
2018-11-15 15:33:10 -08:00
Ewan Mellor 3699ea5412
Exclude intermediate build products from the runtime-testsuite jar.
This means that if you build in an unclean source tree, you don't end up with
intermediate classes in the jar.  (This hasn't broken anything that I noticed,
but it bloats the jar and I wanted to make sure it wasn't messing anything up.)

This excludes .build (the Swift runtime's build directory), target (the Java
runtime's build directory) and Swift/*.xcodeproj (which is not in the source tree
but can be created by devs who are using Xcode).
2018-11-15 15:33:10 -08:00
Ewan Mellor c2d69af6db
Write any dumpstream files into the Travis logs.
This means that we will see the errors if Surefire is bailing for any
reason.
2018-11-15 15:33:10 -08:00
Ewan Mellor 0f6581e480
Fix mvn clean's deleting of the Swift .build directory.
Thanks, Maven.
2018-11-15 15:33:10 -08:00
Ewan Mellor d275a8c97f
[Swift] Make ParserATNSimulator.precedenceTransition return a nullable value.
This was always clearly a possibility, looking at the body of the method.
The newly-enabled performance tests expose this bug (and I don't know how
we've gotten away with it otherwise for so long).

The Java runtime also returns null at this point.
2018-11-15 15:28:47 -08:00
Terence Parr 237ba0f9e1
Merge pull request #2406 from vinoski/cpp-any-fix-is
Do not throw std::bad_cast from antlrcpp::Any::is
2018-11-15 13:21:53 -08:00
Terence Parr 19ebc9da67
Merge pull request #2407 from ewanmellor/swift-4.2
Move the Swift runtime to Swift 4.2
2018-11-15 12:33:37 -08:00
Ewan Mellor 19ac145081
[Swift] Add version info to the documentation.
Add a documention note about which versions of Antlr require which versions
of Swift.
2018-11-15 11:26:09 -08:00
Ewan Mellor 8cd798431d
[Swift] Change getStateToAltMap to use Int as the dictionary key, not ATNState.
The ATNState hashValue and == override are just using the stateNumber field, so
using the Int directly is equivalent, and saves bouncing through those methods.

This also seems to be a correctness issue with the new Hashable protocol changes in
Swift 4.2 (though I admit that I don't know why).

Remove PredictionMode.getStateToAltMap, which was just a stub onto
ATNConfigSet.getStateToAltMap and didn't seem to be doing anything useful.
2018-11-15 11:26:09 -08:00
Ewan Mellor 1184c67f72
[Swift] Swift-Runtime error after XCode 10 / iOS 12 update
Avoid adding to closureBusy before all ATNConfig properties are set.

This fixes #2372.

This is a port of c8805ab from the Java runtime.  That was PR #1955.
2018-11-15 11:26:09 -08:00
Ewan Mellor 75d4d867ef
[Swift] Suppress "Optional" in the output when printing a value.
Suppress "Optional" in the output when printing a value in the tests and
some debugging messages.

This is a change in behavior in Swift 4.2 (SE-0054) that implicitly
unwrapped optionals are now seen as plain Optional at runtime, and so
print doesn't implicitly unwrap them any more.
2018-11-15 11:26:09 -08:00
Ewan Mellor 938883d516
[Swift] Fix MurmurHash calculations under Swift 4.2.
This was working before because calling hashValue on a boxed UInt32 gave
back the value itself.  This is apparently no longer true.

It's not something we should have been doing anyway.  We were needlessly
boxing the intermediate hash values, and passing them into a generic
method, just to unbox them again.

Fix this by creating a helper method, and calling that directly when
updating intermediate hash values.
2018-11-15 11:26:09 -08:00
Ewan Mellor e327e4a13e
Change uses of functions deprecated in Swift 4.2.
This is three instances of flatMap changing to compactMap, and
one instance of UnsafeMutablePointer.deallocate(capacity:) changing
to UnsafeMutablePointer.deallocate().
2018-11-15 11:26:09 -08:00
Ewan Mellor 23bc423259
Move Travis tests to Swift 4.2 and Xcode 10.1.
Move Travis Swift, .NET, and C++ macOS tests from Xcode 9 to Xcode 10.1.
Move Travis Linux Swift tests from Trusty to Xenial and to Swift 4.2.1.

Remove the dirname call when setting JAVA_HOME, it seems to be incorrect.
Print the JAVA_HOME that Travis ends up with.

Moving to Xcode 10.1 / Swift 4.2 exposes the issue discussed in #2372
so this cset will fail automated tests without the relevant fixes.
2018-11-15 11:25:37 -08:00
Ewan Mellor 8e9b6f1147
Switch to using maven-jdk-tools-wrapper to find tools.jar.
This is in different locations on JDK 9 and up.  maven-jdk-tools-wrapper
does the right thing on all JDK releases.

This was mentioned in a side comment on PR #2280.
2018-11-15 11:24:54 -08:00
Terence Parr f261c36bc4
Merge pull request #2400 from nxtstep/fix/st4-dependency
Fix ST4 Snapshot dependency
2018-11-15 09:29:42 -08:00
Terence Parr dc15fe9133
Merge pull request #2404 from ewanmellor/swift-repeated-epsilon-transitions
[Swift] Remove repeated epsilon transitions in ATN.
2018-11-15 09:28:26 -08:00
Terence Parr d87a55576a
Merge pull request #2403 from ewanmellor/swift-perf-tests
Enable some performance tests on Swift.
2018-11-15 09:27:59 -08:00