
Hi, Q1: I am trying to create an Alex equivalent of the following flex file: http://code.haskell.org/yc2js/es-idl/lexer.ll (lexer for Web IDL which is a dialect of OMG IDL) I haven't been able to find Alex equivalent for the following line: PoundSign ^{WhiteSpace}*# that is any amount of whitespace at the beginning of line followed by '#' I defined a @WhiteSpace macro some place earlier, but Alex gives me parser error on the line I created: @PoundSign = ^@WhiteSpace*# in the position 28 that is position of '@', next to caret, that is, caret is not recognized by Alex. Can beginning of line (caret) be recognized by Alex? Q2: The original line says: MultiLineComment \/\*(([^*])|(\*[^/]))*\*\/ basically same as comments in C or Java. I had to prefix star and slash even within square brackets with backslashes to make it compile. So I got: @MultiLineComment = \/\*(([^\*])|(\*[^\/]))*\*\/ Is this correct understanding that if we want to match any character except for an asterisk, then Alex would like to see [^\*] rather than [^*]? And [^\/] rather than [^/]? Or would it be better to use a hex code for the asterisk and slash? Thanks. -- Dimitry Golubovsky Anywhere on the Web

2009/5/1 Dimitry Golubovsky
except for an asterisk, then Alex would like to see [^\*] rather than [^*]? And [^\/] rather than [^/]?
Or would it be better to use a hex code for the asterisk and slash?
In a character set you must escape certain special characters. The list of special characters is specified in the docs here: http://www.haskell.org/alex/doc/html/syntax.html#lexical The key line is: $special = [\.\;\,\$\|\*\+\?\#\~\-\{\}\(\)\[\]\^\/] I'd try to avoid character codes where possible. Cheers, Bernie.
participants (2)
-
Bernie Pope
-
Dimitry Golubovsky