Commit Graph

2354 Commits

Author SHA1 Message Date
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
Sebastian Kürten 2f628a1106 Fix another typo 2016-11-01 11:56:46 +01:00
Sebastian Kürten 8b16ff180a Fix a few typos in Javadoc 2016-11-01 11:46:04 +01: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
Sebastian Kürten 961f087d7a Allow paths as tokenVocab option 2016-10-25 10:31:04 +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
Will Faught 81b464a375 fixup! Fix the layout of some generated Go code 2016-06-10 22:39:36 -07:00
Will Faught c3d6c20ee4 Fix the layout of some generated Go code
And some related fixes.

- Combined multiple blank lines between package decls into one
- Moved some doc comments to just above what they document
- Changed some doc comments to start with the documented thing's name
- Removed some redundant anchor and wrap ST options
- Changed an empty struct type containing just a newline to struct{}
- Added some missing doc comments to exported interface methods
- Removed unneeded parentheses around a single import
- Prevents generating empty const blocks
- Generates single-line package const decls if only one decl
- Indented switch case bodies
- Content checks for some template vars, e.g. if v defined then v else nothing
- Removed template redundancies, e.g. from <attrs:{a | <a>}> to <attrs>.
- Removed blank lines that group embedded types and fields separately
- Changed some trivial one-line func/method decls to mult-line
- Changed empty package slice decls to use nil, e.g. var foo []uint16
- Changed const int enums that used the ST <i> var to use iota instead
- Replaced separator in GoTarget.encodeIntAsCharEscape with a template separator
2016-06-10 14:18:02 -07: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
Wolfgang Johannes Kohnen bc5d6e9c4d tool/Go: gofmt generated code.
* gofmt can be disabled with property -Dantlr.go.disable-gofmt=true or
   setting env ANTLR_GO_DISABLE_GOFMT=true
