bwilso
@gmail.com wrote:
> On May 11, 11:30 am, "Gerald W. Lester" <Gerald.Les
@cox.net> wrote:
>> bwilso
@gmail.com wrote:
>>> I'm putting together a script that parses a file which contains the
>>> following 3 possibilities to extract the file name from a given line.
>>> Please see the examples below:
>>> 1) add_file -verilog -lib work ../../../my_design.v
>>> 2) add_file -verilog -lib work "../../../my_design.v"
>>> 3) add_file -verilog -lib work {../../../my_design.v}
>>> In all 3 of the above cases, the file name I need is ../../../
>>> my_design.v. For the first case, I was using the following code,
>>> which works nicely:
>>> set keyword "add_file"
>>> ...
>>> if {[string match *$keyword* $line]} {
>>> set splitlist [split $line " "]
>>> set filename [lindex $splitlist 4]
>>> }
>>> However, this code breaks for cases 2 and 3. Can anyone suggest a
>>> more flexible solution? I'm guessing it may involve regular
>>> expressions, which currently scare me, but I'm definitely going to
>>> look into taking away this fear.
>> Why not add a proc called add_file in a safe interp and source the file with
>> the add_file's into it. The the fourth argument would be the filename.
>> Tcl is great for defining mini-languages like that.
>> --
>> +--------------------------------+---------------------------------------+
>> | Gerald W. Lester |
>> |"The man who fights for his ideals is the man who is alive." - Cervantes|
>> +------------------------------------------------------------------------+
> This seems like a good idea, but unfortunately it's not always the 4th
> arg. I tried what Stephan suggested and it seems to work nicely.
> Must bow down to the TCL gurus... =)
glad it's working, but if you ever have a filename (or path) with a