Coder Social home page Coder Social logo

Comments (3)

nilscript avatar nilscript commented on September 18, 2024

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 #.

from rockstar.

dylanbeattie avatar dylanbeattie commented on September 18, 2024

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.

from rockstar.

gaborsch avatar gaborsch commented on September 18, 2024

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

from rockstar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.