Commit Graph

2608 Commits

Author SHA1 Message Date
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