[Gerbv-devel] [ gerbv-Bugs-3172530 ] Operator precedence not implemented in aperture macros
Brought to you by:
spetm,
thepurlieu
From: SourceForge.net <no...@so...> - 2011-02-19 21:41:20
|
Bugs item #3172530, was opened at 2011-02-04 04:22 Message generated for change (Comment added) made by thepurlieu You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=409538&aid=3172530&group_id=33921 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Gerber Parser Group: None >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Ben Rampling (benrampling) Assigned to: Stefan Petersen (spetm) Summary: Operator precedence not implemented in aperture macros Initial Comment: 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). ---------------------------------------------------------------------- >Comment By: Julian Lamb (thepurlieu) Date: 2011-02-19 16:41 Message: Fixed by Stefan, and is now in git. Please check out the latest git and make sure it works. Thanks-- Julian ---------------------------------------------------------------------- Comment By: Stefan Petersen (spetm) Date: 2011-02-18 16:45 Message: 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. ---------------------------------------------------------------------- Comment By: Julian Lamb (thepurlieu) Date: 2011-02-04 09:34 Message: 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 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=409538&aid=3172530&group_id=33921 |