Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ANTLR grammar to support Java 1.8 syntax #3054

Closed
benfry opened this issue Jan 22, 2015 · 8 comments
Closed

Update ANTLR grammar to support Java 1.8 syntax #3054

benfry opened this issue Jan 22, 2015 · 8 comments
Labels
enhancement help wanted We have very little time and would like some help

Comments

@benfry
Copy link
Contributor

benfry commented Jan 22, 2015

Our current grammar is out of date and doesn't support many newer Java features. See also #3055.

@benfry benfry added enhancement help wanted We have very little time and would like some help labels Jan 22, 2015
@joelmoniz
Copy link
Member

@benfry I'd like to help out with this. Could you please let me know which features are missing/out-of-date at present? Here are a few missing ones that I have identified, although I'm not quite sure about how relevant/important they may be:

  1. Multi-catch support
  2. Support for the diamond operator
  3. Underscores in numeric literals (such as int x = 30_000)
  4. Strings in switch
  5. Binary literals
  6. Support for lambda calculus

Thanks

@benfry
Copy link
Contributor Author

benfry commented Mar 24, 2015

Thanks for the interest. This is less about adding the language features one by one than it is finding an existing Java 1.8 grammar for ANTLR and making it work. This would be best handled by fixing #3055 first, and then going after this issue.

@miguel-negrao
Copy link

Support for lambda calculus

Lambda calculus is an abstract mathematical entity: "Lambda calculus (also written as λ-calculus) is a formal system in mathematical logic for expressing computation based on function abstraction and application using variable binding and substitution.". You probably mean lambda expressions.

@cansik
Copy link

cansik commented Nov 26, 2016

Is someone working on this issue or on #3055 at the moment? There is an existing grammar for ANTLR: https://github.com/antlr/grammars-v4/blob/master/java8/Java8.g4

It would be great to be able to write lambda expression.

@kevinkyyro
Copy link

I'm not actively working on it, but I've looked at it a bit and it seems tricky.

It looks like the currently used java 5 grammar is not a vanilla; I don't know ANTLR so it's difficult to try to tease out the modifications and then migrate them to ANTLR 4 since I couldn't find migration guides from ANTLR 2 to 3 and 3 to 4 (found one but not the other).

I wonder if it would make sense to migrate to a code or script-based preprocessor translating from processing syntax to valid java 5, then piping that through ANTLR with the vanilla java 5 grammar. It seems like it would make it easier to drop in the java 8 grammar, ideally without modification. This is based on the assumption that the preprocessor would be relatively simple; most of the modifications seem context-independent -- mainly just globals and type aliases, though type I guess type coercion could need a little more care if type aliasing is not sufficient.

@sampottinger
Copy link

Hey there! Just to keep some threads updated... I revisited #3055, bringing it up to speed with processing's current master and #5753. I have a build of processing working (with a few particular error handlers being migrated) at sampottinger#15. I'll redirect that from my fork to this repo after #5753 is concluded.

@sampottinger
Copy link

Hey there! Just a quick update for those tracking this thread. sampottinger#15 is stable and ready for feedback. I recommend testing using my master at https://github.com/sampottinger/processing. It has all of the PRs that branch off of #5753 merged in.

Unfortunately #5753 is still under review so there is likely a little runway on my fork but hoping to rejoin mainline soon.

sampottinger added a commit to sampottinger/processing4 that referenced this issue Oct 6, 2019
Introduces ANTLR4 and Java 8 language feature support within IDE while also adding additional hooks for localization of syntax error messages, addressing processing/processing#3054 and processing/processing#3055.

The PR is broadly a continuation of processing/processing#3055, bringing it up to speed with the latest Processing master plus the changes introduced at processing/processing#5753. **Requires processing/processing#5753 as pre-requisite.** This introduces a number of edits beyond processing/processing#3055 beyond compatibility with current Processing master and processing/processing#5753 including:

 - Update to the grammar itself
 - Change ANTLR listeners to emit `TextTransform.Edit` to unify JDT-based `PreprocessingService` and `JavaBuild`, removing code with duplicate purpose.
 - Introduction of syntax error rewriting with support for localization.
 - Addition of complete localized strings set for English and Spanish.
 - Addition of partial localized strings set for other languages.
 - Refactor of ANTLR-related code for testability and readability
 - Expansion of tests including full parse tests for new Java features (type inference, lambdas).
sampottinger added a commit to sampottinger/processing4 that referenced this issue Oct 6, 2019
* Move to ANTLR 4 with Java 11 lang features and localization.

Introduces ANTLR4 and Java 8 language feature support within IDE while also adding additional hooks for localization of syntax error messages, addressing processing/processing#3054 and processing/processing#3055.

The PR is broadly a continuation of processing/processing#3055, bringing it up to speed with the latest Processing master plus the changes introduced at processing/processing#5753. **Requires processing/processing#5753 as pre-requisite.** This introduces a number of edits beyond processing/processing#3055 beyond compatibility with current Processing master and processing/processing#5753 including:

 - Update to the grammar itself
 - Change ANTLR listeners to emit `TextTransform.Edit` to unify JDT-based `PreprocessingService` and `JavaBuild`, removing code with duplicate purpose.
 - Introduction of syntax error rewriting with support for localization.
 - Addition of complete localized strings set for English and Spanish.
 - Addition of partial localized strings set for other languages.
 - Refactor of ANTLR-related code for testability and readability
 - Expansion of tests including full parse tests for new Java features (type inference, lambdas).

* Ask travis for ant upgrade prior to run.

* Ask Travis for java11 update.

* Add openjdk ppa

* Travis no confirmation on add ppa.

* Force newer ant on travis.

* Swtich ant download to www-us mirror.

* Switch ant to 1.10.7

* Start x for unit tests in travis.

* More complete start x in travis.

* Revert x in travis.

* Try x in services.
@benfry
Copy link
Contributor Author

benfry commented Jan 17, 2020

Resolved in the 4.x series: https://github.com/processing/processing4

@benfry benfry closed this as completed Jan 17, 2020
@processing processing locked as resolved and limited conversation to collaborators Jan 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement help wanted We have very little time and would like some help
Projects
None yet
Development

No branches or pull requests

6 participants