I know nothing about Parse::RecDescent
, but my (naive) solution would be to pre-process the file and delete the offending comments. Provided you will have no more than one ';' per line that could be easily done with a split
That would also allow you to capture the comments and save them somewhere.
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James