Suan Yeo | 1 Jul 00:38

Parsing across multiple buffers and maintaining state (prefably without additional memory usage)

I'm trying to search for a particular string within a chain of buffers, say,
"sausage". Right now, it works fine if "sausage" is wholly in one buffer, but if
it is split between 2 buffers, eg, {"........sau", "sage........", ...}, flex
does not match it. This is my current implementation:

while (buf)
{
  buf_state = yy_scan_bytes(...);
  result = yylex();
  yy_delete_buffer(buf_state);
  buf = buf->next;
}

I use yy_scan_bytes because as I understand it does not copy it into a new
buffer (ie. scans in-place). How should I change my implementation to achieve
the above (other than copying everything into a single buffer)?
Yu-zhong shen | 23 Feb 03:33

Help! How to use unicode in flex?

I am working with flex in GNUWin32.

I want to process some unicode text with it.

Is there any option or patch of flex that support the unicode?

_______________________________________________
help-flex mailing list
help-flex <at> gnu.org
http://lists.gnu.org/mailman/listinfo/help-flex
孟伟超 | 31 Dec 11:01
Favicon

Excuse me

I want a flex
_______________________________________________
help-flex mailing list
help-flex <at> gnu.org
http://lists.gnu.org/mailman/listinfo/help-flex
Georg.Tenckhoff | 29 Apr 10:19
Favicon

(no subject)

Hallo everybody,

is there any trick to convince flex to auto-complete options entered e.g. from stdin? Posed the same
question differently: Can I access the flex parse tables as a kind of tree structure indicating which
characters are allowed to follow as branches?

Freundliche Grüße / Kind regards

Georg Tenckhoff
lookthree | 27 Jan 22:13

Help please

Hi,
I'm a new Flex user.
I'm having the follow problem:

1. I've created one file Example.l:

%option c++
%option yylineno
%option noyywrap
%option caseless

delim [ \t\n]
ws {delim}+
letter [A-Za-z]
digit [0-9]
id {letter}({letter}|{digit})*
number {digit}+(\.{digit}+)?(E[+\-]?{digit}+)?

%%
            int yylval;
{ws}        {;}
if          { return(IF);}
then        { return(THEN);}
else        { return(ELSE);}
{id}        { return(ID);}
{number}    { return(NUMBER);}
"<"         { yylval = LT; return(RELOP);}
"<="        { yylval = LE; return(RELOP);}
"="         { yylval = EQ; return(RELOP);}
"<>"        { yylval = NE; return(RELOP);}
">"         { yylval = GT; return(RELOP);}
">="        {yylval = GE; return(RELOP);}
.           {return(ERROR);}
%%


and i've run >Flex example.l

and it has returned the file lex.yy.cc.

2. Well, i've created also the main program in c++, let's call it main_prog.cpp:



#include <stdio.h>
#include <ctype.h>
enum {LT, LE, NE, GT, GE, EQ, IF, THEN, ELSE, ID, NUMBER, RELOP, ERROR};
#include <FlexLexer.h>
#include "lex.yy.cc"

int main(int argc, char *argv[])
{
    int token;
    FlexLexer* lexer = new yyFlexLexer();
    while ((token=lexer->yylex()) != 0) {
        switch (token) {
        case RELOP: printf("%s","RELOP"); break;
        case NUMBER: printf("%s","NUMBER"); break;
        case ID: printf("%s","ID"); break;
        case IF: printf("%s","IF"); break;
        case THEN: printf("%s","THEN"); break;
        case ELSE: printf("%s","ELSE");break;
        case ERROR: printf("%s", "illegal character"); break;
        default:
                    printf("%s","UNKNOWN");
                    break;
        }
        printf("%s\n", lexer->YYText());
    }
    return 0;
}

The problem becomes when I compile it using

        g++ main_prog.cpp -o main_prog

,infact the system answer me with:

/usr/include/FlexLexer.h:113: error: redefinition of ‘class yyFlexLexer’
/usr/include/FlexLexer.h:113: error: previous definition of ‘class yyFlexLexer’

thank you for helping me,

Simone.










**********
Scopri la nuova Alice Mail!
1 GB di spazio con antivirus, antispam e fino a 2 GB di allegati.

Registrati GRATIS su http://registra.rossoalice.alice.it/registra/basic/entratabasic.do?entryPoint=footer

