Commit Graph

1591 Commits

Author SHA1 Message Date
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
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