lunacookies / eldiro Goto Github PK
View Code? Open in Web Editor NEWLearn to make your own programming language with Rust
Home Page: https://lunacookies.github.io/lang/
License: Apache License 2.0
Learn to make your own programming language with Rust
Home Page: https://lunacookies.github.io/lang/
License: Apache License 2.0
Hi I wanted to know what is this new language about, and how does it differ to Rust.
Additionally I would like to know what is Markers?
I enjoyed your article very much...!
It was vague to create a language to me, but I was inspired by your article.
There seems to be no update after the post has been serialized several times within a short period of time.
I don't want to put pressure on you, but I would appreciate it if you notice there are readers waiting.
Thank you again for your work.
This issue refers to the usage of PhantomData
in part 19
The code works, however to use PhantomData
you need to use std::marker::PhantomData
first.
not a major issue though. I'm sure most people can figure it out
Hi,
First I'd like to say thanks for taking the time to make this blog series.
I'd like to see the code at the time of writing a specific post, but that requires me to search through the repo's history and make a guess as to which commit corresponds with when that blog post was posted. Would it be possible to use git tags to tag the commit of the repo when you post a new blog post? That way, myself and others could just checkout the repo at that tag to browse the code.
Hi,
nice project and tutorial series!
I have a question regarding your 14th part of the tutorial: Is there any future benefit to have an explicit comment token? Without doc comments etc. in mind it would be easier to filter comments with a simple logos::skip like:
pub(crate) enum SyntaxKind {
// snip
#[error]
#[regex("#.*"), logos::skip)] // added here because Error is some kind of fallback token
Error,
// snip
}
Less code, easier to understand, possibly faster and a simpler parser tree. The only drawback is that it is not possible to parse the content of comments in the future.
Hey!
First of all, thanks for the great read, and the wealth of information provided by your tutorial!
Okay, onto the "issue"!
TokenKind::Ident
currently uses the regex [A-Za-z][A-Za-z0-9]*
to get all idents. However, this misses the all imporant _
character. I am not sure if it is desired that idents cannot have an underscore or not, as it was not discussed from what I can tell.
If idents should be able to have _
, then the regex just should be either [A-Za-z][A-Za-z0-9_]*
or [A-Za-z][A-Za-z0-9]*
, depending of if you would like _
to be a valid ident or not.
What currently happens when an ident has an _
:
> let long_name = 2
[email protected]
[email protected]
[email protected] "let"
[email protected] " "
[email protected] "long"
[email protected]
[email protected] "_"
[email protected]
[email protected] "name"
[email protected] " "
[email protected]
[email protected] "="
[email protected] " "
[email protected]
[email protected] "2"
[email protected] "\n"
lower(root) = (
Database {
exprs: Arena {
len: 0,
data: [],
},
},
[
VariableDef(
"long",
VariableRef(
"name",
),
),
Expr(
Literal(
Some(
2,
),
),
),
],
)
With the first suggested change:
-> let long_name = 1
[email protected]
[email protected]
[email protected] "let"
[email protected] " "
[email protected] "long_name"
[email protected] " "
[email protected] "="
[email protected] " "
[email protected]
[email protected] "1"
[email protected] "\n"
lower(root) = (
Database {
exprs: Arena {
len: 0,
data: [],
},
},
[
VariableDef(
"long_name",
Literal(
Some(
1,
),
),
),
],
)
Think about the following file in an imaginary language, where the grammar only matches an identifier and nothing else:
foo
(No trailing newline, token list after lexing: [Whitespace, Ident])
The grammar module uses Source::next_token()
, which skips trivia first and then returns the non-trivia token SyntaxKind::Ident
.
Before the sink step, the event list looks like this: [Event::AddToken]
.
When the sink receives the AddToken
event, it pops off the token at index 0 from the token list, which happens to be SyntaxKind::Whitespace
. After that there is no trivia to eat (Sink::eat_trivia
) and there are no more events. In the end, the CST doesn't even contain the Ident token.
I think that moving eat_trivia to before the match statement works. Even better is that it'd be after StartNode
, but before AddToken
so comments are added into the node.
remove
mod util
; fromexpr.rs
, and put the following inlib.rs
:
Should be
remove
mod utils
; fromexpr.rs
, and put the following inlib.rs
:
i.e. mod util
-> mod utils
Thanks for the series!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.