Redian新闻
>
Do you guys use lex to parsing input?
avatar
Do you guys use lex to parsing input?# Java - 爪哇娇娃
c*t
1
Just curious. Assume that there is a very simple Lexical / Parser
generator for Java, will you use it over Pattern/Regex lib provided
by Sun?
avatar
b*y
2
I've used javacc before, but a bit complicated. You need to come up with the
grammar, left recursion only, I think.
So, normally I would just use Pattern/Regex, since it is standard and easy
to use.
avatar
h*j
3
used antlr before, not bad...
or you can check javacc out

【在 c*****t 的大作中提到】
: Just curious. Assume that there is a very simple Lexical / Parser
: generator for Java, will you use it over Pattern/Regex lib provided
: by Sun?

avatar
k*r
4
regex只能做很简单的。有时候不得不用lex之类。或者javacc/antlr

【在 c*****t 的大作中提到】
: Just curious. Assume that there is a very simple Lexical / Parser
: generator for Java, will you use it over Pattern/Regex lib provided
: by Sun?

avatar
b*y
5
or, you can write your own java based parser/compiler, LL based.
I've read a book called "let's write a compiler" before, it is good and
tells you how to roll your own.
In fact, java compiler is LL (recursive decent), so you can hand-code a java
compiler yourself ;-)
avatar
c*t
6
The problem with LL is well known though, although there are work
arounds. For example:
expr + expr
expr * expr
type, in LALR with precedence is really easy to do, about 20x more
work for LL.
Sun's Java compiler is slow. It also has quite a bit limitations
and some artifacts.
Try this in your code:
String str = "\u000a";
It also fails on several other codes.
Antlr has some problems too. It directly generates Java code.
IMO, this is actually bad due to several reasons: lots of
function calls,

【在 b******y 的大作中提到】
: or, you can write your own java based parser/compiler, LL based.
: I've read a book called "let's write a compiler" before, it is good and
: tells you how to roll your own.
: In fact, java compiler is LL (recursive decent), so you can hand-code a java
: compiler yourself ;-)

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。