What would be a good Delphi lexer/parser for Javascript language file? [closed]

这一生的挚爱 提交于 2020-01-02 05:07:52

问题


Background

I want to be able to parse Javascript source in a Delphi Application. I need to be able to identify variables and functions within the source for the purpose of making changes to the code through later code. I understand that I probably need to use a lexer for this purpose but have not had much luck using the lexer which I found (Dyaclexx).

Question

Is there a suitable freeware or open source delphi parser/lexer which already has token sets for Javascript or could be easily modified for this purpose without too much trouble?

If there isn't such a tool already available then what would be the best way to learn about writing your own lexer for this purpose?

Thank-you


回答1:


For the lexer you can see Synedit's source code for the Javascript highlighter. A highlighter in Synedit context is a lexer with special hooks to provide highlighting to the editor component. Trimming those hooks and getting a plain lexer is a trivial job.

Also Synedit editor can come handy while learning how to build lexers as it will be a help to visually test your lexers real-time. You can see the demos or ask at the mailing list for more.




回答2:


I think you should use should look at GoldParser (http://www.devincook.com/goldparser) for generating a complete JS parser in Delphi code. GoldParser is freeware though.



来源:https://stackoverflow.com/questions/354563/what-would-be-a-good-delphi-lexer-parser-for-javascript-language-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!