boo-lang / boo

The Boo Programming Language.
BSD 3-Clause "New" or "Revised" License
874 stars 148 forks source link

Annotate string quotes and new backtick quoted string #35

Closed drslump closed 12 years ago

drslump commented 12 years ago

Sometimes it's useful to know from a macro or compiler step what kind of quotes were used for a string literal, allowing for example to automatically convert to char those strings with a length of 1 enclosed in single quotes. It's also pretty common for scripting languages to use the backtick "`" to quote literals to be executed verbatim.

This pull request annotates string literals so that the exact quote character used is not lost when parsing and introduces a new string literal quoted by backticks which doesn't perform any escaping on the contents, ideal to define verbatim text with it.

exec `ls /path/to/dir | grep "foo" | wc -l`

eval `
    for i in range(10):
      print "Iteration $i" 
`
bamboo commented 12 years ago

Thanks!

drslump commented 12 years ago

Sorry @bamboo, I forgot to apply the changes to the WSA grammar. It's in commit afe198ced9aa4e68a529c98d5e3bdb816e11fd5a but the pull request doesn't update itself once it's closed. Could you manually merge that commit or re-open the pull request to have github apply it?

thanks!