help-bison
[Top][All Lists]
Advanced

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

Re: Recognize Stings Tokens.


From: Claudio Saavedra
Subject: Re: Recognize Stings Tokens.
Date: Sat, 22 Dec 2007 20:37:14 -0300

[please keep the list in the cc in subsequent replies, so that others
may join the discussion]

El dom, 23-12-2007 a las 00:18 +0100, Jester Underrun escribió:
> Hi Claudio
> 
> TNX for your suggestion. The manual don't speek much about interaction
> with flex but now I try to use it and something works. I have a little
> (I suppose little :D) problem with string "format" recognition. For
> example I have this flex file:
> 
> %option noyywrap
> 
> %%
> string1 { return(STR1); }
> string2 { return(STR2); }
> /*OTHERS STRINGS...*/
> [ \t\n]+
> ^[a-z]+
> %%
> 
> and this example of grammar rules:
> 
> %{
>         #include "lex.yy.c"
>         int main(int argc, char *argv[]);
>     %}
> 
>     %token STR1 STR2
>     %glr-parser
> 
>     %%
>     S0: STR1 F0 ;      
> 
>     F0: F1 | F2 ;
> 
>     F1: STR2 F3 ;
> 
> .......
> 
> If I start the parser and i digit STR1 and STR2 work....If I digit
> STR1 and after a STRX != STR2 return an error and I'm happy...but if I
> digit a trash string like "ababababababa" the parser don't return an
> error....is a lexical problem? I have defined ^[a-z]+ for this cases,
> it seems no sufficient....You know this trick?

If I remember correctly, ^[a-z]+ means "any string composed by one or
more symbols over {a, .., z}, that starts line", so I suppose that your
scanner is accepting strings in ^[a-z]+ as valid but ignoring them,
given that there is no action associated with that rule.

Check the flex manual for more details on how to use it:

  http://www.gnu.org/software/flex/manual

You can also ask in the comp.compilers usenet group, as this is slightly
off-topic.

Greetings,

Claudio


-- 
Claudio Saavedra <address@hidden>





reply via email to

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