Constructing vectors


To ng-spice-devel@ieee.ing.uniroma1.it
From Charles Williams <C.D.H.Williams@exeter.ac.uk>
Date Wed, 31 Oct 2001 22:13:18 +0000
Delivered-To mailing list ng-spice-devel@ieee.ing.uniroma1.it
Mailing-List contact ng-spice-devel-help@ieee.ing.uniroma1.it; run by ezmlm
Reply-To ng-spice-devel@ieee.ing.uniroma1.it

I occasionally work on a 3f5-based version of MacSpice

http://newton.ex.ac.uk/teaching/CDHW/Electronics2/MacSpiceRelease.txt

and will offer some of my patches to ngspice in due course. As part 
of my efforts I have have been thinking about getting the frontend 
processor to handle vectors correctly. My current thoughts are:

'let foo = [ 1 2 3 ]' doesn't work as the Berkeley docs imply it 
should. Mainly because there is no code for this in 3f5! It is not 
clear to me how the parser could be modified to make it work without 
breaking other things as the syntax is badly constructed and there 
are hacks that make assumptions about what '[stuff]' means all over 
the place... (beware the comma operator!)

For the time being I have fixed various bugs in com_let() which 
prevented expressions like 'let foo[2] = 99' working and incorporated 
index range checking.  I have also implemented a semicolon operator 
to facilitate construction of vectors and n-dimensional matrices. 
e.g. the command

'let foo = ((11;12);(21;22))' creates a 2x2 matrix, then
'let bar = (foo;(31;32))'     creates a 3x2 matrix
'let baz = (1;(3,4);5)'       creates a complex vector with 3 elements

It is necessary to protect the ; with ()'s to prevent it being 
treated as a command separator.

This seems broadly compatible with the Spice Opus approach and I 
prefer it to even a finished version of the 'compose' command.

So, do people agree with my judgement that, unless the whole syntax 
is redefined so it can be parsed as a regular grammar with one token 
look ahead, that let 'foo = [ 1 2 3 ]' is out and the semicolon 
operator is the next best thing?

If not, how can the parser be (elegantly) modified to deal with 
constructing vectors?

Obviously any command interpreter where 'let foo=a*b' is equivalent 
to 'foo = a*b' but 'foo=a*b' generates an error is less than ideal, 
however I regard backward- and cross-compatibility as an essential 
feature of any Spice like programme.

Has a policy on how NGspice handles this sort of thing already been agreed?

Does anyone apart from me care about the frontend command language?

Charles

Partial thread listing: