[plt-scheme] Parsing not ignoring \n

From: Paulo J. Matos (pocmatos at gmail.com)
Date: Thu Jun 18 14:08:03 EDT 2009


I have a question regarding on how to user parser tools to handle the
following. My language has C style comments which means I have
something like:
  (line-comment (:: "//" (complement (:: any-string "\n" any-string)) "\n"))
  (c-style-comment (:: "/*" (complement (:: any-string "*/" any-string)) "*/")))

In the lexer:
(define eb-lexer
   ;; Ignore Comments
   ((:or whitespace c-style-comment line-comment) (return-without-pos
(eb-lexer input-port)))

In the parser I then don't worry about newline... it's as if
everything could be in the same line.
Now, I want to change the language a bit, so that new lines _ending
statements_ become important.
However, the issue is that by stripping the line-comment, I am
stripping the last new line. Is there a way to remove the line comment
in the lexer but still maintaining the new line?

So, if I have :
TOKEN1 // comment \n TOKEN2
I could get

Paulo Jorge Matos - pocmatos at gmail.com

Posted on the users mailing list.