A question to Lex problem

A question to Lex problem

Post by Geoff Li » Wed, 02 Jul 2003 14:11:15



All:

I have a rather large LEX codes which can work properly before.  Recently, I
update it to record the current processing line by adding two starting states.
However some errors will be reported by the compiler.

It looks strange since it seems the syntax is ok.  And  I can't find the reason
after several days' debugging.  Could you please give me some help on it? The
following are the error report and codes for a simplified version for a easier
debug

"resource/lex.l":line 49: Error: syntax error
"resource/lex.l":line 48: Error: Illegal rule
"resource/lex.l":line 55: Error: Illegal rule
"resource/lex.l":line 56: Error: Parse error

1  %a 3000
     2  %o 4000
     3
     4  %{
     5
     6  /* include yacc-produced header file for token types */
     7  #include <gram.h>
     8  #include <strings.h>
     9  #include <ResourceDefs.h>
    10
    11  extern char reslinebuf[500];
    12
    13  %}
    14
    15  %s PREPROCESSING PROCESSING
    16
    17  %{
    18                  BEGIN PREPROCESSING;
    19  %}
    20
    21  %%
    22
    23  <PROCESSING>    {
    24
    25          /* Some more codes at this point */
    26
    27          /* ...... */
    28
    29          "#".*$                  {
    30                                          /* allow escaped newline in
Control Section comment */
    31                                          if (yytext[yyleng - 1] == '\\')
    32                                                  yyless(yyleng - 1);
    33                                          else
    34                                                  /* ignore comments */  ;

    35                                  }
    36
    37          \n                      {
    38                                          BEGIN PREPROCESSING;
    39                                          return(NEWLINE);
    40                                  }
    41
    42          \\\n                    /* line continue, ignore */   ;
    43
    44          .       {
    45                          /* anything else is illegal */
    46                              return(ILLEGAL);
    47                  }
    48  }
   49
    50  <PREPROCESSING>  .*$    {
    51                          /* Save the contents of this line for the error
processing */
    52                          strcpy(reslinebuf, yytext);
    53                          yyless(0);
    54                          BEGIN PROCESSING;
    55  }

Thank you very much.

Geoff Liu

--
---------------------------------
IOTA, GDC, Lucent Qingdao(QD)
Tel: (Office)+86-532-8702000x5366

http://gdcsr60.gdc.lucent.com/qdr&d/tm_pe_tools/iota/

 
 
 

A question to Lex problem

Post by Chuck Dillo » Wed, 02 Jul 2003 22:54:16



> All:

> I have a rather large LEX codes which can work properly before.  
> Recently, I update it to record the current processing line by adding
> two starting states.  However some errors will be reported by the compiler.

Try treating the state specified like a qualifier for each individual
RE, not as a scope.

-- ced

--
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.

 
 
 

A question to Lex problem

Post by Geoff Li » Thu, 03 Jul 2003 10:19:38


Chuck:

Thanks for taking care this.

I think you may want me to change it in the following way.  However, I still has
a compile problem.  I would be very appreciate if you can have time to provide
some further help.  I use AT&T lex/yacc.

%a 3000
%o 4000

%{

/* include yacc-produced header file for token types */
#include <gram.h>
#include <strings.h>
#include <ResourceDefs.h>

extern char reslinebuf[500];

%}

%s PREPROCESSING PROCESSING

%{
  BEGIN PREPROCESSING;
%}

%%

 /* Some more codes at this point */

 /* ...... */

<PROCESSING> "#".*$  {
     /* allow escaped newline in Control Section comment */
     if (yytext[yyleng - 1] == '\\')
      yyless(yyleng - 1);
     else
      /* ignore comments */  ;
    }

<PROCESSING> \n   {
     BEGIN PREPROCESSING;
     return(NEWLINE);
    }

<PROCESSING> \\\n   /* line continue, ignore */   ;

<PROCESSING>. {
   /* anything else is illegal */
       return(ILLEGAL);
  }

<PREPROCESSING>  .*$ {
   /* Save the contents of this line for the error processing */
   strcpy(reslinebuf, yytext);
   yyless(0);
   BEGIN PROCESSING;

Quote:}

Thank you very much.

Geoff Liu



> > All:

> > I have a rather large LEX codes which can work properly before.
> > Recently, I update it to record the current processing line by adding
> > two starting states.  However some errors will be reported by the compiler.

> Try treating the state specified like a qualifier for each individual
> RE, not as a scope.

> -- ced

> --
> Chuck Dillon
> Senior Software Engineer
> NimbleGen Systems Inc.

--
---------------------------------
IOTA, GDC, Lucent Qingdao(QD)
Tel: (Office)+86-532-8702000x5366

http://gdcsr60.gdc.lucent.com/qdr&d/tm_pe_tools/iota/
 
 
 

1. Lex maximum - Error when compiling with "lex"

I am trying to compile a long lex file, and am getting different errors.
I am using an SGI, with IRIX 5.3 and lots of memory.  When I reach the
lex limit, I first get:

"lex_test.l":line 423: Error: Too many positions for one state - acompute
3756/8000 nodes(%e), 5716/20000 positions(%p), 2/4000 (%n), 0 transitions,
8/20000 packed char classes(%k), 0/16000 packed transitions(%a), 0/24000 output slots(%o)

I increased the parameters to:

%e 10000
%p 30000
%n 5000
%k 30000
%a 20000
%o 30000

The results when compiling with the previous options are:

"lex_test.l":line 430: Error: Too many positions for one state - acompute
3756/10000 nodes(%e), 5716/30000 positions(%p), 2/5000 (%n), 0 transitions,
8/30000 packed char classes(%k), 0/20000 packed transitions(%a), 0/30000 output slots(%o)

Has anyone had this problem, and solved it?

Ruben Yanas

2. Solaris 2.8 rel 7/01 crashes load CD!

3. lex question

4. CSLIP Problems (random halts in data...)

5. lex question: how to set search specification at run-time

6. KNode: reply by email with munged identity?

7. newbie lex question: parsing Postscript

8. linuxconf and ppp

9. Simple lex v. yacc question

10. lex & nawk : Questions

11. LEX question

12. lex compilation question

13. newbie question - lex