Release v0.4.0: Switch to ANTLR grammar for Java #80
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Edit: this PR now also contains version update and CHANGELOG.
ec0ff1d
)tree
syntax (seeparser.TreeMappings.kt
)Here's a sketch of an alternative (backup) parser for J2EO, using ANTLR grammar for Java from antlr/grammars-v4.
The documentation for this grammar claims to support Java 17, and their benchmarks show that it is somewhat tested on large projects, such as Spring Framework, ElasticSearch, and Log4j. Unfortunately, these benchmarks do not show if the parser works correctly, so it is possible that some adjustments will be required. Still, this grammar can work at least as a backup.
Now, to make use of this grammar, we need to map ANTLR's generated concrete syntax tree to J2EO's abstract syntax tree. This is currently work-in-progress:
AltAnnotationQualifiedName
Annotation
AnnotationConstantRest
AnnotationMethodOrConstantRest
AnnotationMethodRest
AnnotationTypeBody
AnnotationTypeDeclaration
AnnotationTypeElementDeclaration
AnnotationTypeElementRest
Arguments
ArrayCreatorRest
ArrayInitializer
Block
BlockStatement
CatchClause
CatchType
ClassBody
ClassBodyDeclaration
ClassCreatorRest
ClassDeclaration
ClassOrInterfaceModifier
ClassOrInterfaceType
ClassType
CompilationUnit
ConstDeclaration
ConstantDeclarator
ConstructorDeclaration
CreatedName
Creator
DefaultValue
ElementValue
ElementValueArrayInitializer
ElementValuePair
ElementValuePairs
EnhancedForControl
EnhancedForControlControl
EnumBodyDeclarations
EnumConstant
EnumConstants
EnumDeclaration
ExplicitGenericInvocation
ExplicitGenericInvocationSuffix
Expression
ExpressionList
FieldDeclaration
FinallyBlock
FloatLiteral
ForControl
ForInit
ForInitControl
FormalParameter
FormalParameterList
FormalParameters
GenericConstructorDeclaration
GenericInterfaceMethodDeclaration
GenericMethodDeclaration
GuardedPattern
Identifier
ImportDeclaration
InnerCreator
IntegerLiteral
InterfaceBody
InterfaceBodyDeclaration
InterfaceCommonBodyDeclaration
InterfaceDeclaration
InterfaceMemberDeclaration
InterfaceMethodDeclaration
InterfaceMethodModifier
LambdaBody
LambdaExpression
LambdaLVTIList
LambdaLVTIParameter
LambdaParameters
LastFormalParameter
Literal
LocalTypeDeclaration
LocalVariableDeclaration
MemberDeclaration
MethodBody
MethodCall
MethodDeclaration
Modifier
ModuleBody
ModuleDeclaration
ModuleDirective
NonWildcardTypeArguments
NonWildcardTypeArgumentsOrDiamond
PackageDeclaration
ParExpression
Pattern
Primary
PrimitiveType
QualifiedName
QualifiedNameList
ReceiverParameter
RecordBody
RecordComponent
RecordComponentList
RecordDeclaration
RecordHeader
RequiresModifier
Resource
ResourceSpecification
Resources
Statement
SuperSuffix
SwitchBlockStatementGroup
SwitchExpression
SwitchLabel
SwitchLabeledRule
SwitchRuleOutcome
TypeArgument
TypeArguments
TypeArgumentsOrDiamond
TypeBound
TypeDeclaration
TypeList
TypeParameter
TypeParameters
TypeType
TypeTypeOrVoid
VariableDeclarator
VariableDeclaratorId
VariableDeclarators
VariableInitializer
VariableModifier