Parsing a spice netlist, need to be faster

  • Thread starter Adam Chamberlain
  • Start date
A

Adam Chamberlain

Hey guys! I am writing some code that has gotten far too slow. I am
reading files that have the following types of statements:

This is all test written in a file
+bob = 2
+roger = 3
+barn = 'bob'
+frank = '3 + roger'
+nancy = 'roger*6 ' gary =4 jason= 'bob+roger'

It cannot be assumed that bob will be declared before barn, though I
would like to know if it isn't in certain modes. I want to be able to
read all these parameters in (there will be roughly 20,000 of them) and
be able to dump them into an object. That way I can do something like
a["nancy"] and get 18. The code is currently too slow. I need to read
parse strings really fast and be able to evaluate these statements. For
example, if I read in '3 + roger' and do an eval(a), there will be a
nomethod error because roger is not defined. I cannot have roger as a
variable because I can't keep it in scope. Instead I have to pick the
line apart and get 'roger' out of it, then I search through the hash
table to find where roger is. This implementation works but is
incredibly slow. I need someone to point me to some good practices in
Ruby for parsing text and trying to evaluate what's found.

I also recognize the danger of the eval command. I have taken steps to
limit what can and can't reach the eval statement. For example, it is
impossible for backticks to reach the eval command, removing one method
of making a system call within the evla statement.

Adam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top