2016-06-08 17:36:04 +00:00
Mike Lischke 3a95a36e3f 12% speed improvement for C++ runtime. 2016-06-07 16:27:25 +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
Peter Boyer 6d881c395d Merge pull request #23 from willfaught/fmt
Fix whitespace in generated Go code
2016-06-05 17:49:34 -04:00
Peter Boyer 1bf006bd91 Merge pull request #22 from wjkohnen/predef-idents
tool/Go: Add predefined identifiers to list of keywords.
2016-06-05 14:51:43 -04:00
Mike Lischke 73248ac2e3 Some changes in the C++ target doc + a some template fixes.
- Avoiding double semicolons is tricky with the kind of rule nesting. Previous changes for that caused the tests to break as there were semicolons missing then.
- VS complained about the shift code generated using 1L as base, which is signed. Changed that to 1ULL, which is what is actually intended.
- Reverted the change to avoid a warning in RuleSempredFunction() in Cpp.stg as the fix didn't work 100%. We need a different solution.
2016-06-05 14:35:11 +02:00
Will Faught 94ded73cba Change multi-line template signatures into one line 2016-06-04 21:54:59 -07:00
Will Faught a94377d2a5 Add space after commas separating two vars 2016-06-04 21:52:36 -07:00
Will Faught 06e4bb1cd1 Add spaces around template var binder "|" 2016-06-04 21:50:12 -07:00
Will Faught 6a89c4529e Remove line-ending semicolons 2016-06-04 21:47:48 -07:00
Will Faught fc275721b8 Add spaces around == and != 2016-06-04 21:47:14 -07:00
Will Faught d4d46b2930 Combine multiple spaces around ::= into one 2016-06-04 21:44:07 -07:00
Will Faught 4cdc421ce7 Replace 4 spaces with a tab 2016-06-04 21:40:56 -07:00
Wolfgang Johannes Kohnen 696820e2ea tool/Go: Add predefined identifiers to list of keywords. 2016-06-04 13:13:02 +00:00
Mike Lischke b8867c732d Fixed warning in C++ code generation and remove obsolete file. 2016-06-04 13:04:01 +02:00
Wolfgang Johannes Kohnen 4f8951e5ef tool/Go: enable -package option
see antlr/antlr4/issues/1204, pboyer/antlr4/issues/13
2016-06-03 12:20:39 +00:00
Mike Lischke ac664a91b8 A few more fixes. 2016-06-02 17:32:19 +02:00
Mike Lischke be2e71130a TestListeners C++ tests pass now.
- Needed a few adjustments in the test templates for this, which required to change target test templates for all other languages too.
2016-06-02 10:18:19 +02:00
Mike Lischke 6bf1193839 All tests of TestLeftRecursion.java now pass.
- Fixed all disabled tests and enabled them.
- Some more adjustments of the test template + target template was needed.
- Worked on semicolon usage in Cpp.stg to avoid double semicolons. Might need more work, tho.
2016-06-01 12:08:13 +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
Will Faught 52028c52ce Prevent generated file header from being package doc 2016-05-31 19:09:50 -07:00
Will Faught 6515a84d63 Change generated file header to full sentence 2016-05-31 19:09:40 -07:00
Mike Lischke 814a1821be TestParserErrors passes now.
Fixed a bug in the Cpp.stg file where more input was consumed than should be.
2016-05-30 16:27:12 +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
Mike Lischke a0665677c1 Lots of fine tuning to get more tests passing. 2016-05-27 22:38:42 +02:00
Will Faught 9562d87d49 Change willfaught/antlr4 to pboyer/antlr4 2016-05-26 23:43:43 -07:00
Will Faught 8d863ea19c Change antlr/antlr4 to willfaught/antlr4 2016-05-26 23:38:51 -07:00
Will Faught b503116e12 Move runtime/Go/src/antlr to runtime/Go/antlr 2016-05-26 11:51:28 -07:00
Mike Lischke 95b7f488a4 Merge branch 'master' into feature/addtests 2016-05-26 12:21:43 +02:00
Mike Lischke 27b76b5a33 Fixed token toString() so it produces the output expected by the tests. 2016-05-26 12:20:26 +02:00
Peter Boyer 31d21ff4db Update templates 2016-05-25 17:20:38 -04:00
Mike Lischke 89c01af247 Merge branch 'master' into feature/addtests 2016-05-24 17:40:29 +02: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
David Sisson b3a17b00a2 Set up so we compile link all of the files in the test directory. Does not run the binary afterwards, but that's because there's still a print being generated somewhere (and I have no idea where it's coming from). 2016-05-24 01:44:17 -07:00
David Sisson c8e60b7fe0 Down to one issue -- tree::ParseTree and tree:RuleNode aren't related as they are in some tests. Need to find either the right relationship or come up with an alternative test. 2016-05-21 15:59:22 -07: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 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 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 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
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 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
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 0fada33ceb Fix for a weird lambda execution problem in Windows.
One of the lambdas used in a "finally" expression executed already while defining the "finally" instance, which is way too early of course (others did not show this behavior), which happens only with the Visual Studio compiler, not clang. By changing the capture list to a general reference capture things started working as they should.
2016-05-05 10:02:36 +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 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 886600ed55 Fixes to make ANTLR and it's tests fully compile.
- Fixed a few merge errors.
- Added grammar parameter to all target stg files that had been introduced for the C++ target.
2016-05-01 13:11:29 +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 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 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
Renata Hodovan 7562bb3b45 Add missing default pass statements to Python targets.
The default pass statements were missing from the LL1AltBlock's
template in case of Python targets, which generated conditional statements
without body in some cases and ended in syntax error. The patch fixes this.
2016-04-13 21:21:07 +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 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 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 b78e0e9c1e add test and a guard in action translator. minor. Relates to https://github.com/antlr/antlr4/issues/1143 2016-03-30 11:17:57 -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
parrt 7d16438a19 only gen "set stop token" if finally/after actions exist. 2016-03-30 09:48:33 -07:00
Terence Parr b05d86c150 Merge pull request #1131 from gagern/setStopToken
Set stop token in postamble
2016-03-30 16:43:07 +00:00
Terence Parr 69ff2669ee Merge pull request #1117 from ericvergnaud/python-del-keyword
added missing del keyword to Python targets
2016-03-30 02:29:51 +00:00
parrt 196c4d5913 argh! cutt out too much last push 2016-03-29 16:46:48 -07:00
parrt 3a48085f90 a piece of another branch snuck in! del. 2016-03-29 16:45:17 -07:00
parrt eeea98c00b tweak to michaelpj's PR; alter name. Indicate this fixes #1048. 2016-03-29 15:28:36 -07:00
parrt f2cbc6eb7c Merge branch 'left-recursive-prefix-alternatives' of git://github.com/michaelpj/antlr4 into michaelpj-left-recursive-prefix-alternatives 2016-03-29 15:23:59 -07:00
parrt 1beb8feb4f add "return" to python3 keywords 2016-03-29 14:44:17 -07:00
parrt 41a196082d Merge branch 'master' of github.com:antlr/antlr4 2016-03-29 14:40:17 -07:00
Terence Parr 9655a92d50 Merge pull request #1149 from Wingpad/master
Fixing Issue #1148
2016-03-29 21:39:43 +00:00
parrt cd9ed40ab0 Merge branch 'master' of github.com:antlr/antlr4 2016-03-28 15:32:42 -07:00
Martin von Gagern 2c71663a97 Fix Javadoc errors
This fixes all errors (but not the numerous warnings) reported by
Oracle JDK 1.8.0_72 in a simple run of “mvn javadoc:javadoc”.
2016-03-28 23:46:18 +02:00
parrt e4a4253219 more impl of get/set alt num; update doc 2016-03-28 14:10:29 -07: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
Justin Szaday 93b1fa53b4 Fixing Issue #1148, Python Target Generates Invalid Code With Rule Named 'Return' 2016-03-25 22:16:54 -05: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 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
Mike Lischke 29ee73bd0a Separated top level file rules into an on ST group file.
Started formatting output and adding std::shared_ptr<> where needed.
2016-03-07 18:10:11 +01:00
Martin von Gagern e3e3f2bca0 Set stop token in postamble
This ensures that the stop token has been set before the @after action gets
executed.
2016-03-07 15:03:32 +01:00
Mike Lischke a524ca3232 Corrected package and some imports in CppTarget.java. 2016-03-06 19:34:45 +01:00
Mike Lischke e6b4ea736d Moved CppTarget.java to the target subfolder where the other targets are.
Corrected .gitignore which excluded target folders too generously.
2016-03-06 18:57:28 +01:00
Mike Lischke 1cec262cee Merge branch 'master' into feature/templates 2016-03-06 13:06:47 +01:00
Michael Peyton Jones 5967674531 Track 'prefix' and 'other' alternatives together
These alternatives are not treated differently after they are created,
and we want to retain their alternative ordering.
2016-02-22 13:05:38 +00:00
Eric Vergnaud 99b2d6616f added missing del keyword to Python targets 2016-02-18 23:39:51 +08:00
Peter Boyer b10827d91c Cleanup 2016-02-01 11:27:35 -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
Peter Boyer e891d55f1b Cleanup 2016-01-29 13:14:22 -05:00
Peter Boyer b2ee7fe532 Allow customization of output file names from tool 2016-01-29 12:21:56 -05: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 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
Peter Boyer 7fc028409e Fix some more tests 2016-01-12 09:42:29 -05:00
Peter Boyer 7473c21b1e Even more test fixes yayaya 2016-01-08 16:57:54 -05:00
Peter Boyer 857600be43 Numerous test fixes 2016-01-08 09:28:38 -05:00
Peter Boyer b53e85afd2 Fix issue with code gen 2016-01-07 17:06:31 -05:00
Peter Boyer 096f26d3ae Minor fixes for left recursive rules 2016-01-07 09:46:00 -05:00
Peter Boyer 21999adb6e Fix a bunch of compiler errors in Go runtime-testsuite 2016-01-06 19:12:37 -05:00
Peter Boyer 81b47eedd7 Various minor fixes 2016-01-05 17:05:12 -05:00
Peter Boyer 960c59e373 Fix more issues in code generation 2016-01-05 12:16:35 -05:00
Peter Boyer 977a1c3ae7 Fix issue with tests 2016-01-05 09:30:28 -05:00
Peter Boyer f2852686a7 Some of the runtime-testsuite tests now pass 2016-01-04 14:57:47 -05:00
Peter Boyer fa46c498af Export some additional interface methods, fix issues with ParseTreeWalker, generate base Listener with tool 2016-01-03 22:07:43 -05:00
Peter Boyer 39c1321d40 More, more refactoring cleanup 2015-12-31 17:53:41 -05:00
Peter Boyer ddb296cf01 More refactoring and cleanup 2015-12-31 15:36:56 -05:00
Peter Boyer efa8676211 Go impl emits exact same debug messages as JS impl. Yessss.... 2015-12-29 16:37:17 -06:00
Peter Boyer c08a19233c More bug fixing and debugging 2015-12-28 20:31:56 -06:00
Peter Boyer 1dfc764df7 Fix issues found while debugging 1 2015-12-25 16:10:02 -06:00
Peter Boyer ce20f3ff31 More cleanup to ensure embedded fields are initialized 2015-12-24 17:02:28 -06:00
Peter Boyer 8cba3ecc3a Repair init methods 2015-12-24 15:10:55 -06:00
Peter Boyer 694096d517 Init stuff correctly 2015-12-24 14:56:44 -06:00
Peter Boyer 36ae2795f8 Everything compiles and gens properly for Arithmetic example 2015-12-24 14:49:44 -06:00
Peter Boyer a2e273c5f6 Stub out runtime-testsuite test generator 2015-12-23 18:10:47 -06:00
Peter Boyer d1f4d3171f More refactoring to inject GrammarFileName, LiteralNames... 2015-12-23 11:22:31 -06:00
Peter Boyer f5cf1cbf68 Various refactorings to properly support package export 2015-12-23 11:00:30 -06:00
Peter Boyer d6b1041224 Minor tweaks to template 2015-12-22 18:57:14 -06:00
Peter Boyer bd35305bc8 gofmt all files 2015-12-22 18:53:17 -06:00
Peter Boyer 859df5231c And now all of the changes are commmitted 2015-12-22 16:30:14 -06:00
Peter Boyer c83d8fb109 Numerous small fixes 2015-12-18 14:09:06 -05:00
Peter Boyer 54206cd853 Errors 2015-12-18 10:44:02 -05:00
Peter Boyer 40890f2122 More work on ATN code 2015-12-18 09:20:41 -05:00
Peter Boyer 5d0b4dfa09 Move files into one directory 2015-12-17 20:02:50 -05:00
Peter Boyer 350a39cef3 Various type fixes 2015-12-16 13:42:03 -05:00
Peter Boyer 729f30768a Mass refectoring of const variables 2015-12-15 16:38:01 -05:00
Peter Boyer f044fc5048 Parser template starting to look pretty good 2015-12-15 14:29:33 -05:00
Peter Boyer 7419ca6840 More tweaks 2015-12-14 17:39:42 -05:00
Peter Boyer 625ff2ee55 A few fixes 2015-12-14 17:30:46 -05:00
Peter Boyer e19f0e8564 More adjustments to code generation tool 2015-12-14 17:20:58 -05:00
Peter Boyer eac3d7d665 More work on parser template file 2015-12-14 16:35:29 -05:00
Peter Boyer 5d046e256b First steps on converting tool template to Go 2015-12-14 14:47:53 -05:00
Peter Boyer 9f9cd374b4 Add GoTarget 2015-12-14 12:01:21 -05:00
Peter Boyer acbce59a89 Rename file 2015-12-14 11:27:52 -05:00
Peter Boyer 2c36445ac3 Stub out stg file 2015-12-14 11:27:11 -05:00
Terence Parr 1438ab817f why oh why does intellij skip changes when i push? 2015-12-08 11:38:35 -08:00
Terence Parr 99563b116e merging KvanTTT changes. 2015-12-08 11:38:08 -08:00
Terence Parr 6068a4a2c7 Merge pull request #1054 from abego/patch-4
Possible NullPointerException in ActionTranslater#translateActionChunk
2015-11-25 09:05:46 -08:00
Terence Parr 36d8d41def Merge pull request #1046 from abego/extraNullCheckInTestRig
Extra 'null' check in TestRig#process
2015-11-25 09:04:43 -08:00
Udo Borkowski 10edd9a243 Possible NullPointerException in ActionTranslater#translateActionChunk
The parameter `RuleFunction rf` in `ActionTranslater#translateActionChunk` may be `null`.

The method's implementation takes care of this by checking `rf` before making its `ruleCtx` the translator's nodeContext:

```
if ( rf!=null ) translator.nodeContext = rf.ruleCtx;
```

However in the statement following this code the check for `rf!=null` is missing. This will lead to a `NullPointerException` when  `altLabel` is defined and `rf` is `null`:

```
if ( altLabel!=null ) translator.nodeContext = rf.altLabelCtxs.get(altLabel);
```

To avoid the problem only access `rf.altLabelCtxs` when `rf` is not null:

```
if ( rf!=null ) {
    translator.nodeContext = rf.ruleCtx;
    if ( altLabel!=null ) translator.nodeContext = rf.altLabelCtxs.get(altLabel);
}
```
2015-11-25 00:37:48 +01:00
Terence Parr 15f69d6697 this->self. 2015-11-24 10:58:19 -08:00
Terence Parr 05b50325a8 Merge pull request #991 from michaelpj/sync-before-predict
Reinstitute `sync` calls before `adaptivePredict`
2015-11-19 12:37:09 -08:00
Udo Borkowski a71ffbe8bc Extra 'null' check in TestRig#process
After loading and casting the parserClass in TestRig#process using
`cl.loadClass(parserName).asSubclass(Parser.class)` there is a check if
the class returned by `#asSubclass` is not null:

```
parserClass = cl.loadClass(parserName).asSubclass(Parser.class);
if ( parserClass==null ) {
	System.err.println("Can't load "+parserName);
}
```

The method `#asSubclass` will never return `null`, but throw an
`ClassCastException` when the cast is not valid, therefore the check
can be removed.

See also: [TestRig#process Documentation](http://docs.oracle.com/javase/6/docs/api/java/lang/Class.html#asSubclass(java.lang.Class\))
2015-11-19 18:27:32 +01:00
Michael Peyton Jones 42cb08f46a Add proper qualifiers to the JS and Python errHandler calls 2015-11-19 16:40:17 +00:00
Michael Peyton Jones b48c86cc30 Use correct sync method in C# codegen 2015-11-18 11:22:53 +00:00
Terence Parr c77c2a39e9 Merge pull request #1031 from HSorensen/patch-1
Update TestRig.java help text with correct package name
2015-11-12 14:00:42 -08:00
HSorensen dcbe2ae806 TreeViewer: Fix NPE
The `selectedTree.getSelectionPath()` return null if nothing is selected.
Added check to avoid NPE:
```java
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at org.antlr.v4.gui.TreeViewer$4.valueChanged(TreeViewer.java:376)
	at javax.swing.JTree.fireValueChanged(JTree.java:2921)
	at javax.swing.JTree$TreeSelectionRedirector.valueChanged(JTree.java:3382)
	at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(DefaultTreeSelectionModel.java:635)
	at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(DefaultTreeSelectionModel.java:1093)
	at javax.swing.tree.DefaultTreeSelectionModel.removeSelectionPaths(DefaultTreeSelectionModel.java:502)
	at javax.swing.JTree.removeDescendantSelectedPaths(JTree.java:3714)
	at javax.swing.JTree.setExpandedState(JTree.java:3597)
	at javax.swing.JTree.collapsePath(JTree.java:2231)
	at javax.swing.plaf.basic.BasicTreeUI.toggleExpandState(BasicTreeUI.java:2297)
	at javax.swing.plaf.basic.BasicTreeUI.handleExpandControlClick(BasicTreeUI.java:2273)
	at javax.swing.plaf.basic.BasicTreeUI.checkForClickInExpandControl(BasicTreeUI.java:2231)
	at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection(BasicTreeUI.java:3600)
	at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressed(BasicTreeUI.java:3548)
	at java.awt.Component.processMouseEvent(Component.java:6524)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
	at java.awt.Component.processEvent(Component.java:6292)
	at java.awt.Container.processEvent(Container.java:2234)
	at java.awt.Component.dispatchEventImpl(Component.java:4883)
	at java.awt.Container.dispatchEventImpl(Container.java:2292)
	at java.awt.Component.dispatchEvent(Component.java:4705)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4530)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
	at java.awt.Container.dispatchEventImpl(Container.java:2278)
	at java.awt.Window.dispatchEventImpl(Window.java:2739)
	at java.awt.Component.dispatchEvent(Component.java:4705)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)
	at java.awt.EventQueue.access$400(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:697)
	at java.awt.EventQueue$3.run(EventQueue.java:691)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.awt.EventQueue$4.run(EventQueue.java:719)
	at java.awt.EventQueue$4.run(EventQueue.java:717)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
```
2015-10-29 08:56:42 -07:00
Ivan Kochurkin d692e1f0d9 Fixed @sharwell remarks: typos and etc. 2015-10-28 13:22:21 +03:00
HSorensen 84c283c3a9 Update TestRig.java
The help and error message from the TestRig program refers to the old `runtime.misc` instead of the new `gui` package:
```
java org.antlr.v4.runtime.misc.TestRig GrammarName startRuleName
  [-tokens] [-tree] [-gui] [-ps file.ps] [-encoding encodingname]
  [-trace] [-diagnostics] [-SLL]
  [input-filename(s)]
Use startRuleName='tokens' if GrammarName is a lexer grammar.
Omitting input-filename makes rig read from stdin.
```
2015-10-27 21:34:39 -07:00
Bryan Wilhelm 1ed689c31c Handle left-recursion overloads by disabling ambiguous method reference warning. 2015-10-12 20:26:22 -04:00
Ivan Kochurkin 8bf480dcc5 Fixed non-informative NullPointerException. Empty strings now not allowed. fixed #959. 2015-10-12 16:33:32 +03:00
Bryan Wilhelm 3ae2b34d5f Resolve unlabeled left-recursive rules method names. 2015-10-09 22:03:24 -04:00
Bryan Wilhelm 8f53a8e03c Resolve overloaded labeled method. When left recursion is used the rule method is overloaded. When not resolved a C# compiler is generated and defaults to the parameterless method. This explicitly sets it to the parameterless method. 2015-10-09 21:33:13 -04:00
Ivan Kochurkin 78427bae79 Fixed typos in comments. 2015-10-07 23:19:54 +03:00
Ivan Kochurkin a7a9804ecd Restrict certain token, channel, mode names. fixed #1015
Clear error (can not use or declare mode with reserved name) instead of "Serialized ATN data element out of range." exception from #967.
2015-10-07 23:15:21 +03:00
Ivan Kochurkin 935c25b110 Removed wildcard imports.
Fixed test with equal mode and token name.
2015-10-07 17:57:16 +03:00
Bryan Wilhelm fce6c086d2 Update doc comment in C# target base listener and visitor classes to use correct method name. 2015-10-06 21:34:17 -04:00
Ivan Kochurkin a14ba03b6e Changed error code (170), added grammar sample to description. 2015-10-06 18:11:40 +03:00
Ivan Kochurkin a87ac8664b Error in case of mode conflicts with token. fixed #996 2015-10-06 17:39:01 +03:00
Eric Vergnaud 2f082e29fc fix mono 3.12.1 stack overflow on ubuntu with 60k+ string concat expression #2 2015-09-19 02:30:13 +08:00
Eric Vergnaud 7743e44517 fix mono 3.12.1 stack overflow on ubuntu with 60k+ string concat expression 2015-09-19 01:59:22 +08:00
Dan McLaughlin 4a90b9f219 Fixes for the Lexer 2015-09-13 06:27:02 -07:00
Dan McLaughlin 3933f8b38a Fixes in the template file, mainly just semicolons at the end of
include statements
2015-09-11 07:38:54 -07:00
Michael Peyton Jones 09588d2936 Update templates for other languages similarly 2015-09-07 17:39:41 +01:00
Michael Peyton Jones 797cf08111 Delete remaining commented out syncs.
These sync calls are truly redundant - when we are in a simple
alternative block, we can recover sufficiently with `recoverInline`, and
so the syncs do not add anything.
2015-09-07 17:37:05 +01:00
Michael Peyton Jones 940cbcf19f Uncomment syncs before adaptivePredict
These allow slightly better error recovery before we run
`adaptivePredict`, as illustrated by the test.
2015-09-07 11:56:30 +01:00
Eric Vergnaud ee3d29cc50 Fixes an issue pointed out by Mike Cargal, where null literals where registered as 'null' instead of null in both lexicalNames and symbolicNames, thus resulting in erroneous error messages when handling parsing errors. 2015-09-03 20:59:50 +08:00
David Sisson 52f3933bfb updated 2015-08-31 13:32:09 -07:00
parrt c07aa4ede1 [maven-release-plugin] prepare for next development iteration 2015-08-20 12:11:58 -07:00
parrt 3611fde621 [maven-release-plugin] prepare release 4.5.1-1 2015-08-20 12:11:55 -07:00
Jason van Zyl 9623d955a0 Add Main-Class attribute to shaded tool JAR 2015-08-20 13:06:37 -04:00
David Sisson 0ed092e224 Improvements to start supporting header files (incomplete). 2015-08-08 10:01:16 -07:00
parrt 3d181af904 [maven-release-plugin] prepare for next development iteration 2015-07-15 14:45:48 -07:00
parrt 79dae1e6f6 [maven-release-plugin] prepare release 4.5.1 2015-07-15 14:45:45 -07:00
Terence Parr b555099842 Merge pull request #955 from parrt/move-swing-dependency
move swing related stuff out of runtime package into org.antlr.v4.gui
2015-07-14 17:27:51 -07:00
Terence Parr b395127e73 move swing related stuff out of runtime package into org.antlr.v4.gui 2015-07-14 14:29:41 -07:00
Eric Vergnaud d1eb13cddc Fix antlr4-javascript #36.
Octal is not supported in strict mode.
2015-07-05 13:19:50 +08:00
David Sisson 7ead71d143 Enough template definitions to be dangerous (near complete). 2015-07-03 14:59:22 -07:00
David Sisson 8bb5bf0dcd Now 46% complete. 2015-07-03 14:46:38 -07:00
David Sisson dee6f88e44 A third of the templates now look like C++ (but may not match the final runtime). 2015-07-03 14:39:29 -07:00
David Sisson 083f924e25 Working on the templates 2015-07-03 09:43:48 -07:00
David Sisson fa0463fc31 Removed handled TODO. 2015-06-30 21:37:36 -07:00
David Sisson 0d1b4bffd1 Now has support for all 6 header possible header files. 2015-06-30 21:32:05 -07:00
David Sisson fccf0b4036 Now outputs headers a bit as well as code. 2015-06-30 17:17:34 -07:00
Jason van Zyl a142a5bc62 Create shaded tool JAR
Which contains:
 - Antlr runtime classes
 - String template classes
 - Tree layout classes
2015-06-30 12:07:36 -04:00
parrt b05e3ccdb8 messing with poms to get test generation in there. it doesn't seem to compiled and properly though. mvn compile works but mvn install doesn't finished compiling generated tests. 2015-06-29 18:09:38 -07:00
Sam Harwell 157749e825 Generate tests during the build
This commit enables the runtime test generator during the Maven build,
process which means the Java runtime receives the same comprehensive
testing during a Maven build as it does during a build with bild.py.
2015-06-29 18:09:38 -07:00
Terence Parr f4709f2973 tweak pom to give version of maven-jar-plugin so it doesn't fail. success reported for "maven test" but no tests run. ;) 2015-06-29 18:09:37 -07:00
parrt b3133abb21 gitignore was dropping all my target generators. ugh. 2015-06-29 18:09:37 -07:00
parrt da818c0c5c got javascript/node tests passing; folded in all js targets 2015-06-29 18:09:36 -07:00
parrt 8e89af918f all Python2 runtime tests pass 2015-06-29 18:09:35 -07:00
parrt d1f95085fe all Python3 runtime tests pass. Using same "get resource" mechanism to find runtime python code as I did for C#. 2015-06-29 18:09:35 -07:00
parrt e8c4bc4b09 Manual copy/add-to-git from antlr4-csharp repo (w/o history) to show how C# target should get injected into main antlr4 repo. Pieces go into tool for code gen, runtime-testsuite, and of course the runtime module. 2015-06-29 18:09:34 -07:00
parrt 6d892c71b5 mv JavaTarget to new target package 2015-06-29 18:09:33 -07:00
parrt fdcfe5482f mv tool tests into their own top level directory; mv test template support .stg into the runtime-testsuite area 2015-06-29 18:09:32 -07:00
David Sisson 363b640949 Now actually generates some Java-ish looking code with the following command:
LOCATION=~/GitHub/antlr4cpp/antlr4/dist/antlr-4.1.1-dev-complete.jar
java -classpath $LOCATION -jar $LOCATION -Dlanguage=Cpp T.g4
2015-06-28 12:34:47 -07:00
David Sisson 095fe36b66 Updated list of reserved keywords in C++. 2015-06-27 10:09:01 -07:00
David Sisson 0989a7d242 Added initial CppTarget so we can start trying to generate data. Does not yet have support for C++ header files (or really anything). Expect Java-like code. 2015-06-27 09:38:55 -07:00
parrt 9170f57aff tweak TestGenerator so it sorts test names so order is always same in TestX.java files. 2015-06-24 16:36:40 -07:00
Jason van Zyl 46202d98a2 Integrating tests for all supported targets
- A profile "rts" has been created which runs the integration tests. By default the the project containing the runtimes tests will not run so that users casually checking out and building the project do not have to install the tools required to test all the supported Antlr targets.

- The base test classes that are required for running the integration tests are downloaded from the other Antlr repos, dynamically added to the compile classpath and used by the currently checked in integration tests

To run the the full build with all the integration tests use the following:

mvn clean install -Prts
2015-06-24 13:45:40 -04:00
Terence Parr 6439b40d09 Merge pull request #928 from antlr/delete-legacy-tests
delete legacy test generator and generated tests
2015-06-23 10:21:45 -07:00
parrt a95666e710 add/update warning comment 2015-06-22 13:07:49 -07:00
Terence Parr 5c52288845 use template name that indicates what we're testing here. AssertIsList(v). 2015-06-22 11:03:22 -07:00
Terence Parr 162c6138a5 rm unused template 2015-06-20 12:21:51 -07:00
Terence Parr 82d0cbc3f6 add missing template 2015-06-20 11:59:44 -07:00
ericvergnaud 06730fcc6c delete legacy test generator and generated tests 2015-06-21 01:11:11 +08:00
Terence Parr 0f1516b798 Add missing copyright notices. Improve comments. Construct new temporary parsers of the same class as the original parser. a rename. 2015-06-19 13:41:31 -07:00
Sam Harwell 560b2b428e Remove the three remaining .iml files 2015-06-19 14:59:39 -05:00
Terence Parr 4115a0ad47 Merge pull request #913 from sharwell/fix-909
Move TestPerformance.testExpressionGrammar to the runtime test suite
2015-06-19 12:11:12 -07:00
Jason van Zyl 8beec18283 Add Maven build
Account for the following:
- deploying snapshots to OSSRH
- releasing to Maven Central
- Shaded JAR including the treelayout dependency
- OSGi manifest
- remove Eclipse IDE metadata for clean import
- remove IDEA IDE metadata for clean import
2015-06-19 11:13:24 -07:00
Terence Parr 2267559550 yet more ide .xml changes 2015-06-19 11:10:42 -07:00
parrt a9ca2efae5 add tests, refactor get-all-parse-tree stuff. add Trees support routines. 2015-06-18 17:25:51 -07:00
Terence Parr 1c19c70307 convert map to int[][] 2015-06-18 10:00:32 -07:00
parrt 11726e072e update the comments. 2015-06-17 18:30:29 -07:00
parrt 94bef386cb add new interpreter that knows how to track alternatives in rule nodes; some cleanup and improvement to other interpreter 2015-06-17 18:06:22 -07:00
Sam Harwell 3c9aabfb80 Move TestPerformance.testExpressionGrammar to the runtime test suite
Fixes #909
2015-06-16 20:23:44 -05:00
parrt ad0239fb32 got all tests passing for js and changed order of test gen templates 2015-06-16 16:16:16 -07:00
parrt 3ddb25919d got all but 2 tests passing for py2! 2015-06-16 14:52:08 -07:00
parrt fcc15905cc got all but 4 tests passing for py3! 2015-06-16 13:33:58 -07:00
Terence Parr e3dded6ffc Merge pull request #893 from sharwell/test-generation
Completed test generation review
2015-06-16 09:59:24 -07:00
parrt 94bb7c0af3 Fixes #897. An empty rule matched at the start got an improper interval. updated documentation for getSourceInterval(), added unit tests. fixed logic for special cases. 2015-06-11 12:39:21 -07:00
parrt 9e5cda85ed Fixes #896. EOF was not counted in source interval. 2015-06-11 10:56:59 -07:00
parrt 2da28ee5b2 add test showing EOF leaf not in source interval of tree 2015-06-11 10:37:36 -07:00
Terence Parr 8cf7082e89 add legacy bild 2015-06-07 11:43:39 -07:00
Sam Harwell 6865fd6869 Remove files which were unintentionally duplicated in commit 0c7df237 2015-06-06 18:26:17 -05:00
Sam Harwell 4455d526fe Merge branch 'test-generation' into master 2015-06-06 18:15:53 -05:00
Sam Harwell 364d984437 Verify behavior of CompositeGrammars tests, and correct discrepancies 2015-06-06 16:21:19 -05:00
Sam Harwell 2f99ca7453 Add the ability to ignore tests on a per-target basis 2015-06-06 14:30:54 -05:00
Sam Harwell 80a881e132 Disable tests which rely on carriage returns in the input
For some reason, the test generator is not currently able to create string
literals containing these characters, so the tests will fail.
2015-06-06 14:30:17 -05:00
parrt dc445af663 Improve ParserInterpreter code simplicity 2015-06-05 16:14:20 -07:00
ericvergnaud 2e06ed8360 test added to check a user issue 2015-06-04 22:57:58 +08:00
parrt 6e3484a286 add old stuff back in. 2015-06-03 10:11:33 -07:00
parrt fec97f2938 tweaks 2015-06-03 09:58:22 -07:00
Terence Parr 6333674588 bild.py works to build c# now. 2015-06-02 20:06:35 -07:00
Terence Parr 29db15736d regen_test in bild.py works now 2015-06-02 17:24:06 -07:00
parrt 1323e30fa9 moving around templates, deleting old stuff. C# and Java runtime tests work using branch intermediate-test-generation of C#. bild doesn't quite test stuff correctly. 2015-06-02 16:00:45 -07:00
parrt 0c7df237db remove old java runtime test framework; reorg dirs. bild.py test_java appears to work. 2015-06-02 11:50:08 -07:00
parrt fafc7722c8 got bild to gen java tests (others commented out) and run those tests. rm'd .stg map in Index.stg. 2015-06-02 11:40:19 -07:00
Terence Parr e3325ab606 add cmd-line interface, add map in Index.stg to targets-specific templates. 2015-06-01 18:18:44 -07:00
parrt b15e66985e add main to test gen. 2015-06-01 14:40:22 -07:00
Sam Harwell 23cdb2ee8f Merge branch 'test-generation' into parrt_master 2015-06-01 14:45:54 -05:00
parrt d73e73a091 update comments, rename var. 2015-05-29 14:10:08 -07:00
Terence Parr 3e5fc6972a Fixes #773. rule[arg] in non-lr rule alt didnt translate right 2015-05-22 16:49:31 -07:00
Sam Harwell e248be48d1 Restore missing test testAlternateQuotes 2015-05-22 15:39:35 -05:00
Sam Harwell 131599af1a Fix incorrect interpretation of test ListLabelForClosureContext 2015-05-22 15:39:08 -05:00
Sam Harwell 3fe8bf3a10 Updated maven-surefire-plugin version 2015-05-22 15:32:57 -05:00
Sam Harwell c70c1baccf Disable annotation processors during testing for performance 2015-05-22 15:32:57 -05:00
Sam Harwell 8dce2d5fb5 TestCompositeParsers for Java is working 2015-05-22 15:32:56 -05:00
Sam Harwell 99dcf93206 TestFullContextParsing for Java is working 2015-05-22 15:32:54 -05:00
Sam Harwell 4fa9ed5a6b TestParserExec for Java is working 2015-05-22 15:32:54 -05:00
Sam Harwell c9c32c2c4f TestLeftRecursion for Java is working 2015-05-22 15:32:53 -05:00
Sam Harwell 6890d0bfdd TestLexerErrors for Java is working 2015-05-22 15:32:52 -05:00
Sam Harwell 9ce5efc570 TestListeners for Java is working 2015-05-22 15:32:51 -05:00
Sam Harwell 113b72da53 TestParserErrors for Java is working 2015-05-22 15:32:50 -05:00
Sam Harwell c11b384b1d TestSemPredEvalLexer for Java is working 2015-05-22 15:32:49 -05:00
Sam Harwell 98bb519f8a TestSemPredEvalParser for Java is working 2015-05-22 15:32:49 -05:00
Sam Harwell 42ba8c4530 TestLexerExec for Java is working 2015-05-22 15:32:48 -05:00
Sam Harwell 4ec94e0fae TestParseTrees for Java is working 2015-05-22 15:32:47 -05:00
Sam Harwell 039bd22b67 TestCompositeLexers for Java is working 2015-05-22 15:32:46 -05:00
Sam Harwell 90763e5ae2 Rewrite test generator as a Maven plugin that generates tests as part of the build
This commit only updates the "TestSets" collection of tests to use the new framework.
2015-05-22 15:32:06 -05:00
Terence Parr 8f2eca5ae1 added playground stuff 2015-05-22 12:03:28 -07:00
Terence Parr 4f0afdcf8e set error number so it does not conflict with Sam's fork. 2015-05-22 11:09:54 -07:00
Terence Parr 2ad9ff6b9d Fixes #823. Report unknown rule error in proper file. 2015-05-19 17:27:04 -07:00
Terence Parr b5907498de Fixes #822, Fixes #855. We didn't check for left-recursive rules that didn't follow pattern that would lead to error. added unit tests. Passes all tests. 2015-05-19 14:44:05 -07:00
Josh Chase 108f0557fa Add goto to reserved words for java. 2015-05-12 12:31:00 -07:00
Terence Parr db8de6214e IDE missed some changed files 2015-02-14 16:44:35 -08:00
Terence Parr 5e70f94628 Somehow I missed a bunch of imports for @NotNull. Fixes #815. 2015-02-14 16:29:37 -08:00
Terence Parr d4a43684be squash all commits for this branch 2015-02-14 13:51:31 -08:00
Terence Parr 822d61ad47 Fixes #809. 2015-01-31 14:36:46 -08:00
Terence Parr 4cc275ab52 I did not have project URL in pom and the maven deploy failed again. 2015-01-23 15:33:01 -08:00
Terence Parr 3a4d53adea had license to the pom files and make sure that they use the jar packaging. 2015-01-23 14:39:36 -08:00
Terence Parr 4dcc65d452 make all 4.5 2015-01-22 17:08:19 -08:00
Terence Parr 65e4dc47e1 fix unit tests for recent bug fix so that they work with JavaScript. 2015-01-22 17:00:07 -08:00
Terence Parr be03964df3 rm @NotNull and @Nullable from codebase to simplify 2015-01-22 14:34:51 -08:00
Terence Parr 7e21ec761e freshen unit tests 2015-01-22 11:44:01 -08:00
Terence Parr 017fbc8ef7 Make new unit tests compatible with all targets; refactor Generator to take cmd-line arg or current dir. rename some methods. add some output. 2015-01-21 17:12:24 -08:00
Terence Parr e2dc5e5d2e set Generator so that it builds with the current working directory as the main root antlr4 dir like bild.py does. 2015-01-21 10:59:31 -08:00
Terence Parr 41713e1869 revert to 353235c 2015-01-21 10:15:47 -08:00
Terence Parr 136e8a6286 tweak 2015-01-20 17:16:07 -08:00
Terence Parr bab8d2cf40 Merge branch 'master' into fix-recovery 2015-01-20 17:08:47 -08:00
Michael Peyton Jones 9e09e6a9c0 Don't consume after error recovery.
recoverInline should handle making sure that the token stream is
advanced to the appropriate position. It is difficult for the caller to
do that, as recoverInline may create a "new" token that is not actually
in the stream.
2015-01-20 14:18:40 +00:00
Michael Peyton Jones dea7c768d4 Test for recovery over-consumption 2015-01-20 10:54:53 +00:00
ericvergnaud 1926a1636a maven cleanup
- added note for maven developers
 - removed maven plugins
 - updated maven dependencies for dev only
 - added antlr4 annotations
2015-01-19 23:04:46 +08:00
Terence Parr 8af4afc058 add intellij project files 2015-01-14 11:20:08 -08:00
Terence Parr 6d9d60ccda Copy stuff from the root pom to the individual poms and remove the root. Remove dependency on the annotations artifact which no longer exists. hardcode the version number everywhere to make sure I don't use a variable that doesn't exist. update bild so that it uses a new maven_deploy() function I put into bilder.py 2015-01-13 17:29:38 -08:00
Terence Parr 4f0f361d93 Fixes #670. Left recursive rules imported into a root grammar caused an error. All tests pass in all targets. 2015-01-12 13:05:03 -08:00
Terence Parr 64f6e196b2 add unit test that reproduces issue #670 2015-01-12 13:00:15 -08:00
Terence Parr 0c2a693638 remove unnecessary check for missing RULES node as that node is apparently always present; the tree construction rule is: -> ^(RULES rule*) 2015-01-12 12:59:36 -08:00
Terence Parr c9a51b98ae add nullptr check 2015-01-12 12:58:50 -08:00
Terence Parr 8c05364099 set versions to 4.5 2015-01-10 10:12:02 -08:00
Terence Parr a4909b3f52 remove constant word size in *code gen* for inline set testing. 2014-12-26 12:15:49 -08:00
Terence Parr 2a28a9b4f3 simplify. no need for listeners as System.err can be reset. 2014-12-17 10:57:20 -08:00
Terence Parr 49a8029985 allow 4.4-generated parsers to work with new 4.5 runtime. 2014-12-16 19:09:17 -08:00
Terence Parr eb9ee1bd80 urlloader.close() doesn't exist in java 1.6; removing for 1.6 compatibility. 2014-12-16 18:40:07 -08:00
ericvergnaud 38c4e2b002 moved from $self to $parser
- also adjusted generated tests for the above
- also adjusted generated tests for recent changes in Python/JavaScript
targets (token types are nos class members like Java/C#)
2014-12-02 23:44:21 +08:00
ericvergnaud a47ee4d853 add support for $self 2014-11-30 16:28:36 +08:00
ericvergnaud c4ec9e5e35 generate tests for IE 2014-11-23 18:46:14 +08:00
ericvergnaud 78027ed0f0 add edit warnings + fix chrome location + make locations relative 2014-11-23 15:50:31 +08:00
Terence Parr 958f2fdf6e merge from master into release branch 2014-11-22 10:47:29 -08:00
ericvergnaud 8228987b4f prepare release
all tests pass (commented out performance and alternate quotes)
added test for complement set
tests regenerated to fix results after bug fixes and « huge string »
issue in java 1.7+
bild.py review to fix numerous bugs
2014-11-23 02:06:47 +08:00