Commit Graph

2369 Commits

Author SHA1 Message Date
Peter Boyer ced8fba5bc Update Go.stg 2016-11-29 23:50:39 -05:00
Peter Boyer 39c77ca20f Potential fix for antlr/antlr4 #1397 2016-11-29 23:45:29 -05:00
Denis Blank c8279a1d89 Fix a dangerous c-cast in the cpp codegen 2016-11-29 17:14:02 +01:00
Ivan Kochurkin 9aab338021 Reverted old error types and numbers. 2016-11-29 19:12:43 +03:00
Ivan Kochurkin 44aab113f3 Added method checkCommands.
commands check micro optimization and code clearing.
2016-11-29 18:48:03 +03:00
Ivan Kochurkin f76ca22763 MODE_CONFLICTS_WITH_TOKEN error restored. 2016-11-29 18:13:57 +03:00
Ivan Kochurkin 8fe4def4ed Warnings for incompatible commands, added unit-test, fixes #1388.
Improved test for duplicated commands (added pushMode, popMode).
2016-11-29 16:03:33 +03:00
Ivan Kochurkin ed7f6f70da pushMode and popMode commands are not duplicated. 2016-11-29 16:00:41 +03:00
Gary Miller 763669ffc7 Fix for redeclared error is generated Go code. Create block so _x and _m var are created in a local scope. 2016-11-29 12:35:48 +11:00
Ivan Kochurkin bd1111ffa3 Fixed issue with duplicated commands in lexer rule. 2016-11-28 19:48:35 +03:00
Ivan Kochurkin a1def96500 getConstantValue replaced with getModeConstantValue, getTokenConstantValue and getChannelConstantValue methods.
ErrorType simplified, tests fixed.
Fixes #1411, added unit-test.
2016-11-28 14:41:04 +03:00
parrt 3506dcef1d add @Override to hush warnings. Manually did some of https://github.com/antlr/antlr4/pull/1066 2016-11-25 12:52:44 -08:00
Sam Harwell f196971565 Fix failure to identify prefix rules that also recurse
Fixes #1402
2016-11-24 14:38:34 -06:00
parrt 6c2d4e6225 Fixes #1211 2016-11-22 15:04:28 -08:00
parrt dc2c9b039e Fixes #1188 2016-11-22 14:21:07 -08:00
parrt 4e6e7edf0d Fixes #1317 2016-11-21 13:45:05 -08:00
Terence Parr 8ed1105290 Merge pull request #1353 from marcohu/fix_1233
Grammar dependency management for Maven plugin
2016-11-21 11:21:58 -08:00
parrt d580f2184f Use JFrame instead of JDialog to get "expand window" buttons 2016-11-21 10:42:52 -08:00
Marco Hunsicker cfc538bfdc Merge branch 'master' of https://github.com/antlr/antlr4 into fix_1233 to solve
Conflicts:
	contributors.txt
2016-11-21 19:23:48 +01:00
parrt 66be087c38 merge old and new travis; improve so it runs C++ on osx; update BaseSwiftTest so it mirrors other targets; remove unneeded dep in pom to some json stuff 2016-11-20 19:50:54 -08:00
Marco Hunsicker a077d3d072 Merge branch 'master' of https://github.com/antlr/antlr4 into fix_1233 2016-11-20 12:49:39 +01:00
hanjoes e0b326677b Migrating the current Swift tests to the new testing framework. 2016-11-19 18:30:48 -08:00
janyou cddb8a6ff2 Update Swift.stg
add namedActions
2016-11-19 18:30:48 -08:00
janyou abf2a1883c Update SwiftTarget.java
"4.5.1"->"4.5.3"
2016-11-19 18:30:48 -08:00
janyou fc3fa24464 Update Swift.stg 2016-11-19 18:30:48 -08:00
janyou 61248c8a4d Update Swift.stg 2016-11-19 18:30:48 -08:00
Ewan Mellor 6d6327aa9d Move the Token declarations into an enum.
This avoids the naming conflict in the tests between the use of ATN as a
token name and as a type name.
2016-11-19 18:30:48 -08:00
Ewan Mellor 869bcfe429 Mark matchWildcard call with a try, since it can throw. 2016-11-19 18:30:48 -08:00
Ewan Mellor 6d5d1f1c23 Add build system changes needed for Swift backend. 2016-11-19 18:30:48 -08:00
Ewan Mellor c989064e32 Added (part of) a Swift backend.
This comes from https://github.com/janyou/ANTLR-Swift-Target and is
marked Copyright (c) 2016 janyou on top of the BSD license and Copyrights
for Terence Parr and Sam Harwell derived from the original ANTLR source.
2016-11-19 18:30:48 -08:00
Terence Parr 10ce5d2625 Merge pull request #1311 from sebkur/allow_path_in_token_vocab
Allow paths as tokenVocab option
2016-11-19 15:30:19 -08:00
parrt f5d3e4cfe6 Improve robustness and correctness of two functions used by intellij antlr4 plugin to show ambig and lookahead parse trees. 2016-11-19 13:06:49 -08:00
parrt d0620a65f5 Merge branch 'issue#1295' of git://github.com/harriman/antlr4-updates into harriman-issue#1295 2016-11-19 12:05:32 -08:00
parrt 5153154658 Merge branch 'fix_typos' of git://github.com/sebkur/antlr4 into sebkur-fix_typos 2016-11-19 11:52:17 -08:00
Marco Hunsicker 81efb0e366 Merge branch 'master' of https://github.com/antlr/antlr4 into fix_1233 2016-11-18 17:53:54 +01:00
Marco Hunsicker 7d83a3aa9c More cleanup; use save Collection comparison 2016-11-17 23:29:27 +01:00
parrt 5adf79121f revert Go "fix" 2016-11-17 11:16:22 -08:00
Terence Parr cf5a79a5b2 Merge pull request #1362 from sridharxp/stgwotempvar
Stgwotempvar
2016-11-17 19:26:34 +01:00
Kurt Harriman ab8d17472f ANTLR4 generated incorrect code to access return value of recursive rule
Incorrect code was generated for $e.v in a rule like this one:

    e returns [int v] ::=
           INT       {$v = $INT.int;}
        | '(' e ')'  {$v = $e.v;}
        ;

