Which Java oriented lexer parser for simple projec

2019-01-15 09:06发布

I am working on a small text editor project and want to add basic syntax highlighting for a couple of languages (Java, XML..just to name a few). As a learning experience I wanted to add one of the popular or non popular Java lexer parser.

What project do you recommend. Antlr is probably the most well known, but it seems pretty complex and heavy.

Here are the option that I know of.

  1. Antlr
  2. Ragel (yes, it can generate Java source for processing input)
  3. Do it yourself (I guess I could write a simple token parser and highlight the source code).

9条回答
Deceive 欺骗
2楼-- · 2019-01-15 09:57

SableCC

Another interesting option (which I didn't try yet) would be Xtext, which uses Antlr but also includes tools for creating Eclipse editors for your language.

查看更多
Summer. ? 凉城
3楼-- · 2019-01-15 10:02

Another option would be Xtext. It will not only generate a parser for your grammar, but also a complete editor with syntax coloring, error markers, content assist and outline view.

查看更多
走好不送
4楼-- · 2019-01-15 10:08

I don't think that you need a lexer. all you need is first read the file extention to detect the language and then from a xml file which listed the language keywords easily find them and highlight them.

查看更多
登录 后发表回答