Commit Graph

2067 Commits

Author SHA1 Message Date
Mike Lischke 1c3a5879e6 Set required runtime version to 4.6. 2016-11-07 11:22:46 +01:00
Mike Lischke 92b032820e Merge branch 'master_upstream' 2016-11-07 11:19:12 +01:00
Mike Lischke 3b3fe3da57 Merge branch 'master_upstream'
Had to resolve a number of conflicts + added code required for the C++ target to generate header files, after the recent changes in the main repo.
2016-11-07 11:16:02 +01:00
parrt ffaedd209d Set version in code to 4.6. 2016-11-06 11:21:06 -08:00
parrt e5ec462e22 Fixes #1337. Add's sync() call back to LL(1) decisions; all targets updated (causing failed test in Go). Altered test for new output of errors. regen'd tests. 2016-11-06 09:45:40 -08:00
parrt 95c850e5f8 set version in prep for 4.6 2016-11-05 16:48:36 -07:00
Peter Boyer fc35818c52 Update import statements after merge 2016-11-05 16:36:53 -04:00
parrt 0799e838bb weird. missed a few files. these are to simplify get filename functionality. 2016-11-05 09:32:04 -07:00
parrt abdb0b6a46 Merge branch 'model-updates-for-new-targets' of github.com:parrt/antlr4 into reduce-model-changes 2016-11-05 09:29:25 -07:00
parrt 2c98b5d325 incorporate in a single commit all changes needed to support generating header files. many fewer diffs with C++ target codegen now. 2016-11-05 09:25:51 -07:00
parrt 6d022379bc Pull in parrt's branch 'model-updates-for-new-targets' which appears to have freshened some non Go stuff as well. Simplify Go filename construction. 2016-11-05 08:48:37 -07:00
parrt 40e19e5d37 refactor so getRecognizerFileName() etc... delegate to Target; default is same behavior. adds "is header" arg as well in prep for C++ 2016-11-05 08:08:08 -07:00
parrt 75794a588b track different types of StructDecl elements so Go can do setters/getters. 2016-11-05 07:35:57 -07:00
parrt c0cedc424b track different types of StructDecl elements so Go can do setters/getters. 2016-11-05 07:35:39 -07:00
Mike Lischke e71e95080a Merge branch 'master_upstream'
Also updated the list of ignored tests in the Cpp.test.stg file (lke it is done for the other targets).
2016-11-05 15:07:59 +01:00
parrt 8b8094c044 appears to be an ST bug that doesn't see arrays of len 0 as missing; convert array to List. 2016-11-05 06:55:09 -07:00
parrt e0521400cb rm need for isRuleContext in templates; refer to underlying grammar object. 2016-11-05 06:28:58 -07:00
parrt 85f2a87840 rm recognizerName field where possible 2016-11-04 16:07:45 -07:00
parrt 95dbf7b44b look for go in path during tests 2016-11-04 16:06:41 -07:00
kai stammerjohann f3c55be33c fix RulePropertyRef_stopHeaderHeader typo 2016-11-01 09:17:46 +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
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
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
Christian Gudrian cb590334bb the visit methods now return a value 2016-10-06 22:52:19 +02:00
Christian Gudrian eb292adb18 implemented templates for the JavaScript visitors 2016-10-06 22:52:19 +02:00
Peter Boyer 9b76bc6a71 Update Go.stg 2016-10-05 12:04:01 -04: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 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 4394cd20b0 Merge branch 'master_upstream' 2016-09-29 16:50:57 +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
Christian Gudrian 46df58d5d7 The JavaScript ParseTreeVisitor now implements a depth-first traversal by default. 2016-09-22 08:28:11 +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 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
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
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
Will Faught 7f42bc602b Add interface build checks for tree types and generated base listeners 2016-07-18 12:19:31 -07:00
Nathan Burles 9fa56a4cd9 Added lexer channels enum to match Java target 2016-07-07 14:04:01 +01:00
Will Faught a05dea54ec Fix test case build errors 2016-07-06 09:02:42 -07: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
Eric Vergnaud 15430d4bf9 remove unwanted semicolon in generated Python code 2016-06-23 15:06:49 +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 c8a9d75cfe Merge pull request #21 from wjkohnen/gofmt
tool/Go: gofmt generated code.
2016-06-14 16:26:36 -04:00
Mike Lischke 0814d49cf6 Small alt check fix in LexerATNSimulator. 2016-06-14 14:05:18 +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