Commit Graph

1928 Commits

Author SHA1 Message Date
parrt 4312b37828 pull test changes in 2016-10-13 10:58:19 -07:00
Peter Boyer 42347c078b Fix merge failure 2016-10-12 09:53:43 -04:00
Peter Boyer 60662c4b70 Fix remaining tests (#64)
* Fix pred context typo

* Adjust array lengths

* PositionAdjustLexer test fix first steps

* allow virtual method calls from Lexer

* Hopefully fix issues with dup namedActions

* Make parser members

* Fix testParserProperty

* Fix LeftRecursion test failures
2016-10-12 09:49:42 -04:00
Mike Lischke a4e343806f Some small optimizations.
- No copy of a DFA state during ATN deserialization.
- Fixed memory leak of locally created s0 state in DFAState.
2016-10-12 11:06:51 +02:00
Mike Lischke 4897bd8571 Simplified memory management for volatile parsing part.
There are 2 parts in an ANTLR genrated parser where memory is allocated: the actual parsing (with or w/o creating a parse tree) and the prediction part (via DFA/ATN etc.). The first part is highly volatile as it recreates parse tree instances (the class) on each parser run. In fact also lexer tokens belong to that part, but are already managed via unique pointers. This first part works without any smart pointer now. Instead there is a simple tracker class which holds all created references and frees them when the parser is reset or destroyed. This is a bit less optimal if the parser is set to create no parse tree, as created rule context objects are not freed immediately (like with smart pointers), but during reset. On the other hand this change gives (depending on the input) a nice speed up (0%-100%, after the warm up phase). Additionally memory consumption drops by a good amount.

Everything in the simulartors (and interpreters) remains unchanged. This is the shared prediction part.
2016-10-11 13:49:02 +02:00
Peter Boyer 145bfca692 Update lexer_action.go (#62) 2016-10-08 23:03:11 -04:00
Christian Gudrian 75dd652d7a fixed visitAtom implementation
This implementation somehow got lost in rebasing.
2016-10-07 20:37:38 +02:00
Christian Gudrian cb590334bb the visit methods now return a value 2016-10-06 22:52:19 +02:00
Christian Gudrian 0396561520 made visitAtom work for terminal nodes 2016-10-06 22:52:19 +02:00
Peter Boyer 10f15cabf8 errorNode() impl (#59) 2016-10-06 16:19:05 -04:00
Peter Boyer a5859fd54e Fix PredictionContext merge() typo (#61)
* Fix pred context typo

* Adjust array lengths
2016-10-06 16:18:18 -04:00
Mike Lischke 2e92b38bf7 Updated unit tests after last refactoring. 2016-10-06 17:17:36 +02:00
Peter Boyer 499d9d3f89 Print test arrays in java style (#50)
* Print string rule invocation stack array in java style

* regen runtime tests

* Another array print fix

* Fixes to print array of terminal nodes:

* regen tests
2016-10-05 14:52:42 -04:00
Mike Lischke fc5c1a29f9 Next attempt to get the C++ runtime compiled in Travis CI. 2016-10-04 10:17:59 +02:00
Mike Lischke bb5d7ef0b6 Set minimum cmake version to 3.1 for C++ target. 2016-10-04 10:09:31 +02:00
Mike Lischke c968b5209e alts outer-context flag/counter in ATNConfig is now unsiged.
A few more removals of no longer necessary casts.
2016-10-03 16:11:45 +02:00
Mike Lischke 0e0ecfafde Fixed a number of warnings for VS. 2016-10-03 14:50:22 +02:00
Mike Lischke 8280beb564 Refactoring of further int values, mostly converting them to size_t.
- Switched most symbolic signed constants to unsigned variants. Redefined EOF in particular to become (size)-1, to avoid having to use signed token type values.
- Introduced INVALID_INDEX for all previous -1 values to indicate e.g. not found indexes etc.
- Added 2 helpers to convert between symbolic and numeric form (mostly for intervals and toString()).
- Removed many no longer needed type casts to size_t.
- Updated templates for these changes.
- Limited runtime tests to C++ tests only, to see how Travis CI copes with that.
2016-10-02 16:51:57 +02:00
Mike Lischke de4df872fe Updates to get all tests green again.
- Had to take back some of the message beautifying, as this won't match expected runtime test output.
- Updated C++ test stg file for recent runtime changes. Regenerated tests (only one file changed actually).
- Reworked C++ test preparation. The C++ runtime is now built on first invocation of a test. This works only on Linux + OSX/macOS. Windows needs extra handling.
2016-10-01 12:43:31 +02:00
Mike Lischke 5c63bc9a07 Some clean up and xcode unit test fixes. 2016-09-30 10:59:44 +02:00
Mike Lischke 4394cd20b0 Merge branch 'master_upstream' 2016-09-29 16:50:57 +02:00
Mike Lischke f983fac7c7 Added support for hidden symbols on Linux and OSX.
It's now possible to hide all symbols by default and publish only those marked with the ANTLR4CPP_PUBLIC macro (same as for Windows). The included XCode project makes use of this option now.
2016-09-29 16:48:17 +02:00
Mike Lischke 28eb19f52e Explicitly delete copy c-tor and operator for DefaultErrorStrategy.
This class holds a vector of unique_ptr instances and hence cannot be copied.
2016-09-25 11:48:18 +02:00
Mike Lischke ee3e918e4e Exclude also vscode project data when generating the source zip. 2016-09-25 11:24:53 +02:00
Renata Hodovan 03d5fb1244 Make Python targets more pythonic.
The Python implementations are completely synchronous
with the Java version even if some of the constructs
can be expressed with simpler Python solutions. These are
typically the all, any, count, next builtins or the list
comprehensions, etc. Beside using them makes the code
clearer, they are also prefered by the standard and can
result in performance speedup. The patch contains such
equivalent transformations in the Python targets.
2016-09-25 10:33:27 +02:00
Mike Lischke 19345919de Bug fixes + XCode 8 updates
- Recommended project updates from XCode 8 applied.
- Bug: ANTLRInputStream not fully initialized when constructing from a stream.
- Account for more than one temporary error token in DefaultErrorStrategy.
2016-09-24 12:33:54 +02:00
Christian Gudrian 46df58d5d7 The JavaScript ParseTreeVisitor now implements a depth-first traversal by default. 2016-09-22 08:28:11 +02:00
Nathan Burles 6638883d9d Second parameter is end pointer, not size 2016-09-02 12:51:28 +01:00
Mike Lischke 6f62821573 More optimizations of the runtime.
- Lesser use of shared_ptr, e.g. in listeners and some loops.
- Removed useless access methods for children in ParseRuleContext. The child list is public. Fixed initialization for start and stop nodes.
- Simplified parent + child organization in Tree and all derived classes. Instead of using overridable functions in various descendants we have now central parent + child fields in the base tree class (where they belong actually, considering this is about forming a tree). Users have to cast to the appropriate classes if necessary.
- Removed obsolete getChildren() function in Trees helper. We can just return the child vector.
- Changed edges member to an unordered_map, as this is a sparse container. This speeds up certain grammars by 1000% (e.g. highly recursive expression rules) and avoids wasting a lot of memory. This change also simplifies handling significantly.
2016-08-22 12:12:22 +02:00
Mike Lischke ee2510e654 Output formatting in DefaultErrorStrategy and init of generated member vars.
- Had to escape tabs + linebreaks in DefaultErrorStrategy when generating a text representation. Also removed a few explicit string instance creations on the way.
- Member vars in parser context classes that take (optional) Token references must be initialized.
- Fixed a warning that copyFrom() would hide a virtual function in a ParserRuleContext.
- Another attempt to limit genrating double semicolons.
2016-08-10 08:55:17 +02:00
Renata Hodovan c15b0d9a36 Fix the initialization of conflictingAlts in execATN in Python targets.
The Java target initializes the conflictingAlt local variable
based on the conflictingAlts property of the target state.
However, the Python targets resets it to None. The patch makes the
initializations consistent.
2016-08-10 01:32:12 +02:00
Renata Hodovan 510e21d7cb Fix eofToken access in ListTokenSource.nextToken() by Python targets.
At the end of the nextToken() function, setting the eofToken field was
attempted without the 'self' keyword, resulting in accessing
and setting a new local and unused variable. The patch supplements
the missing 'self' keywords for both targets.
2016-08-09 15:32:12 +02:00
Mike Lischke 1869d9dac2 Reverting revision [a2d6b62] 2016-08-07 11:29:47 +02:00
Mike Lischke 7abfbc60c6 Change deployment scripts location and updated doc.
In order to be able to build with cmake and to have a complete source package including the demo the deployment scripts were moved to the root Cpp folder and updated.
Also the releasing-antlr.md doc file has been updated.
2016-08-04 17:03:34 +02:00
Mike Lischke ccc1fc4939 Fix for merge problems in PredictionContext.
Apparently context references can disappear while such a ref is held in the (temporary) merge cache. Hence we need to do a full ref for the merge cache key pair.

Closes issue #12.
2016-08-04 16:05:09 +02:00
Mike Lischke 78a12168bb Merge pull request #35 from nburles/fix-prediction-context
Without these tests, the demo crashes
2016-08-04 15:42:16 +02:00
Mike Lischke 07ceea1245 Some additional changes for removal of the == operator override. 2016-08-04 15:41:45 +02:00
Mike Lischke a41774ef0d Merge pull request #33 from nburles/remove-equality-override
Remove the std::operator== override in CPPUtils.h
2016-08-04 15:40:51 +02:00
Nathan Burles dc35da2a75 Only compare the addresses, as in Java 2016-08-04 13:39:07 +01:00
Nathan Burles fa0816d243 Without these tests, the demo crashes at PredictionContext.h:247 : k->hashCode() 2016-08-04 11:20:21 +01:00
Mike Lischke b05c8286b8 Corrected a warning suppression check. 2016-08-04 10:04:24 +02:00
Mike Lischke 8335d32b2d Various smaller changes to fix compilation and other problems.
- Added new rule to test grammar to get code generation for wildcard capture.
- Updated the Cpp.stg template file for that.
- Made the Unicode hack (auto extend 0xFFFF to 0x10FFFF) dependent on a parameter, so we only use this hack when deserializing an ATN. This avoids trouble with intervals used in other contexts (like string offsets).
- Added a few operator != overloads, to fix compilation after recent changes.
- Simplified operands comparison in SemanticContext (uses the Arrays class now). Some cleanup in that class too.
- The abstract parse tree visitor now uses const& for Any references, to avoid reallocating new instances over and over again.
- The lexer counts syntax errors the same way as the parser does. So we can directly determine if there was any error by simply examining that (which avoids having to use a temporary listener).
2016-08-04 09:28:13 +02:00
Nathan Burles db8339b458 Leave spaces alone unless escaped spaces requested 2016-08-02 14:56:10 +01:00
Nathan Burles a1d61541b7 Remove the std::operator== override in CPPUtils.h 2016-08-02 09:00:10 +01:00
Mike Lischke 183b7ce0a9 Merge pull request #30 from nburles/compare-contents-not-just-addresses
Compare contents not just addresses
2016-08-01 18:17:42 +02:00
Mike Lischke 63b5e61c15 Merge pull request #31 from nburles/simpler-hash-calls
There is no need to call ->hashCode() explicitly
2016-08-01 18:01:28 +02:00
Mike Lischke 8bbdbe0371 Merge pull request #28 from nburles/fix-intervalset-comparisons
Fixes comparisons of IntervalSets
2016-08-01 17:45:45 +02:00
Mike Lischke f3110fdd22 Merge pull request #27 from nburles/fix-ATN-serialization
Fixes ATN serialization
2016-08-01 17:45:03 +02:00
Nathan Burles 64f1a654bd There is no need to call ->hashCode() explicitly 2016-08-01 16:40:15 +01:00
Mike Lischke 3705e1b3fd Consistent formatting in Any.h + converted CPPUtils.cpp to utf-8. 2016-08-01 17:36:43 +02:00
Nathan Burles 198da78c98 Compare contents in SemanticContext::*::operator== 2016-08-01 16:32:51 +01:00
Nathan Burles 739bf3a756 Compare contents in LexerATNConfig::operator== 2016-08-01 16:31:48 +01:00
Nathan Burles 903fa473c5 Compare contents in ATNConfigSet::operator== 2016-08-01 16:26:37 +01:00
Nathan Burles a025c9eefc Compare contents in ATNConfig::operator== 2016-08-01 16:25:37 +01:00
Mike Lischke c60f1bb8f9 Fixed a bug + raised warning level in Visual Studio
- Fixed an endless recursion in Any, caused by the removal of one of the (apparently) unneeded copy constructors. As it turned out both are required. That leads to a warning in VS about a duplicate copy c-tor, which had to be suppressed therefore.
- Raised the warning level to W4 in both VS 2013 and VS 2015 and fixed all warnings resulting from that.
2016-08-01 16:47:17 +02:00
Nathan Burles 3ee53a79db Fixes comparisons of IntervalSets 2016-08-01 09:57:51 +01:00
Nathan Burles 3535830c98 Fixes ATN serialization 2016-08-01 09:54:10 +01:00
Mike Lischke 282e193e6a Corrected an include. 2016-07-31 16:10:39 +02:00
Mike Lischke eee86d8292 Small updates for VS 2013/2015.
Updated the demo project to also use static/dynamic libs like the runtime and fixed a few warnings in the Any class.
2016-07-31 13:28:01 +02:00
Mike Lischke 8a5f6815fe Rework of the visitor implementation
The translation from Java generics to templates in C++ lead to the need of virtual template functions, which is not supported by C++. Instead we use now the Any class for results of visits and no longer need templates for that part.
2016-07-30 20:03:27 +02:00
Tim O'Callaghan 7724dd2cd5 external project cmake example, needed set C++ 11 2016-07-24 22:13:17 +02:00
Tim O'Callaghan d6d50457ff Updated CMake for demo to:
- Only require JRE
- Support out of tree build from antlr repostitory
- Support Superproject build with ExternalAntlr4Cpp cmake module

ExternalAntlr4Cpp module has quickstart documentation for people to be
able to start working quicly with antlr4cpp from the base demo sources
see source file for example.
2016-07-24 21:58:45 +02:00
Mike Lischke 365e0f2df0 Fixed a few warnings. 2016-07-22 16:33:43 +02:00
Mike Lischke d46ef90aa0 Fixed some cmake issues. Closes issue #13 and issue #8.
Additionally a warning was fixed (std::move prevents copy elision)
2016-07-20 16:24:12 +02:00
Mike Lischke 196e8ab53d Actually use a channel in the demo grammar. 2016-07-20 15:22:09 +02:00
Mike Lischke 5e313471df Merge pull request #19 from nburles/fix-utf8-bom
Added code to detect and handle the UTF-8 BOM if present
2016-07-20 15:20:31 +02:00
Mike Lischke be2c98f64f Merge pull request #18 from nburles/fix-intervalset-iterator
vector::erase invalidates any iterators at/after the erase position
2016-07-20 15:16:26 +02:00
Mike Lischke 91a7657d73 A few small corrections after the previous merge. 2016-07-20 12:32:02 +02:00
Nathan Burles 78de172790 Fix warnings with int to char cast 2016-07-19 11:46:24 +01:00
Nathan Burles d3027f18fb Added code to detect and handle the UTF-8 BOM if present, otherwise the utfConverter leaves it in the stream 2016-07-19 11:31:03 +01:00
Will Faught 7f42bc602b Add interface build checks for tree types and generated base listeners 2016-07-18 12:19:31 -07:00
Nathan Burles ba5cf0060c vector::erase invalidates any iterators at/after the erase position 2016-07-18 13:52:45 +01:00
Nic30 22794aa2d8 fix liblib in library names 2016-07-07 12:48:33 +02:00
Nic30 1ceb6a45dd indent fix 2016-07-07 12:43:03 +02:00
Nic30 027dde5e3e LexerAction instances shared_ptr fix 2016-07-07 12:33:59 +02:00
Will Faught a05dea54ec Fix test case build errors 2016-07-06 09:02:42 -07:00
Eric Vergnaud 0fed0b0684 Following #1218, ensure consistency of ATNConfigSet hashing strategy in JavaScript 2016-06-28 10:45:05 +02:00
Chris Heller c4785ab8be Document cmake minimum version.
Document the minimum cmake version needed to build C++ target (if compiling with cmake).  Also, fix a missing space in cmake command between directory path and defining where the ANTLR .jar is located.
2016-06-26 15:28:26 -07:00
Mike Lischke 8046c28a5e A few more text escape calls in DefaultErrorStrategy.
And some cleanup.
2016-06-26 11:35:38 +02:00
Mike Lischke c462e03126 Merge branch 'master_upstream' 2016-06-26 11:12:23 +02:00
Mike Lischke 2352ff03e1 getSerializedATN() wasn't properly overwritten. 2016-06-26 11:10:31 +02:00
nuuman a2d6b62a1a Update DefaultErrorStrategy.cpp
Property escape vocabulary reporting
2016-06-25 21:06:53 +02:00
Eric Vergnaud 26c409103d Fix #1217
The root cause was that ATNConfigSet was not using he required custom hashing strategy for ParserATNSimulator.
The commit includes a number of additional fixes, related to code that was never executed before due to the root cause.
A similar issue is also likely to exist in the JavaScript runtime, I'll fix it later.
2016-06-23 15:51:39 +02:00
Eric Vergnaud c260ce75d1 make it possible to add breakpoint 2016-06-23 15:06:14 +02:00
Mike Lischke c8f80b167d Small naming fix. 2016-06-22 11:24:26 +02:00
Mike Lischke a127f34a74 Changed Win deployment script to produce 2 smaller zips instead of a big one. 2016-06-22 10:56:38 +02:00
Mike Lischke 1da7e8eea0 Fixed #include. 2016-06-21 16:28:44 +02:00
Mike Lischke a2f5cf12fd Fixed + simplified loading text to parse from a file.
- The previous approach to load and convert UTF-8 data via a stream didn't work well, so I replaced that with a simple load-to-buffer + convert buffer from UTF-8 to UTF-32.
- Removed deleted Token.cpp file from XCode project.
2016-06-21 16:23:28 +02:00
Mike Lischke 8c62740f16 Missed to commit an XCode project change. 2016-06-21 10:53:36 +02:00
Mike Lischke d718fa9f44 Windows runtime deployment.
- Created deployment script for Windows + updated doc/releasing-antlr.md.
- Created projects for both VS2013 and VS2015 to be used by the deployment script.
- Fixed trouble with a bug in VS2015 where std::codecvt_utf8<char32_t> is not properly supported.
- Fixed a few #include paths + a number of warnings.
2016-06-21 10:51:31 +02:00
Mike Lischke 89442c6cb8 Changes for deployment.
- Settled on a final library name scheme: base part is "libantlr4-runtime" on MacOS + Linux. The extension determines the type (.a static lib, .dylib dynamic lib in MacOS, .so dynamic lib in Linux). No more mention of target language (cpp) or type (static) in the lib name. On Windows we omit the lib prefix, so the name becomes: antlr4-runtime.dll + antlr4-runtime.lib. We may later want to add version information there, but doing that automatically is difficult.
- Updated XCode project and CMakeLists.txt file for the new naming scheme.
- Added deployment scripts for source code (for Linux + iOS) and MacOS.
- Added C++ section in docs/releasing-antlr.md.
2016-06-19 15:31:09 +02:00
Peter Boyer 97bf8d63f8 TODO 2016-06-17 19:21:11 -04:00
Peter Boyer 6c717889b2 Make protected members package public 2016-06-17 19:19:04 -04:00
Peter Boyer c877bee8f1 PORT_DEBUG fix 2016-06-17 19:18:46 -04:00
Peter Boyer 7b1059ab6e Cleanup 2016-06-17 19:18:04 -04:00
Peter Boyer e4498eca87 delete js test code, unused license/readme 2016-06-17 19:17:39 -04:00
Mike Lischke 19dbd8e746 A fix for the Linux demo project. 2016-06-17 15:54:21 +02:00
Mike Lischke 3b5b400d03 A few fixes for the previous listener change.
Also fixed runtime tests again.
2016-06-17 11:27:52 +02:00
Mike Lischke 4a7ec859aa Simplified parse tree listener handling.
No need to use shared_ptr for management. Listeners are, like the other main classes (parser, lexer, input stream etc.) provided by the application and hence managed there.
2016-06-17 10:22:19 +02:00
Peter Boyer 29eaba44b0 Merge pull request #34 from willfaught/style-charstream-commontoken-dfa
Clean up Go runtime char stream, common token, and dfa code
2016-06-16 14:45:01 -04:00