I'm trying to do searches in CNC G-code files and operate only
in the code, skipping over comments. Comments are almost always
just a left-paren/right-paren pair on the same line, like these sample
lines:
N1000 T2 M6 (27/64 JOBBER DR TIN CTD 3.4" EXTEN)
(X0 Y0 = C/L OF PART)
(Z0 = TOP OF PART)
N123 G0 Z-1.1023 (ADJ FACE DEPTH HERE)
This is the general way I have been doing it:
(search-forward-regexp (concat "\\((\\)\\|" "N" (match-string 4)) nil
t)
(if (match-string 1)
(progn
(backward-char) ;go back so you are on the 1st paren
(forward-list)) ;skip over comment, going to matching paren
--rest of function--
That works to skip over comments, but when the tool description includes
a quote " such as:
N2000 T12 M6 (3/4" CARB FEM 4 FL 1.0 LOC)
forward-list stops at the " and says unbalanced parenthesis.
I wonder if there are other characters that will stop forward-list?
What way _should_ I be skipping over comments in reg-exes so any
characters will be skipped?
It would also be handy to find a way to stop when there are malformed
comments,
1. such as a ( without a matching ) on the same line
2. or ( then a second ( before a )
3. or ( then a ) and then another ) that has no right paren to match it
on the line.
Thanks,
Steve Mitchell
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-beta