[erlang-questions] Parsing C with leex and yecc

Sverker Eriksson sverker@REDACTED
Tue Jul 20 12:32:36 CEST 2010


Joe Armstrong wrote:
> I'm trying to parser ANSI C with leex and yecc and have run into
> two problems.
>
> 1) /* ... */ comments. Leex is (as I understand things) greedy
>    thus I can't just write a regexp to match comments, since it
>    will consume no-only the current comment, but all comments until
>    the last comment in the file.
>
>    To solve this I have just written a simple pre-processor to remove comments
>    from the original source.
>
>   
re:run("/***first comment***/ /* next comment */", 
"/\\*([^*]|(\\*+([^*/])))*\\*+/").

http://ostermiller.org/findcomment.html

/Sverker



More information about the erlang-questions mailing list