Commit Graph

1903 Commits

Author SHA1 Message Date
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
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
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
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
Jason van Zyl a142a5bc62 Create shaded tool JAR
Which contains:
 - Antlr runtime classes
 - String template classes
 - Tree layout classes
2015-06-30 12:07:36 -04:00
parrt b05e3ccdb8 messing with poms to get test generation in there. it doesn't seem to compiled and properly though. mvn compile works but mvn install doesn't finished compiling generated tests. 2015-06-29 18:09:38 -07:00
Sam Harwell 157749e825 Generate tests during the build
This commit enables the runtime test generator during the Maven build,
process which means the Java runtime receives the same comprehensive
testing during a Maven build as it does during a build with bild.py.
2015-06-29 18:09:38 -07:00
Terence Parr f4709f2973 tweak pom to give version of maven-jar-plugin so it doesn't fail. success reported for "maven test" but no tests run. ;) 2015-06-29 18:09:37 -07:00
parrt b3133abb21 gitignore was dropping all my target generators. ugh. 2015-06-29 18:09:37 -07:00
parrt da818c0c5c got javascript/node tests passing; folded in all js targets 2015-06-29 18:09:36 -07:00
parrt 8e89af918f all Python2 runtime tests pass 2015-06-29 18:09:35 -07:00
parrt d1f95085fe all Python3 runtime tests pass. Using same "get resource" mechanism to find runtime python code as I did for C#. 2015-06-29 18:09:35 -07:00
parrt e8c4bc4b09 Manual copy/add-to-git from antlr4-csharp repo (w/o history) to show how C# target should get injected into main antlr4 repo. Pieces go into tool for code gen, runtime-testsuite, and of course the runtime module. 2015-06-29 18:09:34 -07:00
parrt 6d892c71b5 mv JavaTarget to new target package 2015-06-29 18:09:33 -07:00
parrt fdcfe5482f mv tool tests into their own top level directory; mv test template support .stg into the runtime-testsuite area 2015-06-29 18:09:32 -07:00
parrt 9170f57aff tweak TestGenerator so it sorts test names so order is always same in TestX.java files. 2015-06-24 16:36:40 -07:00
Jason van Zyl 46202d98a2 Integrating tests for all supported targets
- A profile "rts" has been created which runs the integration tests. By default the the project containing the runtimes tests will not run so that users casually checking out and building the project do not have to install the tools required to test all the supported Antlr targets.

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

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

