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
Line Directive Patch #911
Line Directive Patch #911
Conversation
I don't think it's a good choice for Ruby to have a directives. You can implement your own preprocessor for these needs (piggybacking on eval <<-RUBY, line, filename
# ...
RUBY Ruby is an interpreter and virtual machine but not your literate programming framework. |
@marshall-lee Agreed. |
The problem is that my input file looks like
Some buildy thingy is run on this that reads all three files and used ''' as the start and generate something like:
Then there is the less likeley case where you have non-complete 'code blocks'. This would be where
|
It does not have to be a directive, but I think that this is the cleanest approach. Also note that Ruby already has a directive
|
What the problem in preprocessing the code smarter? Group all these chunks by file name, concatenate them and pass to eval. |
It does not have to be a directive, but I think that this is the cleanest approach. Also note that Ruby already has a directive
|
d6d0878
to
32873f5
Compare
It seems to have a conflict now. Could you rebase this from master? |
Let me close this as it has not been updated for a while. Please reopen this after resolving conflicts. Thanks. |
Add a line directive to Ruby
The filename is parsed by the standard magic comment code. if only one argument is passes it is assumed to be a line number. If there is a parse error or the line number evaluates to 0, the directive is ignored.
This is done by creating a array of filenames and using the upper bits of the line_number to determine the current filename. The original filename is in position 0.
An extra node is added by the parser that informs the compiler of the filenames so the backtrace code can follow it.
The LINE and FILE constants are updated and compile time warnings are also effected.
https://bugs.ruby-lang.org/issues/11181