Convert user input to regular expression

I am working on a project in which the user enters a user-readable search string with AND OR. I will give three examples

  • a AND (b OR c) → (? =. \ ba \ b) (? =. (\ bb \ b) | (\ bc \ b)). *
  • a OR (b AND c)
  • (a OR b) AND (c OR d)

The above are examples of input that I can get. I want to accept this input and convert it to regex. Isn't that a compiler sample? Looking at this, I see what I want to do is convert a high-level team to a low level. Do you have any suggestions on how I could accomplish the above? I want to go through a regex created in jsoup (pseudo selector: matchOwn) and request an html document. Thank you for your help.

+5
source share
1

- . . , calculator-ast, .

AST, . antlr. v3, v4 . antlr3.org. , pratt parser. , , .

, AST, , AST , .

!

+5

All Articles