mvn clean install -Prts
2015-06-24 13:45:40 -04:00
Terence Parr 6439b40d09 Merge pull request #928 from antlr/delete-legacy-tests
delete legacy test generator and generated tests
2015-06-23 10:21:45 -07:00
parrt a95666e710 add/update warning comment 2015-06-22 13:07:49 -07:00
Terence Parr 5c52288845 use template name that indicates what we're testing here. AssertIsList(v). 2015-06-22 11:03:22 -07:00
Terence Parr 162c6138a5 rm unused template 2015-06-20 12:21:51 -07:00
Terence Parr 82d0cbc3f6 add missing template 2015-06-20 11:59:44 -07:00
ericvergnaud 06730fcc6c delete legacy test generator and generated tests 2015-06-21 01:11:11 +08:00
Terence Parr 0f1516b798 Add missing copyright notices. Improve comments. Construct new temporary parsers of the same class as the original parser. a rename. 2015-06-19 13:41:31 -07:00
Sam Harwell 560b2b428e Remove the three remaining .iml files 2015-06-19 14:59:39 -05:00
Terence Parr 4115a0ad47 Merge pull request #913 from sharwell/fix-909
Move TestPerformance.testExpressionGrammar to the runtime test suite
2015-06-19 12:11:12 -07:00
Jason van Zyl 8beec18283 Add Maven build
Account for the following:
- deploying snapshots to OSSRH
- releasing to Maven Central
- Shaded JAR including the treelayout dependency
- OSGi manifest
- remove Eclipse IDE metadata for clean import
- remove IDEA IDE metadata for clean import
2015-06-19 11:13:24 -07:00
Terence Parr 2267559550 yet more ide .xml changes 2015-06-19 11:10:42 -07:00
parrt a9ca2efae5 add tests, refactor get-all-parse-tree stuff. add Trees support routines. 2015-06-18 17:25:51 -07:00
Terence Parr 1c19c70307 convert map to int[][] 2015-06-18 10:00:32 -07:00
parrt 11726e072e update the comments. 2015-06-17 18:30:29 -07:00
parrt 94bef386cb add new interpreter that knows how to track alternatives in rule nodes; some cleanup and improvement to other interpreter 2015-06-17 18:06:22 -07:00
Sam Harwell 3c9aabfb80 Move TestPerformance.testExpressionGrammar to the runtime test suite
Fixes #909
2015-06-16 20:23:44 -05:00
parrt ad0239fb32 got all tests passing for js and changed order of test gen templates 2015-06-16 16:16:16 -07:00
parrt 3ddb25919d got all but 2 tests passing for py2! 2015-06-16 14:52:08 -07:00
parrt fcc15905cc got all but 4 tests passing for py3! 2015-06-16 13:33:58 -07:00
Terence Parr e3dded6ffc Merge pull request #893 from sharwell/test-generation
Completed test generation review
2015-06-16 09:59:24 -07:00
parrt 94bb7c0af3 Fixes #897. An empty rule matched at the start got an improper interval. updated documentation for getSourceInterval(), added unit tests. fixed logic for special cases. 2015-06-11 12:39:21 -07:00
parrt 9e5cda85ed Fixes #896. EOF was not counted in source interval. 2015-06-11 10:56:59 -07:00
parrt 2da28ee5b2 add test showing EOF leaf not in source interval of tree 2015-06-11 10:37:36 -07:00
Terence Parr 8cf7082e89 add legacy bild 2015-06-07 11:43:39 -07:00
Sam Harwell 6865fd6869 Remove files which were unintentionally duplicated in commit 0c7df237 2015-06-06 18:26:17 -05:00
Sam Harwell 4455d526fe Merge branch 'test-generation' into master 2015-06-06 18:15:53 -05:00
Sam Harwell 364d984437 Verify behavior of CompositeGrammars tests, and correct discrepancies 2015-06-06 16:21:19 -05:00
Sam Harwell 2f99ca7453 Add the ability to ignore tests on a per-target basis 2015-06-06 14:30:54 -05:00
Sam Harwell 80a881e132 Disable tests which rely on carriage returns in the input
For some reason, the test generator is not currently able to create string
literals containing these characters, so the tests will fail.
2015-06-06 14:30:17 -05:00
parrt dc445af663 Improve ParserInterpreter code simplicity 2015-06-05 16:14:20 -07:00
ericvergnaud 2e06ed8360 test added to check a user issue 2015-06-04 22:57:58 +08:00
parrt 6e3484a286 add old stuff back in. 2015-06-03 10:11:33 -07:00
parrt fec97f2938 tweaks 2015-06-03 09:58:22 -07:00
Terence Parr 6333674588 bild.py works to build c# now. 2015-06-02 20:06:35 -07:00
Terence Parr 29db15736d regen_test in bild.py works now 2015-06-02 17:24:06 -07:00
parrt 1323e30fa9 moving around templates, deleting old stuff. C# and Java runtime tests work using branch intermediate-test-generation of C#. bild doesn't quite test stuff correctly. 2015-06-02 16:00:45 -07:00
parrt 0c7df237db remove old java runtime test framework; reorg dirs. bild.py test_java appears to work. 2015-06-02 11:50:08 -07:00
parrt fafc7722c8 got bild to gen java tests (others commented out) and run those tests. rm'd .stg map in Index.stg. 2015-06-02 11:40:19 -07:00
Terence Parr e3325ab606 add cmd-line interface, add map in Index.stg to targets-specific templates. 2015-06-01 18:18:44 -07:00
parrt b15e66985e add main to test gen. 2015-06-01 14:40:22 -07:00
Sam Harwell 23cdb2ee8f Merge branch 'test-generation' into parrt_master 2015-06-01 14:45:54 -05:00
parrt d73e73a091 update comments, rename var. 2015-05-29 14:10:08 -07:00
Terence Parr 3e5fc6972a Fixes #773. rule[arg] in non-lr rule alt didnt translate right 2015-05-22 16:49:31 -07:00
Sam Harwell e248be48d1 Restore missing test testAlternateQuotes 2015-05-22 15:39:35 -05:00
Sam Harwell 131599af1a Fix incorrect interpretation of test ListLabelForClosureContext 2015-05-22 15:39:08 -05:00
Sam Harwell 3fe8bf3a10 Updated maven-surefire-plugin version 2015-05-22 15:32:57 -05:00
Sam Harwell c70c1baccf Disable annotation processors during testing for performance 2015-05-22 15:32:57 -05:00
Sam Harwell 8dce2d5fb5 TestCompositeParsers for Java is working 2015-05-22 15:32:56 -05:00
Sam Harwell 99dcf93206 TestFullContextParsing for Java is working 2015-05-22 15:32:54 -05:00
Sam Harwell 4fa9ed5a6b TestParserExec for Java is working 2015-05-22 15:32:54 -05:00
Sam Harwell c9c32c2c4f TestLeftRecursion for Java is working 2015-05-22 15:32:53 -05:00