ANTLR Grammar for Java Regular Expression Syntax

I am currently working on a test platform for regular expressions, and I need to be able to parse Java regular expressions in AST to be able to generate string patterns that match a given regular expression.

I looked at the implementation java.util.regex.Pattern, but the code looks rather cumbersome (the emphasis was on speed over readability, which I imagined), so I decided to use ANTLR to write a regular expression parser from scratch.

I am wondering if anyone knows about the ready-made ANTLR grammar for regular expression before I start beating myself.

+3
source share
1 answer

There is a similar question here:

Regular Expression Grammar

The answers contain references to various grammars; none of them is ANTLR. I suspect that if you switch BNF to ANTLR, you will suffer from dizzy headaches, but if you try, you may be lucky.

+3
source

Source: https://habr.com/ru/post/1706026/


All Articles