Issue #11181 has been updated by Allen Morris.


I have changed the code to use the **magic comment** feature.  To use the directive you now use:

    # -*- line: filename 1000 -*-

or

    # -*- line: 1000 -*-

Where the filename is optional and the line number is greater than zero.

The filename if included is parsed in the same way as the arguemnt to the 'coding magic comment'.  The line number is parsed as a base 10 unsigned long.

This is all done in a funtion called `magic_line` in _parse.y_.

----------------------------------------
Feature #11181: Add a line directive to Ruby
https://bugs.ruby-lang.org/issues/11181#change-52670

* Author: Allen Morris
* Status: Open
* Priority: Low
* Assignee: ruby-core
----------------------------------------
Add a __line directive__ to Ruby

```
  #line {nn} ["filename"]
```

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 also use the correct file names.

The __\_\_LINE____ and __\_\_FILE____ _constants_ are updated and compile time warnings are also effected.

There is a pull request at https://github.com/ruby/ruby/pull/910

The patch does not have any affect on current programs unless a line matching '#\s*line \d+(\s+"(.*)")?\s*$' is found in the ruby source code. 


More tests need to be written before this change sould be applied.

Use case:

This is helpful for debugging any generated code but is particularlly helpful for literate programming using Noweb.



-- 
https://bugs.ruby-lang.org/