Maker Pro
Maker Pro

SPICE syntax and grammer

Hi, does anyone know where I can get a formal Backus-Naur style syntax
and/or grammar definition for any of the various SPICEs out there?

Specifically, hspice, pspice, or berkeley spice. What is the
difference from a grammar/syntax perspective?


thanks
ms
 
J

Jim Thompson

Jan 1, 1970
0
Hi, does anyone know where I can get a formal Backus-Naur style syntax
and/or grammar definition for any of the various SPICEs out there?

Specifically, hspice, pspice, or berkeley spice. What is the
difference from a grammar/syntax perspective?


thanks
ms

I have no idea what "a formal Backus-Naur style syntax" is.

Are you speaking of "commands" such as .TRAN, etc?

If that is what you are after, the various SPICE's have the same
command line structure, except that HSpice has a few additional ones,
..ALTER for instance, that I wish PSpice had :-(

...Jim Thompson
 
Hi,

The backus-naur grammar format specifies exactly how a spice parser
would read in the text file and create the data structures representing
the circuit.

For instance, a parameter list would be something like:

PARMLST:=PARMLST TUPLE | TUPLE

TUPLE:= VAR '=' NUM

VAR = non-keyword
NUM = number

So this means a PARMLIST consists of another parmlist and a tuple, or
just a tuple. A tuple is a variable followed by an equals sign
followed by a number. With these rules it's possible to describe most
computer languages and stuff. I'm sure SPICE has one, but I haven't
been able to find it.

thanks
ms
 
J

Jim Thompson

Jan 1, 1970
0
Hi,

The backus-naur grammar format specifies exactly how a spice parser
would read in the text file and create the data structures representing
the circuit.

For instance, a parameter list would be something like:

PARMLST:=PARMLST TUPLE | TUPLE

TUPLE:= VAR '=' NUM

VAR = non-keyword
NUM = number

So this means a PARMLIST consists of another parmlist and a tuple, or
just a tuple. A tuple is a variable followed by an equals sign
followed by a number. With these rules it's possible to describe most
computer languages and stuff. I'm sure SPICE has one, but I haven't
been able to find it.

thanks
ms

Seems that would be a function of how closely the software writers
adhered to the original Berkeley approach which, IIRC, was written in
Fortran. I know that PSpice was re-written in C. I don't know about
other SPICE's.

...Jim Thompson
 
J

Jens Tingleff

Jan 1, 1970
0
Hi, does anyone know where I can get a formal Backus-Naur style syntax
and/or grammar definition for any of the various SPICEs out there?

I doubt that you can. I had a look some time ago, and one stumbling block is the
fact that tokens can mean different things depending on where they occur. While
it is possible to describe grammers with this property in some scanner/parser
generator systems, I doubt that BFN or its ilks will do.

Consider

R R 0 R

which describes a resistor (line starts with 'R') from node R to node 0 with the
value R. This is legal in hspice input language and other extensions of the
Berkeley Spice input language (expecting a defintion of the value of the
parameter 'R,' of course) but makes scanning/parsing a challenge.

I would love to see such a grammar, but didn't find one when I was looking for
it.

That said, the original Berkely Spice 2 accepted such a simple input language
that a formal description should be possible.

Best Regards

Jens
 
F

Fred Bartoli

Jan 1, 1970
0
Jens Tingleff said:
I doubt that you can. I had a look some time ago, and one stumbling block is the
fact that tokens can mean different things depending on where they occur. While
it is possible to describe grammers with this property in some scanner/parser
generator systems, I doubt that BFN or its ilks will do.

Consider

R R 0 R

which describes a resistor (line starts with 'R') from node R to node 0 with the
value R. This is legal in hspice input language and other extensions of the
Berkeley Spice input language (expecting a defintion of the value of the
parameter 'R,' of course) but makes scanning/parsing a challenge.

I would love to see such a grammar, but didn't find one when I was looking for
it.

That said, the original Berkely Spice 2 accepted such a simple input language
that a formal description should be possible.

We once developped a library maintaining tool and went to exactly the same
conclusion.

OTOH I just googled for "spice grammar" + parser and found a message (dated
03/2005) from somebody trying to write one using ANTLR. Maybe you can
contact him : simon at icmethods dot com
 

Similar threads

J
Replies
3
Views
1K
Helmut Sennewald
H
B
Replies
3
Views
2K
Charlie Edmondson
C
Top