[plt-scheme] Parsing not ignoring \n

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

Hi,

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:
(define-lex-abbrevs
  (line-comment (:: "//" (complement (:: any-string "\n" any-string)) "\n"))
  (c-style-comment (:: "/*" (complement (:: any-string "*/" any-string)) "*/")))

In the lexer:
(define eb-lexer
  (lexer-src-pos
   ;; 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
TOKEN1 \n TOKEN2
?

Cheers,
-- 
Paulo Jorge Matos - pocmatos at gmail.com
http://www.pmatos.net


Posted on the users mailing list.