1 Description of how aperture macros are implemented in gerbv
7 Operation of gerbv is split in two stages; parsing and drawing.
8 This makes it simpler handle peculiar syntax in different gerber
9 implementation by just doing the parser more robust. It also
12 Handling of aperture macros are also split in two parts, ie parsing
17 When the command "%AM" is stumbled upon in the gerber file command
18 is left to the function parse_aperture_macro in amacro.c. It first
19 extracts out the name of the aperture macro. Then it tries to build
20 program in a very primitive assembler. This program should describe
21 how to draw the macro. The assembler consist of 8 instruction intended
22 for a stackbased machine. The instructions are:
23 NOP, PUSH, PPUSH, ADD, SUB, MUL, DIV, PRIM.
27 NOP : The no operation. This is the default instruction and are
28 added as a security measure.
29 PUSH : Pushes a value on the stack. This machine only works with floats
31 PPUSH: Pushes inparameters onto the stack. Gerber aperture macros accepts
32 parameters to be set when later declared, so the same macro can
33 be used at several instances. Wich parameter to b set is an integer
35 ADD : The mathematical operation +. Takes the two uppermost values on the
36 the stack, adds them and pushes the result back onto the stack.
37 SUB : Same as ADD, but with -.
38 MUL : Same as ADD, but with *.
39 DIV : Same as ADD, but with /.
40 PRIM : Aperture macros are based on primitive figures, which then are
41 combined in a macro. This instruction describes which primitive
42 figure to draw (for a description, see Gerber documentation) and
43 all parameters when drawing this primitive figure is taken from
44 the stack (and hence popped).
48 The parser have no precedence at all regarding mathematical operations.
49 The standard doesn't define any, but the limit lies only within the parser.
50 The parser handles several primitives within one aperture macro definition.