Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for end-of-line comments using # so that shebangs (e.g. #!/usr/bin/rockstar) work #276

Open
nilscript opened this issue Apr 3, 2021 · 3 comments
Labels
backlog Stuff we WILL do. good first issue Good for newcomers
Milestone

Comments

@nilscript
Copy link

It's not pretty but practical. If I want my lyrics to mean something I have to wrap them around an interpreter which is fuggly.
Would it be to much to ask if the spec allowed shebangs on the top?
Example usage after implementing shebangs:

#!/usr/bin/env <your favorite interpreter>
Midnight takes your heart and your soul
<rest of lyrics>
@nilscript
Copy link
Author

An easy way to implement this would be to ignore parsing any lines starting with # but that would create a new kind of comment which is not in the spec. So an almost an easy way would be to ignore the first line of any program if it starting with #.

@dylanbeattie
Copy link
Collaborator

I'm happy to add end-of-line comments using # as the comment character, just as it works in bash, Python, Perl, etc.

#!/usr/bin/rockstar
# this entire line is a comment

shout "hello world" # this is also a comment

Sure, they're not very rock'n'roll, but if you're being absolutely idiomatic you shouldn't be using comments anyway. :)

I had a very quick look at plugging this into the PEG grammar, and it's not quite as easy as I thought... if anybody wants to take a look, go for it; happy to accept a PR for this. If not, I'll take a look when I have a little more time.

@dylanbeattie dylanbeattie added backlog Stuff we WILL do. good first issue Good for newcomers labels Apr 8, 2021
@dylanbeattie dylanbeattie changed the title Add support for shebang Add support for end-of-line comments using # so that shebangs (e.g. #!/usr/bin/rockstar) work Apr 8, 2021
@gaborsch
Copy link

I have added the shebang support to Rocky, as well as the # comment line support, for all the use cases @dylanbeattie sketched above.

If we have an entire line # comment, it won't behave like an empty line (end of block), rather the line is simply skipped. This is useful if you are in the middle of coding, but you want to temporarily comment out a line, e.g in a function or in a loop.

For example, here are 2 whole line comment lines in the middle of the loop - if they were treated as empty lines, it would break the While loop block.

Love is " bottles of beer on the wall"
Problems are " bottles of beer"
Carol says Take one down, pass it around
The beers were numbering fa'too'many
While the beers ain't nothing
Shout it with Love
#Shout it + " bottles of beer on the wall"
Shout it with Problems
#Shout it + " bottles of beer"
Say Carol,
Knock the beers down
Say it with Love

@dylanbeattie dylanbeattie added this to the 2.0 milestone Mar 15, 2024
@dylanbeattie dylanbeattie reopened this Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Stuff we WILL do. good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants