[erlang-questions] Start Conditions in Lexical Analyzer Generator (leex)
Richard A. O'Keefe
ok@REDACTED
Tue Jan 21 02:00:35 CET 2014
On 20/01/2014, at 11:06 PM, Dmitry Kolesnikov wrote:
> Instead of porting flex input rules, I would take a look into flex interim results and try to map them to leex.
Or better still, take a step _right_ back and look at
the basic problem. Sometimes programmers using Lex or
Flex use start conditions when they don't need to.
PL/I-style comments are a good example of this.
It's _easier_ to process them using start conditions,
but it's _possible_ to process them without.
Using start conditions:
> "/*" BEGIN(comment);
>
> <comment>[^*\n]* /* eat anything that's not a '*' */
> <comment>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */
> <comment>\n ++line_num;
> <comment>"*"+"/" BEGIN(INITIAL);
Not using them:
"/*"[^*]*"*"+([^/*][^*]*"*"+)*"/" { line_num += count_nls(yytext); }
More information about the erlang-questions
mailing list