design datastructure for parsing the text file.

Hi,
This is srinivas, i am new to this forum,i need help from our forum. I stuck up with my code to parse and Extracting the information from the text file and dumping the extracted information onto another data structure in order access the design information instantly. The format of the file is given below.
please use the standard Template libraries,our code has to work on my compiler (GNU C compiler).

# c17
# 5 inputs
# 2 outputs
# 0 inverter
# 6 gates ( 6 NANDs )

// the keyword INPUT()represents the primary input in the design

INPUT(1)
INPUT(2)
INPUT(3)
INPUT(6)
INPUT(7)

//// the keyword OUTPUT()represents the primary OUTPUT in the design
OUTPUT(22)
OUTPUT(23)

10 = NAND(1, 3)
11 = NAND(3, 6)
16 = NAND(2, 11)
19 = NAND(11, 7)
22 = NAND(10, 16)
23 = NAND(16, 19)

The above file represents an electronic circuit description and i want to extract the circuit information into the arrays or vectors.

1) I want the n.of inputs and outputs in the design
2) Extract the inputs and outputs into the arrays or vectors.
3) Extract the information about NAND gates i.e the inputs(the R.H.S brackets represents the sequence of inputs to that NAND gate) going into it and output (L.H.S represents the output of the NAND gate) coming from it .I have to gather information about the NAND into the arrays or vectors,but i want the random access if inputs and outputs of perticualr NAND gate.
4) so for the above we need to design one data structure to extract the design information.

please help me..

I would suggest a data structure that holds the information about one connection. Then use a container to hold 23 instances of the structure. The data structure would need to hold fields for things like the connection number, what the connection is, and if it's a NAND gate, which gate it is.

Have a go. If you get stuck paste your attempt back here and someone will help point you in the right direction.
Topic archived. No new replies allowed.