On 8/12/2012 12:27 PM, Pragma Tix wrote:
Am 12.08.2012 20:51, schrieb Walter Bright:
I suspect his problems come mostly from trying to write Java code in D.

Sure, but atm I have no idea what is a good D solution for the following 
problem.


Quote Andrew :
The first thing I ran into was that the lexer returns "tokens", which in the
Java code are not just integer enums, but actual enum classes with fields and
methods. ......
In typical new user fashion, I tried to reproduce the Java style token enum in
D. (It's hard not to avoid "cutting against the grain" when learning a new
language.) D does allow you to use structs for enums so it seemed this would
work. But if you use structs then you lose the automatic assignment of
consecutive integer values, and D struct's are value types so they aren't
necessarily unique.

end quote

What is the D way here ?


There's a whole thread here about building a lexer in D entitled "std.d.lexer requirements" and another entitled "D Lexer" which should be most helpful.

Reply via email to