🐛 add a DoubleColon to the Token struct in the lexer.rs#243
🐛 add a DoubleColon to the Token struct in the lexer.rs#243LesterEvSe wants to merge 1 commit intoBlockstreamResearch:masterfrom
DoubleColon to the Token struct in the lexer.rs#243Conversation
src/lexer.rs
Outdated
| /// This prevents the lexer from allowing spaces between colons (e.g., `use a: :b`), | ||
| /// ensuring we strictly parse valid paths. |
There was a problem hiding this comment.
| /// This prevents the lexer from allowing spaces between colons (e.g., `use a: :b`), | |
| /// ensuring we strictly parse valid paths. | |
| /// This prevents the lexer from allowing spaces between colons (e.g., `use a: :b`) |
| doc_link_with_quotes = "warn" | ||
| doc_markdown = "warn" | ||
| empty_enum = "warn" | ||
| empty_enums = "warn" |
There was a problem hiding this comment.
Explain in description why this is changed
There was a problem hiding this comment.
After updating to Rust 1.94.0, cargo clippy started complaining about these lints. I just applied the automatic suggestions from Clippy to fix the warnings.
| transmute_ptr_to_ptr = "warn" | ||
| trivially_copy_pass_by_ref = "warn" | ||
| unchecked_duration_subtraction = "warn" | ||
| unchecked_time_subtraction = "warn" |
There was a problem hiding this comment.
The solution is the same as in the previous answer.
src/lexer.rs
Outdated
| just("->").to(Token::Arrow), | ||
| just("=>").to(Token::FatArrow), | ||
| just("=").to(Token::Eq), | ||
| just("::").to(Token::DoubleColon), |
There was a problem hiding this comment.
This is confusing, is param:::: now valid?
There was a problem hiding this comment.
No. It's working as usual; the error is being shown by jet::::. So I think it's behaving similarly to param::::.
stringhandler
left a comment
There was a problem hiding this comment.
4fe0378
Seems fine but would be useful to have some tests that show the problem. Have a look here for a simple way to create one https://github.com/BlockstreamResearch/SimplicityHL/pull/213/changes#diff-5d5fd55cd63fa75e4c8902fa6b6d63da3f8da03742454636a8d9c092f6f6eeb4R346
917a87a to
24f4e44
Compare
Done |
stringhandler
left a comment
There was a problem hiding this comment.
I think let's add some tests for witness:: and witness::::
src/lexer.rs
Outdated
There was a problem hiding this comment.
I think we can remove the double colons here now. The correct lexer should create [Token::Witness, Token::DoubleColon]
There was a problem hiding this comment.
Is this OK?
let jet = just("jet")
.padded()
.ignore_then(just("::"))
.padded()
.ignore_then(text::ident())
.map(Token::Jet);
let witness = just("witness")
.padded()
.ignore_then(just("::"))
.padded()
.ignore_then(text::ident())
.map(Token::Witness);
let param = just("param")
.padded()
.ignore_then(just("::"))
.padded()
.ignore_then(text::ident())
.map(Token::Param);Or do I need to change this part of the code?
let keyword = text::ident().map(|s| match s {
"fn" => Token::Fn,
"let" => Token::Let,
"type" => Token::Type,
"mod" => Token::Mod,
"const" => Token::Const,
"match" => Token::Match,
"true" => Token::Bool(true),
"false" => Token::Bool(false),
_ => Token::Ident(s),
});If I add these kinds of words here, then I need to use Token::Jet("") or delete the (&'src str) payload here:
// Jets, witnesses, and params
Jet(&'src str),
Witness(&'src str),
Param(&'src str),So, which approach should I choose?
There was a problem hiding this comment.
I chose the option with the fewest changes (.padded(), ignore_then("::"))
There was a problem hiding this comment.
So those are valid now
jet :: add_32, witness :: PK, and witness:: PK
?
There was a problem hiding this comment.
Yes, it's an analogy to the Rust syntax.
24f4e44 to
9ae7f36
Compare
This prevents the lexer from allowing spaces between colons (e.g.,
a: :b),