Commit Graph

2140 Commits

Author SHA1 Message Date
Mike Lischke aabf4baf60 Added default c-tor to ParseTree + improved createInstance.
createInstance now use move semantics for its parameters.
2016-10-14 17:05:00 +02:00
Mike Lischke 014070de66 Converted smart pointer for the rule context in RecognitionException
Since we pass around raw pointer for volatile references now, we must not create smart pointers from them or we will get a double free.
2016-10-14 17:03:38 +02:00
parrt 285c7fca6c resolve contribs conflict 2016-10-13 16:21:00 -07:00
Peter Boyer 2444386091 Remove JavaScript PORT_DEBUG, re-enable runtime tests for other language targets (#69)
* Re-enable runtime tests for other language targets

* Fix typo in js code

* Remove PORT_DEBUG statements

* Fix missing

* Fix testAltNum
2016-10-13 17:06:22 -04:00
Terence Parr 8d0ae8599e Merge pull request #1221 from ericvergnaud/javascript-consistency
Following #1218, ensure consistency of ATNConfigSet hashing strategy …
2016-10-13 14:05:36 -07:00
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
ghosthope 9766dff5d8 Javascript performance. Was add new string.hash function - murmurhash3_gc.js (https://github.com/garycourt/murmurhash-js/blob/master/murmurhash3_gc.js). Performance of the function increased in two times 2016-09-23 16:57:40 +03:00
Christian Gudrian 46df58d5d7 The JavaScript ParseTreeVisitor now implements a depth-first traversal by default. 2016-09-22 08:28:11 +02:00
Vlad 5a0608be2e fix op filter error when trying to replaceSingleToken 2016-09-02 22:20:08 +03:00
Vlad ae435d06c8 add TokenStreamRewriter to Python2 runtime 2016-09-02 15:36:11 +03: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 543a069440 Fix comparisons in ATNConfigSet.__contains__ of Python targets.
The __contains__ method of ATNConfigSet used different hashing
function (hash) for indexing the config dictionary than the
getOrAdd method (hashCodeForConfigSet) which filled it.
Furthermore, they also used different methods for comparing
ATNConfig objects. The patch makes them consistent.
2016-08-09 22:52:37 +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
Tom Wieczorek ea31615804
Use the iterative version of the ParseTreeWalker as default implementation 2016-07-20 09:18:08 +02:00
Tom Wieczorek 7ca7acd084
Use two queues instead of a custom linked memory structure 2016-07-20 09:17:50 +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
Tom Wieczorek 53f2a67b9d
Add an iterative version of the ParseTreeWalker 2016-07-10 15:54:23 +02: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
Will Faught 3e621970f5 Clean up Go runtime char stream, common token, and dfa code 2016-06-16 11:15:49 -07:00
Mike Lischke dd48c0fbd5 A few final touches to make runtime tests passing. 2016-06-16 11:20:42 +02:00
Mike Lischke e68cdc3c0e A few of the previously reverted changes are still good. 2016-06-15 13:46:27 +02:00
Mike Lischke 4a8010b4eb Revert "A few more places that no longer pass a shared_ptr around."
This reverts commit 728af59528.
2016-06-15 13:30:37 +02:00
Will Faught 538455eae6 ATN runtime format, style, and comment cleanup 2016-06-14 15:09:42 -07:00
Mike Lischke 728af59528 A few more places that no longer pass a shared_ptr around. 2016-06-14 15:17:23 +02:00
Mike Lischke dcb0d4aa62 Some cleanup. 2016-06-14 14:05:18 +02:00
Mike Lischke 7ac5252fe9 Explicitly delete copy c-tor + copy operator to for Visual Studio.
VS requires to have copy operations disabled on classes which hold vectors of unique pointers (clang is a bit more relaxed about this).
2016-06-13 17:38:57 +02:00
Mike Lischke 7488621983 Visual Studio build fix. 2016-06-13 16:47:32 +02:00
Mike Lischke b9c28d8c9c Signficantly simplified Token handling.
In order to lower the overhead when passing around Token instances via smart pointers and because the ownership is clear (token streams own them), these instances can be passed as raw pointers.
2016-06-13 13:12:02 +02:00
Mike Lischke 23eeae4b44 Simplification of the ATN config lookup handling.
No need for the ConfigLookup(Impl) class as we only need a way to determine if a config has been added to a set or not. This can be done much simpler by using individual hash codes produced by either ATNConfigSet or OrderedATNConfigSet (idea taken from C# runtime).
2016-06-12 16:08:16 +02:00
Mike Lischke c920d57331 DFA states member is now a set (instead of a map). 2016-06-11 12:57:29 +02:00
Mike Lischke e9d2a04be1 Removed shared_ptr instances for ATNConfigSet.
ATNConfigSet instance follow a clear ownership (all owned by DFAState instances, which stay alive all time). Hence we can use a unique_ptr for memory management instead and pass raw pointers around where needed.
2016-06-10 16:13:15 +02:00
Mike Lischke fec23ce989 Simplified equality check in ATNConfigSet. 2016-06-10 14:58:22 +02:00
Mike Lischke b8fcb5f30d More performance increase for C++ target (25% now).
All shared_ptr<> now use const& for function parameters to avoid constant copies + locks. Ownership and lifetime control is still ensured by the owning containers. Code templates have been updated as well.
2016-06-09 12:02:30 +02:00
Mike Lischke 1cbbc1b760 Merge branch 'antlr-upstream' 2016-06-07 17:44:53 +02:00
Mike Lischke 3a95a36e3f 12% speed improvement for C++ runtime. 2016-06-07 16:27:25 +02:00
Mike Lischke 963f4fc507 ... and for Linux the same. 2016-06-06 16:15:30 +02:00
Mike Lischke b90398f8a6 A few fixes for Visual Studio after added the xpath stuff. 2016-06-06 16:13:38 +02:00
Mike Lischke ff129beadf Some smaller fixes for Windows. 2016-06-06 15:58:14 +02:00
Mike Lischke a4bc611fd5 Changed namespaces + fixed runtime tests.
- Changed namespace chain (org::antlr::v4::runtime) to just antlr4 in all files.
- Fixed runtime tests for that.
- Added conversion of the xpath code, which compiles now (no tests, tho, as there are runtime tests for it).
- Removed TestRig stuff. That doesn't work in C++.
2016-06-06 15:55:27 +02:00
Mike Lischke 4a6b68c6f6 All C++ runtime tests pass now.
- A few remaining changes had to be done for the C++ runtime tests which now completely pass.
- Added a runtime testing overview document.
- Added a description of C++ target.
- Updated the ANTLR release document.
2016-06-04 12:11:38 +02:00
Mike Lischke ac664a91b8 A few more fixes. 2016-06-02 17:32:19 +02:00
Mike Lischke b7ade0ade1 TestParseTrees + TestSemPredEvalLexer C++ test groups pass now. 2016-06-02 12:22:24 +02:00
Mike Lischke 28ccc4962b TestParseTrees passes now. 2016-06-01 15:20:11 +02:00
Mike Lischke 86014ac3a6 TestParserExec tests pass now.
- A few more adjustments to make this test group pass.
- Fixed a few issues in C++ runtime as well.
2016-06-01 10:22:48 +02:00
Wolfgang Johannes Kohnen 950acca7c0 Sort values of BitSet.
* Fixes pboyer/antlr4#16
2016-05-31 17:13:01 +02:00
Mike Lischke 08f844af0e Fixed 2 problems found by runtime tests.
- TestLexerExce group passes now.
- Reverted wrong removal of action text output that prevent named actions from showing up properly.
2016-05-29 16:47:51 +02:00
Mike Lischke 815bb95982 TestLeftRecursion passes, but with some disabled tests.
There are a number of disabled tests that need extra work (all because of target specific action code).
2016-05-29 12:17:29 +02:00
Wolfgang Johannes Kohnen 4fd4e51810 runtime-testsuite/go: Make path construction slightly more robust.
* also piggy back a typo fix.
2016-05-28 11:15:14 +02:00
Mike Lischke a0665677c1 Lots of fine tuning to get more tests passing. 2016-05-27 22:38:42 +02:00
Peter Boyer 6ddc7c9d4f Merge pull request #9 from willfaught/master
Test fixes
2016-05-27 15:33:29 -04:00
Wolfgang Johannes Kohnen 0b0d202c49 runtime/Go semantic context: NewAND, NewOR create empty operands 2016-05-27 18:14:18 +02:00
Will Faught 92793a9dc8 Rename "this" receiver to "t" 2016-05-26 23:28:27 -07:00
Will Faught 10eb1a1970 Rename Lexer.mode to setMode
Also minor formatting.
2016-05-26 23:27:45 -07:00
Will Faught 1208f97696 Rename Go files back to snake case 2016-05-26 12:00:40 -07:00
Will Faught b503116e12 Move runtime/Go/src/antlr to runtime/Go/antlr 2016-05-26 11:51:28 -07:00
Will Faught fe1d61d9db Merging 2016-05-26 11:40:02 -07:00
Will Faught 103dc662c4 Fix "misMatched" 2016-05-26 11:35:49 -07:00
Will Faught 08c17b850e Rename Go files back to camel case 2016-05-26 11:32:45 -07:00
Will Faught bf88d2747c Move runtime/Go/antlr to runtime/Go/src/antlr 2016-05-26 11:26:03 -07:00
Mike Lischke 27b76b5a33 Fixed token toString() so it produces the output expected by the tests. 2016-05-26 12:20:26 +02:00
Will Faught 7080d04662 Export LL1Analyzer.look 2016-05-25 20:16:22 -07:00
Peter Boyer ed5b4d14f7 antlr4 -> antlr 2016-05-25 17:20:16 -04:00
Mike Lischke f103e05bc3 Some additions for better operation.
- Allow loading new input instead of setting up a new input stream.
- Made is<> template function inline, for hopefully faster execution.
- A few other fixes in stream + lexer classes.

- Reverted another rename from context to _localctx in the Cpp.stg file as this is used for certain actions.
2016-05-24 17:39:21 +02:00
Wolfgang Johannes Kohnen 7652b9af79 Go runtime: Change misMatched to mismatched.
That seemed to be a find/replace accident. Apparently this change turns
the tests ...

 * testTokenMismatch
 * testTokenMismatch2
 * testNoViableAltAvoidance
 * testNoViableAlt
 * testExprAmbiguity_2

... to green. Although I am not sure about testExprAmbiguity_2 as that
one doesn't have mis[Mm]atched in its output AFAICS.
2016-05-23 11:26:34 +02:00
Mike Lischke 9e30f3f265 A few minor changes related to building via cmake. 2016-05-23 09:40:48 +02:00
Mike Lischke be65ccd25c Moved the library build instructions to the library readme. 2016-05-22 11:18:16 +02:00
Will Faught 90ac6c0f63 Change "a" back to "this" in comment 2016-05-21 17:08:48 -07:00
Mike Lischke aafc76a7eb Fixed big memory consumption problem.
- The ATN simular generated lots of duplicate DFAStates that consumed a lot of memory, due to missing hashing/== functionality. By using an own hasher/comparer for the unordered_map in the DFA this problem could be solved. Memory consumption is now 100% stable on a low level (e.g. 115MB for a fairly complex parser) and doesn't increase anymore after the warmup phase.
- Fixed also a number of things reported by the clang static analyzer.
- Fixed a bug in Parser.cpp where the stop token in the current context would be set twice overriding a previously set value.
- Optimized token range check via ATN::nextTokens, by not duplicating the stored interval set for a given state.
- Slightly improved IntervalSet::contains() by moving some tests out of the loop and not using intermediate variables.
2016-05-21 16:55:11 +02:00
Will Faught b4da149732 Lint: Remove underscores from names 2016-05-21 01:02:49 -07:00
Will Faught 71dba8cb91 Lint: Change all caps "LOOK" in names to camel case 2016-05-21 00:27:51 -07:00
Will Faught 29b6530a2b Lint: Omit redundant declaration types 2016-05-21 00:22:54 -07:00
Will Faught 5c4e28487e Lint: Replace -= 1 with -- 2016-05-21 00:22:54 -07:00
Will Faught c81f2a7901 Lint: Drop nil declaration assignments 2016-05-21 00:18:15 -07:00
Will Faught 056f3f62c1 Lint: Rename initialisms to uppercase 2016-05-21 00:13:27 -07:00
Will Faught 26df617532 Lint: Outdent else blocks for if blocks that return 2016-05-21 00:05:40 -07:00
Will Faught 33fd68778e Lint: Replace += 1 with ++ 2016-05-20 23:44:36 -07:00
Will Faught 9ed1ed1003 Lint: Use uniform receiver names 2016-05-20 23:41:06 -07:00
Will Faught 8a1b68feb4 Lint: Omit unused second range var 2016-05-20 23:27:24 -07:00
Will Faught 3b742ed8cb Lint: Rename generic "this" var 2016-05-20 23:25:05 -07:00
Will Faught 5361aedc0b Vet 2016-05-20 18:52:08 -07:00
Will Faught 21fa2d1310 Format 2016-05-20 18:52:08 -07:00
Will Faught baaf1fe72f Rename files to snake case 2016-05-20 18:52:02 -07:00
Will Faught 519277f78f Rename package antlr4 to antlr 2016-05-20 17:34:38 -07:00
Will Faught bff76c3e5a Move runtime/Go/LICENSE.txt to antlr 2016-05-20 17:34:04 -07:00
Will Faught 4200fc7c14 Delete unneeded README.md 2016-05-20 17:33:32 -07:00
Will Faught db5a5c5c17 Move runtime/Go/src/antlr4 to runtime/Go/antlr 2016-05-20 17:33:07 -07:00
Peter Boyer 3406acabe5 Correct nil check in ParserATNSimulator 2016-05-20 10:33:39 -04:00
Mike Lischke e6ebc5c36b Fixed demo compilation for Visual Studio 2013. 2016-05-19 17:33:25 +02:00
Mike Lischke e2d545fb2e Changed exception object back in error reporting + removed precompiled headers with cmake.
- Reverted the change from RecognitionException to exception_ptr (and removed the make_exception_ptr() call). This is not needed and only leads to object slicing. Instead we check directly the given exception object for the individual handling in reportError() and use std::current_exception() to get the exception pointer for our contexts.
- Removed precompiled header stuff from cmake file for the same reasons as I did in the XCode project (Visual Studio still pending).
2016-05-18 18:16:08 +02:00
Mike Lischke 0617dfff54 Rework of the include structure.
In order to ease including the antlr runtime in other projects the include structure has been changed:

- Removed precompiled header usage (only OSX, VS + cmake still need updates).
- Created umbrella header antlr4-runtime.h that contains everything needed in a target application.
- Changed all includes to use relative paths, so it is enough to add the src folder to the header search path in an application.

- Also fixed a smaller issue in the C++ template wrt the serialized ATN storage for large grammars.
2016-05-15 18:37:56 +02:00
Mike Lischke 2cbed81504 Further work to have full Unicode support.
- The upper char limit in Lexer.h was wrong. Now correctly set to 10FFFF.
- The lexer ATN simulator now uses lower + upper limit of char32_t instead of hardcoded values.
- Added a little hack to Interval, where a range ending with 0xFFFF will automatically be extended to 0x10FFFF. This is necessary until ANTLR generates full Unicode intervals. This hack allows to include Unicode chars beyond the BMP in char classes in a lexer.
- Fixed an error display issue in Lexer.
2016-05-14 15:57:37 +02:00
Mike Lischke 66a9ee53a0 The generation + runtime now uses std::string instead of std::wstring almost everywhere.
- In order to support UTF-8 the input streams now support loading data from UTF-8 strings and convert them internally to UTF32.
- Additionally, all the toString() functions that (unnecessarily) used wstring are now on string as well. Only some corner cases remain where we still have std::wstring (ATNSerializer).
- The transition classes use size_t instead of int now for vocabulary matching.
- The max char value in the lexer has been increased to 1FFFE, to allow matching the full Unicode range. This is also used in the Interval class to e.g. to negate sets.
- Renamed Strings.h to StringUtils.h, to avoid a conflict with an OSX header (used with Obj-C compilation, e.g. in a project that uses the runtime).
2016-05-13 18:19:12 +02:00
Mike Lischke 0eebbdd78c Updated VS solution with newly added files. 2016-05-12 13:36:27 +02:00
Mike Lischke 75bb338882 Added 2 newer support classes to the runtime.
With those 2 classes the port of the C++ runtime is essentially complete. We now do only bug fixing.
2016-05-12 13:32:10 +02:00
Mike Lischke 313c971cae Bug fixes + update C++ template.
- Also the ArrayPredictionContext has parent references (like the SingletonPredictionContext) which need to be strong refs or we may lose some of the parent contexts if they are not held somewhere else.
- Don't use WCHAR_MIN as lower bounds for char input checks, it's not 0 as you would expect but -2G, making so EOF succeed even though it should fail this check.
- Don't resize the parents array when merging parents + return states in PredictionContext or we will try to access parents outside of the available range.
- Use an unordered set when merging parents in PredictionContext, so that the normal equality pattern kicks in when comparing contexts.
- Some parameters in AbstractParseTreeVisitor where wrongly outcommented where only the param name should.

C++ template:
- No longer include the DEFAULT_MODE in the generated lexer (it's defined elsewhere).
- Corrected formatting and finished some reference rules that were not done yet.
2016-05-12 10:30:40 +02:00
Mike Lischke 23873b4a14 Fixed one more warning in VS. 2016-05-10 10:26:41 +02:00
Mike Lischke d8442c0bf6 Update VS solution (removed deleted file references). 2016-05-10 10:25:06 +02:00
Mike Lischke fda0210b50 Some updates to demo grammar, Cpp.stg and XCode projects.
- Reversed the meaning of grammar sections members + declarations to maintain the same meaning for members between C++ and Java target. Now members are placed in the public section of a class, while declarations use the private section. This change helps to minimize language specific parts in grammar actions.
- Removed deleted cpp files from XCode project.
- Cpp.stg:
  - Renamed all occurences of "result" back to "_localctx" as they appear in the Java.stg file. While the name "result" better fits the purpose the rename increases differences between targets, hence it was taken back, so we can use the same actions in all targets.
  - TokenPropertyRef_text is now complete.
2016-05-10 10:14:40 +02:00
Marcin Szalowicz 5653be36fa Runtime Cpp: disable warnings and remove unnecessary files
Signed-off-by: Mike Lischke <mike@lischke-online.de>
2016-05-09 15:24:03 +02:00
Mike Lischke 0835c52a67 Moved Marcin to Other Contributors list. 2016-05-09 15:06:08 +02:00
Mike Lischke 13b135f4e8 VS warns about /* */ comments if the are directly after a *. 2016-05-09 14:53:41 +02:00
Mike Lischke faddb83fe5 Enabled unused-parameter warning in XCode and fixed all occurences.
Some warnings in generated files cannot be fixed in a general way because usage of parameters depends on the grammar, hence we suppress unused-parameter warnings in the grammar (for lexer and parser files).
2016-05-09 14:51:46 +02:00
Mike Lischke 337f0467a8 Added yet another possible code section + EOF rework.
- @parser::context or @lexer::context are now also accepted for code that should be placed directly before the class declaration (e.g. additional types, like enums etc.)
- Reverted the removal of explicit EOF handling. Thought we can just live with the EOF macro, but that doesn't work out, so we go with the same approach as the ANTLR3 C target: #undef EOF and use EOF member constants as in the original Java code.
- Fixed a crash when trying to create a hash from a null parent in PredictionContext.cpp.
- Generated token and rule enums are now placed in the lexer/parser classes which allows to use them without qualfication within those classes, making so actions in a grammar more language independent. Outside code still has to use e.g. TParser::ID to access them.
- Made some lambda capture lists more explicit. Need to test yet if we can just use a default capture instead.
2016-05-09 14:09:00 +02:00
Mike Lischke 303684dd34 Removed jar that should not have been in the repository. 2016-05-06 17:16:06 +02:00
Mike Lischke 6c21223d2e Added cmake target (Linux + OSX) + fixed a number of warnings.
- Compiling with cmake brought up quite a number of new warnings. Some of them have to be disabled yet (dollar in identifier, four char constant, overloaded virtual). The others have all been fixed.
- Updated the README to include build instruction.
2016-05-06 16:48:59 +02:00
Renata Hodovan 4e3325c9da Fix initialization of ATNConfig when computing SLL prediction
termination condition.

The PredictionMode::hasSLLConflictTerminatingPrediction method aims to
create ATNConfig objects from another ATNConfig and SemanticContext
objects. In case of the Python targets, the initialization
happened without keyword arguments. Since the called __init__
method had default values set for all the parameters, the parameter
substitution worked by indices. As a consequence, the first ATNConfig
parameter was wrongly interpreted as an ATNState and the SemanticContext as
an alternative. The patch fixes this by adding the missing keywords.
2016-05-06 15:59:55 +02:00
Mike Lischke 297f00350c Added more supported grammar sections (named actions).
C++ target:
- More sections are now supported: pre + post include, declarations, definitions (in addition to header and members).
- Added specific variants of these sections for (base)listener + (base)visitor files (baselistenerpreinclude etc.).

Had to add named sections to VisitorFile.java + ListenerFile.java.
Also added the new namedActions parameter to all target stg files where needed.
2016-05-06 12:22:08 +02:00
Mike Lischke f30aa125a5 Updated VS solution after project restructuring. 2016-05-05 13:33:28 +02:00
Mike Lischke 6ac56de5f1 Updated OSX demo project after structure changes. 2016-05-05 13:14:01 +02:00
Mike Lischke a44741a73d No need for public headers in an OSX dylib. 2016-05-05 13:07:24 +02:00
Mike Lischke 5780755196 Reorganized runtime folder structure + created ios target in XCode.
The runtime folder now contains the individual project files for each platform (and associated files/folders). The actual source code moved down one level to folder src.
2016-05-05 13:06:17 +02:00
Mike Lischke a83849a0c4 Missing parts from the previous commit. 2016-05-05 11:50:20 +02:00
Mike Lischke bfe3a7cc63 Renamed XCode demo project and set install name for dylib.
The default install name is /usr/libs/antlrcpp.dylib which makes running the demo from command line not working (location and install name of the dylib differ). Since the probability that the lib is placed in an app bundle is much higher than that the lib is being installed in the system, the default has been changed to just the dylib name. This can be changed to anything else if needed in a concrete project.
2016-05-05 11:45:49 +02:00
Mike Lischke 6939b7f92c Split XCode demo + libraries into individual projects.
In order to allow building the OSX libraries without the demo project they have been split into 2.
2016-05-05 11:12:51 +02:00
Mike Lischke dd43278406 Linux + Mac build fixes.
- Updated XCode project (removed obsolete cpp files refs).
- Set channel datatype in lexer + tokens to size_t.
- Removed one unit test that no longer works, now that we require all objects in a vector given to murmur hash code computation to support the hashCode() function.
2016-05-05 10:17:12 +02:00
Mike Lischke 8ff852640a Updated Windows project to be compilable as both static and dynamic lib.
Removed a few unneeded cpp files on the way.

Note: building as DLL produces many of the well known compiler warnings C4251 (type needs to have a DLL interface ..) because the runtime uses many STL classes in exported classes. I tried exporting all those types via explicit template instantion, but once I hit unordered_map I gave up. Just crazy what you have to export just to make this map export properly (and I already had like 50 exports already in place). So at the end I disabled this warning on project level. So make sure you build this DLL and all binaries using it with exact the same compiler and linker settings (same C++ runtime etc.).
2016-05-04 19:04:33 +02:00
Mike Lischke aa88e7bc30 A bit more complex expression in demo parser.
Forgot to commit that with the last changeset.
2016-05-03 18:13:20 +02:00
Mike Lischke d98f3f7934 Fixed a number of subtle bugs that broke parsing.
Things start looking very promising now. We are ready for runtime tests.
2016-05-03 18:12:04 +02:00
Mike Lischke 6d9d52b45a Solving a tricky issue with prematurely released prediction contexts.
Sometimes in the prediction process temporary ATNConfig instances are created which either share their prediction context with other configs or get a new context which receives the context of another config as parent. Later in the process such temporary configs are released, but the set parent prediction context should stay alive as it is used later. Since there is no top level structure that would keep them alive we need a way to make them stay. For this effect the SinglePredictionContext (which is the only prediction context that keeps a parent reference) uses a shared_ptr instead of a weak_ptr for the parent reference.
2016-05-03 12:09:33 +02:00
Mike Lischke c9c294a729 2 smaller changes
- Changed the empty return state PredictionContext to max int (instead fixing it on int 16), like it's done in the Java runtime.
- Converted 2 static init lambdas in the Cpp.stg to normal code, as VS doesn't allow us to access private class members in such lambdas.
2016-05-02 18:41:10 +02:00
Mike Lischke 185e956f9e VS solution update + compile fixes after latest changes. 2016-05-02 13:50:57 +02:00
Mike Lischke 7b030d601f A C++ runtime fix that caused test parsing to fail with syntax error. 2016-05-01 17:48:18 +02:00
Mike Lischke 89093f7317 Some finetuning in template files for C++.
Also checked parameters for all rules in the template files as there were changes too.
2016-05-01 16:41:18 +02:00
Mike Lischke bfcb0a71cb Switching to current ANTLR revision, final part. 2016-05-01 12:41:32 +02:00
Mike Lischke d4ebdfa138 Switching to current ANTLR revision, part 3.
- Everything from atn + dfa subfolders is updated now.
- IntervalSet changed behavior a bit which needed updated unit tests.
2016-04-30 15:08:28 +02:00
Mike Lischke 99ada0550f We need recursive locks to synchronize access.
We can certainly revert to simple locks, but then have to do synchronization differently than the Java target does, which is not in the scope of the current work.
2016-04-30 13:14:57 +02:00
Mike Lischke 8cd043a6de Switching to current ANTLR revision, part 2.
- Finished adding all new ATN related classes (e.g. profiling infos, lexer actions).
- Introduced a global Ref<X> alias for std::shared_ptr<X>. The previous approach (defining a type individually for each class led to cyclic #includes).
- Converted all ::Ref typedefs and uses to the new Ref template (+ a number of std::shared_ptr<> occurances). Work in progress still, all those occurences will be converted for 100% consistency.
2016-04-30 12:29:50 +02:00
Renata Hodovan 54168905b0 Fix typo in the parser of the Python3 runtime.
The last parameter name of Parser::enterRule in the Python3 runtime
was mistakenly combined with its type. The patch fixes this.
2016-04-30 12:14:31 +02:00
Eric Vergnaud 2a2b6acba1 links update 2016-04-26 13:27:26 +08:00
parrt d430f495ea add comments to "dead" code in serializer. text from Sam Harwell. 2016-04-25 09:49:29 -07:00
Mike Lischke f8341c7820 Switching to current ANTLR revision, part 1.
- Removed rules no longer used in the Cpp.stg.
- Removed CppTarget.java in old place.
- Converted + added most new LexerAction* classes to XCode project.
- Added changes to a number of classes.
2016-04-24 17:55:51 +02:00
Mike Lischke e79f917437 Found a solution to make RVO in ATNDeserializer work.
Visual Studio needs a move constructor. The move assignment is not enough. No need for the copy constructor anymore, so it can go.
2016-04-24 12:12:45 +02:00
Mike Lischke 0e5b501aa8 Merge branch 'feature/templates' into feature/templates-org 2016-04-23 16:42:26 +02:00
Mike Lischke 014d9fd593 Merge branch 'master' into feature/templates 2016-04-23 16:05:10 +02:00
Mike Lischke 217bb23248 Build fix for OSX.
- After enabling the OSX specific variant in the Guid class we have to link to CoreFoundation.
2016-04-23 15:44:25 +02:00
Mike Lischke 5ab89e38bd Demo app on Windows is working now.
- Class ATN is currently leaking states (delete disabled in d-tor) until I have found a solution for the failing return value optimization from ATNDeserializer::deserialize().
- Added member init in BlockEndState.
2016-04-23 15:39:24 +02:00
Mike Lischke 77d0a6c32a Serialized ATN generation changed.
Originally the serialized ATN was coded as a wide string literal with embeded Unicode escapes (where necessary). This might fail on Windows however, as VS is very strict when checking Unicode code points and rejects compilation if it finds undefined code points. Hence this generation has been changed to hex numbers instead of that string literal.
2016-04-23 11:10:12 +02:00
Mike Lischke b2daab9477 antlr4cpp on Windows
- Solved all compilation issues. Updated the antlr4cpp library project. At the moment we only build a static lib. Need to add exports for a DLL. Since we want this library to be compatible with VS 2013 still, we cannot use std::rethrow_with_nested(), hence we do a simple unnested throw in such cases. Starting with VS 2015 this works fully then.
- Added demo application.
- Added parser generation script.
2016-04-23 11:03:30 +02:00
Mike Lischke e85385785e Simplified use of the demo project.
- The needed ANTLR jar is provided now, so it's not needed to build it yourself.
- The generate.sh script has been updated to use the new jar.
- Small update of the readme too.
2016-04-21 17:57:33 +02:00
Mike Lischke e8325623d9 Finished checking all memory allocations.
- All allocations are now checked for proper deallocation.
- Ran LLVM analyzer over the runtime but it found mostly valid stuff and did not find non-freed allocations I left undeleted by intention. So it's not worth much.
- Added move and copy assignment operator overloading, as well as a copy c-tor to ATN class to avoid a copy (and to be able to free content properly) after deserialization.
- Some clean up.
2016-04-20 17:51:24 +02:00
Mike Lischke f292d14abc The parser is parsing for the first time.
- Removed ultra simple test grammar + parser. No longer needed.
- Removed long list of keywords from (regular) test grammar.
- Fixed a number of toString() methods to get better debug output.
- Moved Ref typedefs from Declarations.h to the individual classes as defining them on the forward declarations totally confuses the XCode debugger.
- Removed reference to the owning ATN in an ATNState. We cannot guarantee to have the correct address there due to the way the states are created. The reference is not needed anyway.
- ATNDeserializationOptions now has verifyATN set by default (as in the Java target).
- Had to add a workaround for a weird situation: static initialization in ATNDeseralizer stopped working for no apparent reason. Need to investigate this.
- Added a few support methods to the CPPUtils, mostly to ease debug output creation.
- Added console listener by default to the listeners list (as done in the Java target).
- Fixed translation mistakes in the CommonTokenStream class.
- Fixed some memory leaks and exception handling bugs.
2016-04-17 13:13:15 +02:00
Mike Lischke eb0241f767 Another refactoring round.
- Removed a few unused classes.
- More raw pointers to smart pointers conversion: RuleContext, ParserRuleContext, ParseTree, Token, ParseTreeWalker, Tree...
- BitSet is now used directly instead of all those dynamic allocations and is a derived class instead of a composite.
- Replced ATNState equals with == operator overload.
- Correct wrong iterator over ATNConfigsets.
- Added utilitiy function that mimics Java's generic toString().
2016-04-13 19:05:56 +02:00
Mike Lischke 6f344b376b Fixed all ATNConfigSet memory leaks. 2016-04-09 17:39:38 +02:00
Mike Lischke 7f8ad7bd2d Applied consistent exception model and fixed is<> helper.
- Exceptions are now consistently thrown by value and captured by reference. C++11 exception_ptr and nested_exception are used when exception references are neeeded or when implementing the equivalent of Java's nesting.
- The is<> helper didn't handle properly (const) references, which is now explicitly handled. Added new unit tests for that.
- Fixed a number of places where a catch all was used to implement a "finally" (which hides exceptions).
- Changed exceptions to hold (temporary) raw pointers instead of shared pointers, as otherwise it is tried to free wrapped pointers which might just be references to static objects. Might later be updated again when we continue with removing raw pointers.
- Some smaller fixes.
- The generated simple parser now runs through without any error (yet, it doesn't do anything useful).

- ANTLR C++ target template:
  - Added getListener and genVisitor bool members to ANTLR's LexerFile + ParserFile classes, so can use them in the template.
  - Made addition of listener #include dependent on the new genListener member, which allows to run parser generation without listeners/visitors.
2016-04-09 16:36:52 +02:00
Mike Lischke 091c40899c Finished fixing all C++ TODOs and Java to C++ converter warnings.
Fixed again a few mem leaks.
2016-04-06 18:30:27 +02:00
Mike Lischke 8f2e95516b Removed StringBuilder + stringconverter code.
Both can easily be implement using STL code.
2016-04-06 16:28:05 +02:00
Mike Lischke 3d17066e0c Removed a few unnecessary pointer casts. 2016-04-06 15:12:47 +02:00
Mike Lischke d1b59ca5af Next overhaul (more TODOs fixed)
- Added an even simpler grammar to ease debugging while getting the lib into a working state.
- Added helper template is<> to ease frequent type checks (for value types, ref types and shared_ptr). Added some unit tests for that as well.
- Changed the MurmurHash::hashCode() function to take shared_ptr as this is the only variant we need. Had to change the MurmurHash unit tests for that.
- Removed conflicting IntStream::_EOF (and other variants). We use the C runtime EOF value instead.
- Changed all references to semantic contexts, prediction context and the prediction context cache to use shared_ptr<>. Created *Ref typedefs to simplify usage.
- Adjusted the C++ string templates for that.
- Fixed a number of memory leaks + some cleanup.
2016-04-06 15:07:25 +02:00
Mike Lischke 1ca5b38868 Fixed some TODOs + exceptions.
- Reworked the exception hierarchy to conform with the Java hierarchy (where we mimic that). Ultimative base class is std::exception, which uses std::string (char* actually) for messages, so all exceptions use std::string for that as well. Consider that as first step to rework the entire lib to use std::string instead of std::wstring (with utf-8 for full Unicode support).
- Removed ASSERTException + TODOException and fixed the places where they were used.
- Removed ANTLRException, which was only an intermediate layer without an equivalent on Java side.
- Replaced some equals() calls by == (with defined operator overloading).
- Enhanced Arrays::equals() to ensure it compiles only if the actual types being compared support the != operator (both value + reference types).
- Made the Recognizer class template free by using plain polymorphism. Some adjustments were need also in the Cpp template to support that. Could convert the .inl file to .cpp then.
2016-03-31 18:32:44 +02:00
parrt b92f22769e [maven-release-plugin] prepare for next development iteration 2016-03-30 16:25:49 -07:00
parrt 567fcc6311 [maven-release-plugin] prepare release antlr4-master-4.5.3 2016-03-30 16:25:45 -07:00
parrt cd0913712a set code string versions to 4.5.3 2016-03-30 16:21:50 -07:00
parrt 3d21617e30 need blank ctor 2016-03-30 13:11:33 -07:00
Mike Lischke 29dedd17c4 New unit tests + template enhancements + more memory handling work
- Added IntervalSet unit tests. Fixed a few bugs found by that.
- Enhanced the demo grammar so that we use as many as possible template rules from Cpp.stg. Still not fully done it seems.
- Fixed bugs in size determination for arrays (vectors now).
- Simplified PredictionContext and SemanticContext (one template parameter less).
- Removed no longer used Utils.h/cpp. Fixed CPPUtils.h/cpp.
- Extended LexerXXCommand template rules to take a new grammar parameter (code gen has been updated) as we need this context in the Cpp target. This change requires to update all existing templates! Cannot do here as this is an old revision.
- Some cleanup.
2016-03-30 20:11:05 +02:00
parrt 9e98714a1d Add ability to set parse tree internal node super class with option contextSuperClass. Provide impl in Java target that has altNum backing field. Add test across targets to set/get alt num. Fixes #1152. 2016-03-30 11:00:47 -07:00
Terence Parr 9c440c5b89 Merge pull request #1139 from dtymon/06_fix_SemanticPredicate
JS: SemanticPredicate should be SemanticContext
2016-03-30 16:39:18 +00:00
Terence Parr 4deb708cd8 Merge pull request #1138 from dtymon/05_fix_OR_toString
JS: Fix copy-and-paste error in OR SemanticContext toString() method
2016-03-30 16:39:08 +00:00
Terence Parr 0c804f0a28 Merge pull request #1137 from dtymon/04_lexerActionExecutor_equals
JS: Do deep Actions array comparison in LexerActionExecutor equals()
2016-03-30 16:38:56 +00:00
parrt 90d753b08a Add getMaxTokenType for C# vocab object like https://github.com/antlr/antlr4/pull/1146 2016-03-29 16:14:53 -07:00
parrt ac1637c0bd add get max token type to vocab. 2016-03-29 16:02:33 -07:00
parrt 1356186f65 add get max token type to vocab. 2016-03-29 15:55:02 -07:00
parrt 41a196082d Merge branch 'master' of github.com:antlr/antlr4 2016-03-29 14:40:17 -07:00
parrt e4a4253219 more impl of get/set alt num; update doc 2016-03-28 14:10:29 -07:00
Martin Steiger 6ca812e255 Add Vocabulary.getMaxTokenType() 2016-03-28 22:08:31 +02:00
parrt fa10ca678f add method to RuleContext 2016-03-28 11:35:44 -07:00
Mike Lischke baef9b0b32 New unit tests for Interval + MurmurHash.
While testing Interval() and Interval::of() I found that the latter is twice as slow as the normal object creation. Seems caching single element intervals doesn't have the same impact as in Java (quite the opposite), so I removed Interval::off and the interval cache.

The MurmurHash implementation was actually for a 32bit platform, so I added a 64 bit version too (stripped down from 128 bit MurmurHash3). Tests cannot directly check the correctness of the algorithm, but duplicate checks over 300K hashs (for short input, which is more prone to duplicates than longer input) showed there are no duplicates. So I take it that the code is good.

Fixed a hash creation bug in PredictionContext.cpp.
2016-03-28 18:15:50 +02:00
Mike Lischke 3f78367457 Next overhaul
- Added first real unit test set and enable code coverage collection in XCode (for ANTLRInputStream).
- Reworked ANTLRFileStream::load, which is now more flexible (supports Unicode BOM + 3 possible encodings), can load from Unicode file names and has almost no platform code.
- Enabled strict data size and sign checks in XCode (clang) and fixed a million places...
- Started converting int to size_t where it makes more sense.
- Started working on const correctness.
- Fixed a ton of memory leaks.
- The ATN and ATNConfigSet classes now entirely work as value types. Same for Interval(Set). These seem to be the most critical data structures (ATNConfig + ATNState are pending).
- The abstract IntSet class is gone now.
- Murmur hash code now works with size_t instead of int (need to add unit tests for that).
- Fixed a number of TODOs and other smaller things.

- The Cpp template now properly handles grammar rule return values.
2016-03-27 22:01:03 +02:00
Mike Lischke bc81acba06 An attempt to cut the Gordian knot called Java generics, in C++.
- Reworked the ATNConfigSet + the config lookup implementation it uses. The new implementation no longer needs the hand written Array2DHashSet class but instead relies now on std::unordered_set with custom hasher and comparer classes.
- Fixed a bug where the ATNConfigSet was deriving from std::set while in the original Java code it only implements the Set interface (not the config set itself is a set but the config lookup is). As a consequence all iterations over ATNConfigSet now iterate over ATNConfigSet->configLookup.
- Removed the Any class as it didn't solve the problems we had mind.
- Removed the no longer necessary Array2DHashSet, AbstractEqualityComparer and ObjectEqualityComparer classes.
- Instead there is a new ConfigLookup implementation with a templated config lookup implementation.
- Removed ATNConfig::equals, as this is already implement in the == operator overloading. So the operator is used instead where needed.
2016-03-26 11:01:51 +01:00
Mike Lischke e97820a27e Reworked handling of ATN instances throught the code + definition of IRecognizer.
ATNs are top level structures, which are created and kept by parser/lexer classes (or their simulator equivalents). Hence there are now value types in their controlling class and passed around as const &.

IRecognizer was a template class without real need, which has been changed to make it a simple interface easily usable without having to find C++ hacks for fancy Java wildcard generics.
2016-03-24 11:49:44 +01:00
Mike Lischke 2aa40c779e Removed the need for a separate VectorHelper class + other improvements.
Some cleanup too.
2016-03-22 17:55:57 +01:00
Mike Lischke 9006d241fa Introduced the Any class (based on some public domain code).
The Any class is loosly modelled after boost::Any and allows us to use equals() and hashCode() functions to be used where we have no common base class (like Java's Object class). By introducing this class we can replace all void* occurances that would otherwise not work.
2016-03-21 20:50:36 +01:00
Mike Lischke 6df5d025bf Complete formatting overhaul.
- Reformatted every single file to have a consistent indentation style using only space chars, with 2 chars per indentation. Reduced huge indentation due to deep namespace nesting by not indenting namespaces.
- Reduced #include usage to a minimum.
- Made copyright header the first entry in all files.
- Moved the previously mac-only prefix file (antlrcpp-Prefix.h) to the runtime. It can now be used by all platforms and includes all necessary standard headers.
- Removed a number of unused files.
2016-03-20 17:21:46 +01:00
Mike Lischke fec65477d8 ATN deserialization + some initialization and memory leak fixes
- ATN deserialization finally works.
- Changed a number of pointer to STL classes to just the STL classes and pass them around by const & where necessary.
2016-03-19 17:18:06 +01:00
Mike Lischke 11571fa092 A few more adjustments to make the merged changes work with this revision of antlr. 2016-03-18 15:27:17 +01:00
Mike Lischke 1672bc0739 Added all changes done so far. Since we are here on a very old revision I cannot simply merge, so all files have manually been copied and we have no history for these changes. 2016-03-18 14:22:42 +01:00
Mike Lischke 815856bdf0 Initial demo app setup + backend changes.
- The demo now uses a real setup to parse something and print output.
- Replaced empty UUID implementation by the guid implementation from Graeme Hill. Fixed uuid handling in a few places.
- Removed some obsolete (and mostly empty) lib files.
- Mac: the XCode project now does regenerate the files only after a grammar change, not always.
- Simplified ATNDeserializer + ATNSerializer and fixed a few things there (e.g. feature determination, duplicate copy op of the input).
- Removed some deprecated functions from ATNSimulator.h
- Fixed some bugs (e.g. uninitialized vars + leaks).
- Corrected a mistake I did in CppTarget which lead to wrong serialized ATN output.
- Cpp template:
  - Added proper static init code generation for Lexer + Parser classes.
  - Added some missing functions.
2016-03-18 09:59:09 +01:00
Mike Lischke 7e09002ebc First working version of a demo app that uses the new C++ target.
- Created a new command line target in the XCode project. Win + Linux yet outstanding.
- Reorganized the C++ runtime folder structure a bit
  * Put everything in a new folder "runtime"
  * Added a "demo" folder for the demo grammar + app
  * Renamed Apple folder to Mac in demo folder
  * Added a script with some descriptions to run parser regeneration (via jar or classes). This is also used in the XCode project to regenerate the files.
  * Moved all C++ runtime files up in the folder hierarchy. No need to mimic the deep nesting from Java.
- Some adjustments here and there in the C++ runtime for consistency.
- Overhaul of the Cpp.stg file to produce compilable code. Extracted file level templates into a new template Files.stg. Experimented with new named actions (@parser::listenerheader) but the result is not satisfying yet. Need to investigate more.
- Extended ANTLR to produce header files if a target class returns true in the new function needsHeader().
- Added generated folder from demo to .gitignore
- Added myself to contributors file + maven xml.
2016-03-15 21:02:47 +01:00
David Tymon eb5af71a30 JS: ATNConfig can incorrectly change "alt" of 0 to null
When an ATNConfig instance is created with an alt of 0, it is
possible for it to be incorrectly changed to null due to its
"falsey" nature.
2016-03-15 13:38:55 +11:00
David Tymon 5e176e405f JS: SemanticPredicate should be SemanticContext
AND.evalPrecedence() method is attempting to invoke a method on a
non-existent class "SemanticPredicate". It should be using
"SemanticContext" instead.
2016-03-15 13:32:48 +11:00
David Tymon 0dbb12ad1a JS: Fix copy-and-paste error in OR SemanticContext toString() method
- the OR toString() method was incorrectly added to the AND prototype
2016-03-15 11:00:36 +11:00
David Tymon 0262aac8f6 JS: LexerActionExecutor equals() should do deep comparison of Actions array
- according to the corresponding Java implementation, the equals()
  method for LexerActionExecutor should be doing an equals() test
  on each of the actions rather than testing the Array reference
  is equal.
2016-03-15 10:55:17 +11:00
Mike Lischke fcdff98aa6 Added my homepage to readme. 2016-03-06 13:46:27 +01:00
Mike Lischke fc1ae35963 Some fixes for readme.
Added myself there too.
2016-03-06 13:22:35 +01:00
Mike Lischke d0d7d23d6c Removed binary build file from Visual Studio solution from repo. 2016-03-06 13:19:29 +01:00
Mike Lischke 72d6e3b400 Add current C++ target runtime from antlr4cpp (Dan McLaughlin). 2016-03-06 13:16:40 +01:00
Terence Parr d0fb48c2b8 Merge pull request #1103 from ericvergnaud/master
latest version of honey-require
2016-02-10 12:40:53 -08:00
parrt ae8ea836fc reopen PR #1081 2016-02-09 11:47:54 -08:00
Eric Vergnaud b0196bc86e fixes #1108 2016-02-09 10:25:31 +08:00
Eric Vergnaud 7a59e92b8d latest version of honey-require 2016-02-02 21:01:28 +08:00
Peter Boyer 1ccaad7ae1 Fix incorrect assignment of stop token 2016-02-01 11:27:49 -05:00
Terence Parr 184f711753 [maven-release-plugin] prepare for next development iteration 2016-01-30 10:01:53 -08:00
Terence Parr dcca95d4f0 [maven-release-plugin] prepare release 4.5.2 2016-01-30 10:01:48 -08:00
Terence Parr c92ddcbd06 update version to 4.5.2 in source / packaging stuff. 2016-01-30 09:54:47 -08:00
Terence Parr 8fbf46b2f2 why oh why does intellij skip changes when i push? 2016-01-28 20:16:49 -08:00
Terence Parr 9a053d63b1 Merge pull request #1084 from dtymon/03_lexerActionExecutor_hash_string_clash
JS: LexerActionExecutor cached hash string name clashes with function
2016-01-28 11:11:15 -08:00
Terence Parr da27381fc1 Merge pull request #1083 from dtymon/02_ll1analyzer-incorrect_atnconfig_ctor
JS: LL1Analyzer passing PredictionContext incorrectly to ATNConfig ctor
2016-01-28 11:11:01 -08:00
parrt 34787c0fd8 Merge branch 'patch-1' of git://github.com/cooperra/antlr4 into cooperra-patch-1 Fixes #1081 2016-01-28 10:54:47 -08:00
Terence Parr 49cc92aa35 Merge pull request #1060 from ericvergnaud/missing-js-visitor-methods
fix #1058
2016-01-28 10:51:21 -08:00
parrt 7e6af55245 Merge branch 'master' of github.com:antlr/antlr4 2016-01-28 10:49:23 -08:00
parrt 5299d436aa Merge branch 'patch-1' of git://github.com/cooperra/antlr4 into cooperra-patch-1
# Conflicts:
#	contributors.txt
2016-01-28 10:47:03 -08:00
Peter Boyer 89f1192cb6 Fixes to Go runtime, tool 2016-01-21 19:31:30 -05:00
Peter Boyer 92b8f9f891 Various test fixes 2016-01-19 10:44:16 -05:00
Peter Boyer 86d65cf719 Fix lexer test failures 2016-01-16 17:11:00 -05:00
Peter Boyer 8f70a6f553 Fix test and GetRuleInvocationStack 2016-01-13 21:19:13 -05:00
Peter Boyer c8b73c99ea Fix issue where recovering tests returned nil by using named return value 2016-01-12 23:56:00 -05:00
Peter Boyer da94e5295e Fix some tests 2016-01-12 23:14:38 -05:00