After parsing "(99)" the result would have v == 0 instead of 99.
2016-11-16 22:38:11 -08:00
parrt 4f3c7738f3 ignore :: in C++ arg declarations; add test. 2016-11-16 12:34:14 -08:00
parrt 5aae2edb24 support x:T notation in rule arguments, update documentation, improve [...] scope parsing testing 2016-11-16 11:54:23 -08:00
hanjoes 03fa75efba differentiate prefix/postfix type decl. 2016-11-16 11:44:39 -08:00
sridharxp 6e09f08348 InvokeRule without Fix without Temporary variable 2016-11-16 13:14:38 +05:30
parrt 08e9776a4a shift template-based runtime test to legacy, new mechanism uses annotation to get multi-line strings into java. all tests pass minus about 15 in C# 2016-11-15 11:08:19 -08:00
Marco Hunsicker be585f6a8f Make graph accessible to the outside 2016-11-14 00:29:51 +01:00
parrt da342af01e added sync() per other targets to LL(1) decisions 2016-11-07 14:48:20 -08:00
parrt f8bec27d6d bring Go target templates up to same args as others. 2016-11-07 11:07:46 -08:00
parrt 3d0678508b reuse code to builld named actions. all file model objects have it now. 2016-11-07 11:07:23 -08:00
parrt 51d38110be trying a refactoring to test if i can push back 2016-11-07 10:55:48 -08:00
Mike Lischke 1c3a5879e6 Set required runtime version to 4.6. 2016-11-07 11:22:46 +01:00
Mike Lischke 92b032820e Merge branch 'master_upstream' 2016-11-07 11:19:12 +01:00
Mike Lischke 3b3fe3da57 Merge branch 'master_upstream'
Had to resolve a number of conflicts + added code required for the C++ target to generate header files, after the recent changes in the main repo.
2016-11-07 11:16:02 +01:00
parrt ffaedd209d Set version in code to 4.6. 2016-11-06 11:21:06 -08:00
parrt e5ec462e22 Fixes #1337. Add's sync() call back to LL(1) decisions; all targets updated (causing failed test in Go). Altered test for new output of errors. regen'd tests. 2016-11-06 09:45:40 -08:00
parrt 95c850e5f8 set version in prep for 4.6 2016-11-05 16:48:36 -07:00
Peter Boyer fc35818c52 Update import statements after merge 2016-11-05 16:36:53 -04:00
parrt 0799e838bb weird. missed a few files. these are to simplify get filename functionality. 2016-11-05 09:32:04 -07:00
parrt abdb0b6a46 Merge branch 'model-updates-for-new-targets' of github.com:parrt/antlr4 into reduce-model-changes 2016-11-05 09:29:25 -07:00
parrt 2c98b5d325 incorporate in a single commit all changes needed to support generating header files. many fewer diffs with C++ target codegen now. 2016-11-05 09:25:51 -07:00
parrt 6d022379bc Pull in parrt's branch 'model-updates-for-new-targets' which appears to have freshened some non Go stuff as well. Simplify Go filename construction. 2016-11-05 08:48:37 -07:00
parrt 40e19e5d37 refactor so getRecognizerFileName() etc... delegate to Target; default is same behavior. adds "is header" arg as well in prep for C++ 2016-11-05 08:08:08 -07:00
parrt 75794a588b track different types of StructDecl elements so Go can do setters/getters. 2016-11-05 07:35:57 -07:00
parrt c0cedc424b track different types of StructDecl elements so Go can do setters/getters. 2016-11-05 07:35:39 -07:00
Mike Lischke e71e95080a Merge branch 'master_upstream'
Also updated the list of ignored tests in the Cpp.test.stg file (lke it is done for the other targets).
2016-11-05 15:07:59 +01:00
parrt 8b8094c044 appears to be an ST bug that doesn't see arrays of len 0 as missing; convert array to List. 2016-11-05 06:55:09 -07:00
parrt e0521400cb rm need for isRuleContext in templates; refer to underlying grammar object. 2016-11-05 06:28:58 -07:00
parrt 85f2a87840 rm recognizerName field where possible 2016-11-04 16:07:45 -07:00
parrt 95dbf7b44b look for go in path during tests 2016-11-04 16:06:41 -07:00
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