Commit Graph

4956 Commits

Author SHA1 Message Date
kai stammerjohann f3c55be33c fix RulePropertyRef_stopHeaderHeader typo 2016-11-01 09:17:46 +01:00
kai stammerjohann 1feef18e3e ParserRuleContext init members 2016-11-01 09:06:27 +01:00
Mike Lischke f794820aaf Reworked mutex handling + updated C++ template for a var init
- Mutexes have been consolidated. Instead of one per DFA (which can easily get to hundreds of them) we only have one mutex in the Recognizer class and all other parties use this for serialization. It's only about protected the DFA anyway, which is stored in a recognizer (lexer/parser).
- ATNState::getStateType() returns a size_t value now (actually an enum).
- Replaced checks via RTTI for transitions by the (serialization) type of the transition, for simplicity.
- Added some missing initialization for fields in certain ATN state classes.
- Fixed mem leak in DFA by shadowing the s0 field. That way still have a ref to the self created instance, even is s0 was replaced later.
- Added variable init in code generation for a rule context declaration (e.g. for labels).
2016-10-29 14:46:38 +02:00
Mike Lischke c9f85f1d6a Merge pull request #41 from FloorGoddijn/master
cpp runtime: updated the vs2013 project reflecting the last changes
2016-10-22 16:10:35 +02:00
Floor 951d0f06d7 cpp runtime: updated the vs2013 project reflecting the last changes 2016-10-21 13:07:15 +02:00
Mike Lischke 9e77edcb34 ATNState::transactions improvements
The transaction field was access with trivial getters and setters which server no real purpose, so I made the vector public and remove all the obsolete accessor functions. This simplifies the API (e.g. use .size() instead of getNumberOfTransitions()).
This change required a few other changes in runtime.

Additionally, I radically cut down the ATN::toString method to return only what the Java runtime is doing instead of a full dump of the state and it's transitions.
2016-10-14 17:10:00 +02:00
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
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
Mike Lischke 2e92b38bf7 Updated unit tests after last refactoring. 2016-10-06 17:17:36 +02:00
Mike Lischke 6c225337ae Trying a different compiler in Travis CI. 2016-10-04 11:02:40 +02:00
Mike Lischke e8f00f8074 Another attempt for Travis CI. 2016-10-04 10:51:14 +02: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 a7b9499230 Code generation + Travis CI fixes.
- Had to adjust a comparison <= 0 to the new unsigned EOF.
- For testing: extended the runtime tests to all C++ tests.
- Install uuid-dev in Travis CI in order to be able to build the C++ runtime.
2016-10-03 11:25:02 +02:00
Mike Lischke 70fd9527a4 C++11 for Travis CI. 2016-10-02 17:01:16 +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
Terence Parr e9aa00e05b Merge pull request #1172 from renatahodovan/default-pass
Add missing default pass statements to Python targets.
2016-09-25 11:24:48 -07:00
Terence Parr 5ea09b30f2 Merge pull request #1255 from renatahodovan/pythonic-python
Make Python targets more pythonic.
2016-09-25 11:24:07 -07: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 3b98c1136e Merge branch 'master_upstream' 2016-09-25 11:31:51 +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
parrt 0b2d5304a5 tweak links in doc 2016-09-24 11:20:13 -07: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
Terence Parr 683cbee2e7 Merge pull request #1261 from BurtHarris/fixGitignore
Fix .gitignore for codegen/target language directory
2016-09-23 15:24:52 -07:00
Burt Harris 10f5ebe22a Repair comment 2016-09-23 15:02:38 -07:00
Burt Harris 8e44b19ec9 Update .gitignroe fules for VisualStudio etc.
Avoids temp and user-preference files from getting commited
2016-09-23 14:58:21 -07:00
Burt Harris 9a7e0b5e4e Merge branch 'master' into fixGitignore
These are changes from the upstream master.
2016-09-23 14:47:33 -07:00
Burt Harris fdfe97c813 Merge branch 'master' of https://github.com/antlr/antlr4 2016-09-23 13:46:45 -07:00
parrt 2f92b47500 tweak links in doc 2016-09-23 13:19:44 -07:00
Terence Parr 5b461ddd77 Merge pull request #1268 from andjo403/windowsPaths
update the runtime paths to work in windows
2016-09-23 13:12:28 -07:00
Terence Parr 401f53fa3c Merge pull request #1289 from ericvergnaud/docs
Enhancing the doc
2016-09-23 10:11:34 -07:00
Eric Vergnaud d3ceee5043 Enhancing the doc 2016-09-24 00:02:18 +08:00
Mike Lischke 1df9d54e05 Reverted all Travis changes. Didn't do what I expected. 2016-09-07 21:13:01 +02:00
Mike Lischke 82a22b51a4 Trying to counter weird Travis error. 2016-09-07 21:08:46 +02:00
Mike Lischke 5afa240b97 Add Travis settings necessary for C++11 compilation. 2016-09-07 21:04:38 +02:00
Mike Lischke b0fc8ea0da Added semicolon generation after some of the header decls.
Closes issue #40.
2016-09-06 09:51:31 +02:00
Mike Lischke 6f31e94cb9 Merge pull request #39 from nburles/fix-utf8-bom
Second parameter is end pointer, not size
2016-09-02 13:58:48 +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
Andreas Jonson 6e780c90bb update the runtime paths to work in windows
the old paths contained a / at the beginning of the path e.g. "/C:/" but the expected path is "C:/" and due to this all test for the targets javascript, python and c# failed on windows.
2016-08-19 23:27:08 +02:00
Andreas Jonson 71a2a1295f update the runtime paths to work in windows
the old paths contained a / at the beginning of the path e.g. "/C:/" but the expected path is "C:/" and due to this all test for the targets javascript, python and c# failed on windows.
2016-08-19 22:22:05 +02:00