Menu

#140 Operator precedence not implemented in aperture macros

closed-fixed
5
2011-02-19
2011-02-04
No

Section 4.2.2 of the RS-274X specification says the following about the aperture macro arithmetic operators:

"The standard arithmetic precedence rules apply."

gerbv does not implement precedence and simply evaluates left to right.

I have created a 10 line test case, attached.

The attached sample should show a 2 inch OD, 1.9 inch ID annulus (a thin circle). GC-Prevue does implement precedence, and correctly displays the attached sample. gerbv incorrectly displays a 2 inch OD, 0.1 inch ID annulus (a disc with a small hole).

The following expression in the example is responsible:

1.8 + 1 x 0 + 0.1

It should be evaluated as:

((1.8 + (1 x 0)) + 0.1)

Presumably gerbv is doing:

((1.8 + 1) x 0) + 0.1

A simplified version of the shunting yard algorithm can be used to parse these expressions correctly, while only using three variables (two to hold expression stack numbers, and one to hold the single operator stack entry; it isn't necessary to use actual stacks, just three normal variables).

Discussion

  • Ben Rampling

    Ben Rampling - 2011-02-04

    A ten line test case (gerber file)

     
  • Julian Lamb

    Julian Lamb - 2011-02-04

    Ben,
    Hmmm...thanks for tracking this down. I was unaware of the precedence requirement. I'll forward this to Stefan, who did the macro parsing logic, and hopefully we can get a fix for this without *too* much reworking. Patches are also welcome too... :)

    Cheers,
    Julian

     
  • Stefan Petersen

    Stefan Petersen - 2011-02-18

    Dear Ben,
    Thanks for notifying us on the precedence requirement (not explicit in the "old" standard) and also suggesting an algorithm. I think I have implemented the algorithm, but I need to verify it a bit more before releasing it to the wild.
    I want your permission to use your example as a test case in our test case suite.I hope it is OK to add it to our repo and use it to test compliance.

     
  • Julian Lamb

    Julian Lamb - 2011-02-19

    Fixed by Stefan, and is now in git. Please check out the latest git and make sure it works. Thanks--

    Julian

     
  • Julian Lamb

    Julian Lamb - 2011-02-19
    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB