Hi Folks,
I am writing a simple parser to parse SPICE code ( Spice is a transistor level simulator ). The spice code looks like this -
=============== =========
R10 2 3 0.5e-3
C11 4 6 0.2e-6
L13 4 4 0.1e-9
=============== ==========
As you can see each line has 4 items -
a character string followed by an integer then another integer and finally a floating point number.
I need to return the appropriate token on a per line basis.
I am attaching a tar ball called parse.zip that has the following files -
1. netlist ( the source file to be parsed )
2. spice.lex ( the lexer code )
3. spice.y ( the grammar )
4. Makefile
To build the parser, simple type make ( on linux ). Then to run -
%parser < netlist
In the .y file I have the grammar rule where I expect $1 to return the character string, $2 to return the first integer, $3 to return the next integer value and finally $4 to return the floating point value on a per line basis. Mos of this works correctly, except $1 returns the entire line instead of the character string. Can anyone tell what's wrong in the token generator ( lex file ) or the grammar description ( .y file ) ?? Any help will be highly appreciated.
Thanks,
Rajat Mitra
I am writing a simple parser to parse SPICE code ( Spice is a transistor level simulator ). The spice code looks like this -
=============== =========
R10 2 3 0.5e-3
C11 4 6 0.2e-6
L13 4 4 0.1e-9
=============== ==========
As you can see each line has 4 items -
a character string followed by an integer then another integer and finally a floating point number.
I need to return the appropriate token on a per line basis.
I am attaching a tar ball called parse.zip that has the following files -
1. netlist ( the source file to be parsed )
2. spice.lex ( the lexer code )
3. spice.y ( the grammar )
4. Makefile
To build the parser, simple type make ( on linux ). Then to run -
%parser < netlist
In the .y file I have the grammar rule where I expect $1 to return the character string, $2 to return the first integer, $3 to return the next integer value and finally $4 to return the floating point value on a per line basis. Mos of this works correctly, except $1 returns the entire line instead of the character string. Can anyone tell what's wrong in the token generator ( lex file ) or the grammar description ( .y file ) ?? Any help will be highly appreciated.
Thanks,
Rajat Mitra