Conversation
|
Ah shoot, I have to fix the history so it doesn't have the old stuff |
|
While this works, I would prefer to make the parser stricter and only recognize the And also needs tests:
|
|
In that case I'll take a new approach and make |
|
Do you think a separate token is worth it? I think just scanning the stream for #! at the beginning and skipping until the first EOL would be easier and keep the rest of the lexer and parser oblivious that this happened. And I think I hadn't noticed this was a draft! Surprised to see that they show up by default in the PRs list. |
My reasoning for a separate token (and also catching it in the tokenizer) was that it would let us give better error messages (+ lexer-time errors instead of runtime errors), but it might also not be worth it. It's up to you. If we want to do this at the time of lexing it would require that #142 be done or a similar solution, though. It would also requiring passing more info through to the lexer, since it would have to know that we're not in the intrepeter.
Haha, yup, this and #142 are both drafts. Just made the PRs so it would be easier to communicate as I'm working on them. |
|
But for line numbers, we'd just need to start the counter at 2 instead of 1 inside the spans when #! is present, right? The thing is that the #! is a Unix thing bolted onto the language, so that's why I think it should not be part of the lexer/parser and it should just be something that happens "out of band" before the lexer even sees the stream. I'm guessing, but haven't checked, that this is how #! is also added to many other scripting languages that don't have #-style comments in them. |
|
That seems a fair argument. The only thing I'm thinking is potential end goals of the project -- if the idea is that people who are new to programming can use it to learn, they might see an example on line that starts with |
No description provided.