help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Defining Rules


From: Tim Van Holder
Subject: RE: Defining Rules
Date: Fri, 12 Sep 2003 20:27:14 +0200

> As a newbie, I have a newbie question (please be patient)
> 
> I am "writing" a scanner for ASP.
> 
> My intention is treat every html line as single token and 
> diferentiate just
> VBscript tokens, starting with <%, using the following rules:
> 
> %x vbs
> %%
> "<%" {printf("START VBS");BEGIN(vbs);}
> "<%=" {printf("VBS-RESPONSE.WRITE");BEGIN(vbs);}
> <vbs>"%>" {printf("END VBS");BEGIN(INITIAL);}
> .* {ECHO;}
> %%
> 
> Rules above result in every line been scanned by .* rule and 
> "<%" rule never
> gets in.

Flex always uses the longest possible match.  This means that
when the line had "<%=" it will use "<%=" and not "<%".
It also means that if you have a matcher like .* (= whole line)
it will take that.
Simply delete the .* line (ECHO is the default anyway), or change
the matcher to a single '.'






reply via email to

[Prev in Thread] Current Thread [Next in Thread]