_______________________________________________
help-flex mailing list
help-flex <at> gnu.org
http://lists.gnu.org/mailman/listinfo/help-flex
Eric Fowler | 8 Sep 04:25

Flex empty string

I hear a rumor this is the place for online flex discussion.

I am a relative newbie and I want to match NMEA 0183 strings coming from a GPS.

They look like this:
$GPGGA,123519,4807.038,N,01131.000,E,1,08, 0.9,545.4,M,46.9,M,,*47

except when they look like this:

$GPGGA,123519,4807.038,N,01131.000,E,,,,,,,,,*47

In other words, many fields can be blank, but they are always comma - delimited. When they exist they are nicely structured, e.g. {DIGIT}{4}"."{DIGIT}{3} matches a latitude string.

So how do I distinguish between a field with some specific data and a delimiter, and an empty string followed by the same delimiter?

Thanks.

Eric

_______________________________________________
help-flex mailing list
help-flex <at> gnu.org
http://lists.gnu.org/mailman/listinfo/help-flex
Carlos Smith | 2 Jun 15:47

Building flex-2.5.34 from CVS

Hi,

Just want to confirm i succesfully build
flex 2.5.34 fresh from cvs.

The README.cvs says to use

gettext 0.14.5, but it does not work.
Instead you needs gettext-devl (for autopoint)

Also, is ident 2.8 the correct version.
May be it is 2.2.8 ?

-- carlos
harsh | 31 May 08:11

warning

Hi,

 

I get a warning dealing with "yy_flex_realloc" saying that:'void* yy_flex_realloc(void*, yy_size_t)' defined but not used,

I would like to know how it's posssible to avoid it.

 

Best regards,

Harsh

 

DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Pvt. Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Pvt. Ltd. does not accept any liability for virus infected mails.

_______________________________________________
help-flex mailing list
help-flex <at> gnu.org
http://lists.gnu.org/mailman/listinfo/help-flex
post2li | 29 May 13:09
Favicon

Flex/Bison Segment Fault?

I am trying to test the code in the book "Lex & Yacc, 2nd", however,
it didn't work as described. Pls.

# uname -a
Linux redhat9 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686 i386
GNU/Linux

# flex -V
flex version 2.5.4

# bison -V
bison (GNU Bison) 1.35

# flex -olexa.yy.c ch1-05.l
# bison -obisa.tab.c ch1-05.y
# gcc -o ex bisa.tab.c lexa.yy.c -ll

# ./ex
Segmentation fault
kkc | 25 May 18:34
Favicon

lex & yacc, Second Edition example compile code problem


I try compile all code using "make" command in linux, but it come back with
compile error, please help.

thank you!

/* output
[work]$ make
flex ch1-01.l
mv lex.yy.c ch1-01.c
gcc -g -o ch1-01.pgm ch1-01.c -ly -ll
/usr/bin/ld: cannot find -ly
collect2: ld returned 1 exit status
make: *** [ch1-01.pgm] Error 1
[work]$

*/
--

-- 
View this message in context: http://www.nabble.com/lex---yacc%2C-Second-Edition-example-compile-code-problem-tf3817146.html#a10806368
Sent from the Gnu - Flex mailing list archive at Nabble.com.
arun kv | 30 Apr 12:54
Favicon

memory errors ....

  
Hi All, 

I have implemented a parser using lex and yacc ,  my lex and yacc files are named parser.y and scanner.l 
(these files are compiled with flex++ and bison++  to make my parser compatible with C++) 
My parser is working fine but .... 
The issue is when I run my parser with purify (a memory detection tool ) .It gives out memory errors in the flex
and bison generated  source codes (parser.cpp , parser.h and scanner.h )

The purify errors for the parser are : 
IPR :Invalid pointer read , IPW :Invalid pointer write , BSR: Beyond stack read error 
Shown by these variables in parser.cpp 
yystate
yyn    
yyssp  
yyvsp  
yyerrstatus    
yycharl

For detailed purify log please see the attached file. 
What I want to know is that, Is there any way in which I can control these variables form my lex and yacc files. 
Or how else I can fix these memory errors shown by purify. 
Best Regards 
Arun 

Attachment (parser.log): application/octet-stream, 41 KiB
_______________________________________________
help-bison <at> gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Gmane