Commit Graph

1928 Commits

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

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

 * testTokenMismatch
 * testTokenMismatch2
 * testNoViableAltAvoidance
 * testNoViableAlt
 * testExprAmbiguity_2

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

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

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

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

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

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

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

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

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

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

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

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