简体   繁体   English

Intellij解析Java代码

[英]Intellij parsing java code

I want to use a math-expression parser of java code. 我想使用Java代码的数学表达式解析器。 In particular I would like to convert a math-expression given as String to an abstract syntax tree consisted of separate nodes. 特别是,我想将以String形式给出的数学表达式转换为由单独的节点组成的抽象语法树。

Is there anyone to recommend me a relevant open source tool? 有没有人向我推荐相关的开源工具?

If no, how do you reckon the possibility to exploit Intellij source code to do this work? 如果没有,您认为如何利用Intellij源代码来完成这项工作? Which classes are responsible for code parsing and analysis? 哪些类负责代码解析和分析?

Are they included in idea.jar? 它们包含在idea.jar中吗? How can I easily infiltrate their functionality (methods etc)? 如何轻松渗透其功能(方法等)?

I am speaking exclusively for Intellij. 我只为Intellij发言。

看一下MVEL库。

If you only want the results of the math-expression you should revise the question and the answer i selected months ago: 如果您只想要数学表达式的结果,则应该修改我几个月前选择的问题和答案:

Java 1.5: mathematical formula parser Java 1.5:数学公式解析器

Brieff description: use the java integration with dinamyc languajes like javascript to let them do the work for you brieff描述:将Java与dinamyc languajes集成在一起,例如javascript,让他们为您完成工作

I would not use IntelliJ, as much as I love it. 我不会像我所喜欢的那样使用IntelliJ。

If you need an AST, look no further than ANTLR. 如果您需要AST,则只需ANTLR。 If you can write a grammar for your equations, ANTLR can generate a lexer/parser to create it for you. 如果您可以为方程式编写语法,则ANTLR可以生成一个词法分析器/解析器来为您创建它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM