[erlang-questions] Re: sending extra information to leex or yecc? (or how to know the name of the file I'm parsing in them)
Sun Jun 6 19:42:34 CEST 2010
On Sun, Jun 6, 2010 at 11:54 AM, Robert Virding <> wrote:
> Do you mean the name of the source files used to generate a leex
> scanner or a yecc parser? Or do you mean the name of a file scanned by
> a leex scanner or parsed by a yecc parser?
> For a description of how a scanner/parser is integrated into the i/o
> system check out the i/o part of the Erlang Rationale found at:
> In short neither know who calls them. When generating a scanner/parser
> there is no direct way to get the source file names, indirectly the
> source name is used to generate the module and file name of the
> resultant scanner/parser.
> What is that you want to do?
I had to replace some macro variables in my language and needed to
know the name of the file that I was parsing to replace $module
$module_string and $file, what I did whas to spawn a process, register
it with a name and before starting the parsing I stored the
information in the process, then from yecc I request the
information sending a message
if there is a better way to do it I would like to know how, if there
is some observations on how I did it it would be nice too :)
More information about the erlang-questions