Commit Graph

6698 Commits

Author SHA1 Message Date
Ewan Mellor 376f7384c3
Run the Swift runtime unit tests during the Travis run.
These are the unit tests that are written in Swift, not the more
in-depth runtime-testsuite tests (we were always running those).

I don't know why JAVA_HOME isn't set during run-tests-swift.sh, but it
isn't.  Set it, since runtime/Swift/boot.py expects it as part of the
parser generation.
2017-11-04 11:41:20 -07:00
Terence Parr 0fd2098b6c
Merge pull request #2096 from ewanmellor/mvn-clean-swift
Include the Swift runtime in "mvn clean".
2017-11-04 10:51:42 -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
Terence Parr 85aaf1b0d9
Merge pull request #2092 from ewanmellor/swift-fix-unbufferedcharstream
Fix UnbufferedCharStream in the Swift runtime.
2017-11-04 10:50:29 -07:00
Terence Parr 5809f71d0e
Merge pull request #2091 from ewanmellor/travis-cache-dotnet-osx
Add Travis-side caching of the dotnet package that we download from Microsoft
2017-11-04 10:50:00 -07:00
Terence Parr 21a38b3cea
Merge pull request #2086 from ewanmellor/message-output
Improve the "gnu" message format
2017-11-04 10:49:37 -07:00
Terence Parr 22842da4cb
Merge pull request #2085 from ewanmellor/fix-message-format-cmdline-option
Fix the -message-format command line option.
2017-11-04 10:48:39 -07:00
Terence Parr fe992fa69d
Merge pull request #2084 from ewanmellor/fix-outputdirectory-error-handling
Very minor fix in error handling path for the -o command line option.
2017-11-04 10:47:50 -07:00
Terence Parr 4bff008527
Merge pull request #2082 from ewanmellor/appveyor-cache
Add cache entries to appveyor.yml.
2017-11-04 10:47:06 -07:00
Terence Parr 1813da0166
Merge pull request #2079 from ewanmellor/travis-dont-cache-antlr
Remove ~/.m2/repository/org/antlr from the Travis cache.
2017-11-04 10:46:43 -07:00
Terence Parr 1701d769d3
Update antlr-project-testing.md 2017-11-04 09:20:11 -07:00
Ewan Mellor 0e0ad04f01
Include the Swift runtime in "mvn clean".
Add an entry to pom.xml so that the runtime/Swift subdirectories that contain
build output are removed when "mvn clean" is used.
2017-11-01 15:03:27 -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
Terence Parr 64ae36b3e8
Merge pull request #2090 from gendalph/master
CMake build fixes for Visual Studio
2017-10-30 13:38:09 -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
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
Ewan Mellor 63d83a8bcc
Add a note to the documentation regarding -message-format gnu's suitability
for Xcode.

Mention use of -o while we're here.
2017-10-29 12:12:58 -07:00
Ewan Mellor 4729fe8285
Change the "gnu" message format.
Add the column to the location; this is something that GCC and other
GNU tools do, and is obviously useful for IDEs.

Move the message ID so that it reads e.g. "... [error 50]". This mimics
GCC's [-Wformat] kind of thing and is more obvious than the (50) that we
were using before.
2017-10-29 12:03:04 -07:00
Ewan Mellor 8f639f28dd
Put full filepaths in error messages when not using the default message format.
When the default "antlr" message format is used, ErrorManager deliberately
only includes the filename in any error message, not the full path, to
keep the messages short.  However, if the error message is intended to be
parsed by an IDE, this is no good.

Address this by printing the full path when using alternate message formats.
There are two formats available today -- "gnu" and "vs2005".  I think it's
reasonable to assume that people would use these for IDE compatibility, and
so using the full path for these is appropriate.  Also, they didn't work
until very recently, so this isn't breaking any existing behavior.
2017-10-29 12:03:04 -07:00
Ewan Mellor f2638b290d
Fix the -message-format command line option.
ErrorManager.setFormat was being called before the command line options
were parsed in handleArgs.  This meant that setFormat was always called
with the default, and so the command line option never took effect.

This option apparently only worked for 2.5 hours on Sep 6 2012 ;-)

Closes #992.
2017-10-29 11:58:16 -07:00
Ewan Mellor a465f777ea
Add cache entries to appveyor.yml.
These cache the Maven and nuget package directories.
2017-10-29 11:50:14 -07:00
Ewan Mellor c8c577c332
Very minor fix in error handling path for the -o command line option.
If the specified output path was a file and not a directory, the error
handling intended to invalidate outputDirectory, but due to an apparent
copy-paste error, it invalidated libDirectory instead.
2017-10-29 11:49:06 -07: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
Ewan Mellor 026c6736dc
Add Travis-side caching of the dotnet package that we download from Microsoft.
This avoids hitting the Microsoft server every time.  The download isn't
super-reliable, so this should help with build reliability.

This extends the cache timeout, because the package is large and the
upload was timing out.
2017-10-28 14:32:33 -07:00
Ewan Mellor 6b504fee43
Remove ~/.m2/repository/org/antlr from the Travis cache.
Caching ~/.m2 is useful; caching org/antlr inside there is not.  It causes
unnecessary re-submission of the cache every build.
2017-10-28 14:26:34 -07: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