[erlang-questions] Start Conditions in Lexical Analyzer Generator (leex)

Dmitry Kolesnikov <>
Mon Jan 20 11:06:50 CET 2014


Hello,

Right… I think there is not a straight path from flex to Erlang leex. 
Instead of porting flex input rules, I would take a look into flex interim results and try to map them to leex.  

- Dmitry 

On 18 Jan 2014, at 03:25, Xiao Jia <> wrote:

> On Fri, Jan 17, 2014 at 10:53 PM, Dmitry Kolesnikov
> <> wrote:
>> Hello,
>> 
>> Probably, I've missed something… The start condition is the literal part of lex regex.
>> e.g.
>> 
>> Definitions.
>> 
>> WSS = [\x20\x09\x0A\x0D]+
>> VAR = [a-zA-Z.]+
>> 
>> Rules.
>> 
>> {if{WSS}{VAR}} : {token, {'if', TokenLine, TokenChars}}.
>> 
>> this matches token is it starts with if
> 
> That's probably not what Vance Shipley wants.  Using start conditions
> is sort of moving between state machines.  See below example excerpted
> from http://flex.sourceforge.net/manual/Start-Conditions.html#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);
> 
> 
>> 
>> - Dmitry
>> 
>> On Jan 17, 2014, at 4:42 PM, Vance Shipley <> wrote:
>> 
>>> I've never tried using leex before but since the job at hand is
>>> to parse a language file, where the reference implementation uses
>>> flex, it seemed like porting their lex input file for use with leex
>>> would be the way to go.
>>> 
>>> However I got stuck right away in that leex doesn't seem to support
>>> "start conditions":
>>> 
>>>  http://flex.sourceforge.net/manual/Start-Conditions.html#Start-Conditions
>>> 
>>> Am I missing something?
> 
> 
> From http://erlang.org/doc/man/leex.html rules have the following format:
> 
>        <Regexp> : <Erlang code>.
> 
> and apparently start conditions are not regular expressions... so
> probably there is no support for that.
> 
> 
> -- 
> Regards,
> Xiao Jia

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140120/676a6a84/attachment.html>


More information about the erlang-questions mailing list