Commit Graph

1591 Commits

Author SHA1 Message Date
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
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
David Tymon a1c63234e1 JS: Added 'require' statements are missing the class names 2015-12-24 19:04:22 +11:00
FUJI Goro (gfx) 4a1ec7df38 Remove Utils#waitForClose()
It is used nowhere but imports java.awt.*; Android runtime
has no java.awt.* so Android SDK build tools say "it includes
invalid packages". It's better if antlr4-runtime has no dependency
on java.awt.*, esp. it is not used anymore.
2015-12-24 14:04:58 +09:00
David Tymon 812794600d JS: LexerActionExecutor cached hash string name clashes with function
LexerActionExecutor caches its hash string in a member called
'hashString'. However, the class also has a method with the
same name which leads to unexpected results.

The member has been renamed to '_hashString' to avoid the name
clash.
2015-12-24 13:06:59 +11:00
David Tymon f40ce5a188 JS: LL1Analyzer passing PredictionContext incorrectly to ATNConfig constructor
The PredictionContext should be passed to the ATNConfig constructor
in the first argument, the params object. Instead, it is being passed
as the second argument which is intended to be the config.
2015-12-24 13:01:40 +11:00
David Tymon 0455e0a09f JS: Fix missing 'requires' statements 2015-12-24 12:23:09 +11:00
Peter Boyer 797dd823be Fix mistake in tokenIndex bounds check
undefined < anyInteger 

