Implementing a programming language in D: Lexical Analysis
blog.felixangell.com
Implementing a programming language in D: Lexical Analysis
1–10 of 22 posts
Re: Implementing a programming language in D: Lexical Analysis
#2Re: Implementing a programming language in D: Lexical Analysis
#3I'm wondering why you used D rather than Rust? Was it just that you were curious about the D language or is there something about Rust that you don't like?
Re: Implementing a programming language in D: Lexical Analysis
#4I've never seen the D language before and I have to admit, it looks very elegant and has piqued my interest. Thanks for your post. I'm wondering why you used D rather than Rust? Was it just that you were curious about the D language or is there something about Rust that you don't like?
https://github.com/aswyk/oxidation/blob/master/oxidation/src...
Of course, Rust's own lexer is also written in Rust.
ETA: I can't promise my lexer is actually any good... it's really the first non-trivial thing I've written in Rust. But it works ;)
Re: Implementing a programming language in D: Lexical Analysis
#5I've never seen the D language before and I have to admit, it looks very elegant and has piqued my interest. Thanks for your post. I'm wondering why you used D rather than Rust? Was it just that you were curious about the D language or is there something about Rust that you don't like?
Re: Implementing a programming language in D: Lexical Analysis
#6I've never seen the D language before and I have to admit, it looks very elegant and has piqued my interest. Thanks for your post. I'm wondering why you used D rather than Rust? Was it just that you were curious about the D language or is there something about Rust that you don't like?
I continue to dabble in Rust, but D is so much more comfortable.
Re: Implementing a programming language in D: Lexical Analysis
#7Re: Implementing a programming language in D: Lexical Analysis
#8I've never seen the D language before and I have to admit, it looks very elegant and has piqued my interest. Thanks for your post. I'm wondering why you used D rather than Rust? Was it just that you were curious about the D language or is there something about Rust that you don't like?
If you want to see what a lexical analyzer looks like in Rust, here's one that I wrote for Lua: https://github.com/aswyk/oxidation/blob/master/oxidation/src... Of course, Rust's own lexer is also written in Rust. ETA: I can't promise my lexer is actually any good... it's really the first non-trivial thing I've written in Rust. But it works ;)
Re: Implementing a programming language in D: Lexical Analysis
#9I've never seen the D language before and I have to admit, it looks very elegant and has piqued my interest. Thanks for your post. I'm wondering why you used D rather than Rust? Was it just that you were curious about the D language or is there something about Rust that you don't like?
enum MyLanguage {
Var(String),
Int(i32),
Sum(Box, Box),
Let(String, Box, Box)
}
(Apologies if I got a few things wrong; I just mean the general idea)Seems like without a construct like this, you'd have to use subclasses or something similar, which (to me) isn't quite as nice.
Re: Implementing a programming language in D: Lexical Analysis
#10I've never seen the D language before and I have to admit, it looks very elegant and has piqued my interest. Thanks for your post. I'm wondering why you used D rather than Rust? Was it just that you were curious about the D language or is there something about Rust that you don't like?
One advantage I could see of Rust over D for language stuff is sum types (enums in Rust). So for example you can write: enum MyLanguage { Var(String), Int(i32), Sum(Box , Box ), Let(String, Box , Box ) } (Apologies if I got a few things wrong; I just mean the general idea) Seems like without a construct like this, you'd have to use subclasses or something similar, which (to me) isn't quite as nice.