Background
I am using a Ruby - like language called Sapphire as a way to try out some of the ideas that I have on concurrency in programming languages. I am trying to copy double-quoted Ruby strings with embedded code, which I find very useful as a programmer.
Question
How does any Ruby interpreter include a double-quoted string with embedded code and AST?
eg:
puts "The value of foo is #{@foo}."
puts "this is an example of unmatched braces in code: #{ foo.go('}') }"
More details
The problem is how to decide which }code block closes. Blocks of code can have other braces inside them and with little effort they can be unsurpassed. A lexer can find the beginning of a code block in a string, but without the help of a parser, he cannot know exactly which character is the end of this block.
It looks like the Ruby file parse.yperforms both lexing and parsing steps, but reading this thing is a nightmare , it has 11,628 lines without comment and a lot of abbreviations.
source
share