returns false
2015-12-15 21:44:47 -05:00
Eric Vergnaud c651c83a8b fix #1058 2015-12-09 22:17:46 +08:00
Terence Parr 8a4aa39de2 fix links 2015-11-23 16:19:45 -08:00
Eric Vergnaud 98abfc14f3 Update GitHub references in npm package 2015-11-12 07:57:52 +08:00
Terence Parr 482d8d44fd resolve contrib conflict 2015-10-27 09:43:07 -07:00
Martin Probst af9e8a1e92 fix #1023: getExpectedTokens() returns out of context tokens on consecutive runs 2015-10-21 17:14:43 +02:00
hkff e051b1a0f8 Fixing BufferedTokenStream.getTokenStream() calls 2015-10-21 16:34:44 +02:00
hkff 0e09f8b659 Adding getTokenSource in BufferedTokenStream 2015-10-21 14:15:57 +02:00
Eric Vergnaud 3e807138d5 local replica of #1010 2015-10-05 21:28:30 +08:00
Eric Vergnaud 158ef2c567 same fix as #1010 2015-10-05 21:03:37 +08:00
Eric Vergnaud 1b01140354 Useful information for code completion 2015-10-04 11:44:26 +08:00
Eric Vergnaud a3b27766fa fix type 2015-09-30 22:07:46 +08:00
Terence Parr ca467f2d45 fix merge in contrib file 2015-09-18 14:04:26 -07:00
Terence Parr dfe05b5f9f Merge pull request #997 from krzkaczor/master
Added proper visit function in ParseTreeVisitor
2015-09-18 12:28:43 -07:00
Krzysztof Kaczor 55fce54f4e reverted fix 2015-09-18 17:29:55 +02:00
Eric Vergnaud 986d00a5a0 missing 'new', thanks Mike 2015-09-18 22:21:17 +08:00
Rajiv Subrahmanyam e5f011a9a1 #999: Using unicode(c) instead of str(c) to avoid exception when unicode string contains high byte chars 2015-09-17 22:23:10 -07:00
Krzysztof Kaczor b2d771e01c fixed bug that prevented run on nodejs 2015-09-17 21:25:37 +02:00
Krzysztof Kaczor 7a7480911c added proper visit function in ParseTreeVisitor 2015-09-17 21:21:49 +02:00
Eric Vergnaud 488f7b92ae was failing when ran in NodeJS 2015-09-14 23:34:52 +08:00
Eric Vergnaud 1e89482a64 Actually, Torben was kind enough to fix the require version from Smoothie, moved to a new framework called Honey, and to switch to the MIT license.
So dropped my version, which also required some fix for Safari, in favor of this one that I don't have to maintain
2015-09-11 16:20:29 +08:00
Eric Vergnaud 6c0b7d9c87 Improve compatibility across contexts: nodejs, web ui and web worker 2015-09-04 00:19:34 +08:00
Eric Vergnaud e7cdc2271f Largely rewritten to support usage in web worker thread without breaking compatibility with NodeJS require 2015-09-03 23:40:06 +08:00
Eric Vergnaud 27855f7ed4 remove slow asserts 2015-08-26 23:43:03 +08:00
Eric Vergnaud d7d59c53a7 more tuning 2015-08-26 23:42:14 +08:00
Eric Vergnaud 1b3f74495f typo 2015-08-26 23:41:21 +08:00
Eric Vergnaud 295d235728 typo 2015-08-26 23:40:41 +08:00
Eric Vergnaud 980072b6b4 more tuning 2015-08-26 23:40:14 +08:00
Eric Vergnaud 3a10724919 typo 2015-08-26 23:39:31 +08:00
Eric Vergnaud 1b5437aeab more tuning 2015-08-26 23:39:04 +08:00
Eric Vergnaud 2f4f36d60c typos 2015-08-26 02:14:19 +08:00
Eric Vergnaud e6d27c7a7c use native tuple hash instead of str hash 2015-08-26 02:13:56 +08:00
Eric Vergnaud 164a34ba6e use native tuple hash instead of str hash 2015-08-26 01:17:23 +08:00
Eric Vergnaud cfb557cc90 add performance test 2015-08-26 01:15:59 +08: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
Robbie Cooper 3c08f49a1a Fix NameError in LexerATNSimulator.reset()
Without this line, one gets "NameError: name 'Lexer' is not defined" when calling reset(). This is the same way __init__() assigns self.mode.
2015-08-05 02:31:57 -04:00
parrt ad6a1bda3f rm generated files, update a manifest 2015-07-17 12:43:41 -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 2921865a54 add TestRig proxy. 2015-07-14 16:57:46 -07:00
Terence Parr fcd1e54289 rm unneeded plug-in from maven 2015-07-14 14:40:21 -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 7a8dc8e290 simpler and clearer 2015-07-07 23:32:44 +08:00
Terence Parr 53678867ca rm a few local test files 2015-06-30 15:04:20 -07:00
Terence Parr c2dfb7f457 rm a few local test files 2015-06-30 14:27:12 -07:00
Terence Parr 7114dcd3ae Merge branch 'fold-into-master' of github.com:antlr/antlr4-python3 2015-06-30 14:26:37 -07:00
Terence Parr d81fa33128 mv files into proper position for folding into main antlr4 repo; delete already moved stuff 2015-06-30 14:25:12 -07:00
Terence Parr 40ef11a77c Merge branch 'fold-into-master' of github.com:antlr/antlr4-python2 2015-06-30 14:15:44 -07:00
Terence Parr fe207fb3ee mv files into proper position for folding into main antlr4 repo; delete already moved stuff 2015-06-30 14:13:56 -07:00
Terence Parr 6bd039e585 fold in history from javascript repo 2015-06-30 11:28:57 -07:00
Terence Parr c0aa3b36ca get .project into position 2015-06-30 11:26:45 -07:00
Terence Parr dac66a6fab mv files into proper position for folding into main antlr4 repo 2015-06-30 11:18:25 -07:00
Terence Parr 5d2d75d2e3 looks like i had python2 and 3 swapped. java, python3, c# pass. python2, js each have same single test failing: testCharSetWithQuote1 2015-06-29 18:09:37 -07:00
Terence Parr 99ad09ece1 ok, somehow python2 runtime got overwritten with weird stuff. it passes tests again now with fresh copy. 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