help-bison
[Top][All Lists]
Advanced

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

Re: Multiple Parsers in the Same Program


From: Patrick Bellasi
Subject: Re: Multiple Parsers in the Same Program
Date: Sat, 4 Sep 2004 01:02:26 +0000
User-agent: KMail/1.6.2

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 03 September 2004 22:44, you wrote:
> > But when I do that... I'm able to compile but I just get a SEGMENTATION
>
> FAULT
>
> > when I run the parser.
> >
> > Anyone know what can be the problem?
>
> Probably an uninitialized pointer.  I suggest running your program in a
> debugger, such as the GNU debugger GDB.  Then you'll be able to pinpoint
> the exact spot.  Use `bt' to get a "backtrace", which will show you a
> listing of the current stack frames.  
Always done... But the info I'm getting are not useful for me.
The crash is inside yylex()...
... but the code seem to go in an infinite loop: bt show a great number of 
nested call of the same routine!

****************************************************************************
This is mi code
****************************************************************************
%{
#include <stdio.h>

int armlex () {
         return yylex();
}

int yyerror (char const *s) {
        fprintf (stderr, "%s\n", s);
        return 1;
}

%}

%token T_BEGIN
%token T_ADD
%token T_SUB
%token T_MOV
%token T_BX
%token T_END

%name-prefix="arm"

%%

prog: T_BEGIN stmts T_END
;
        
stmts:  stmt
        | stmts stmt
;
        
stmt: T_ADD {printf ("ARM[add]\n");}
        | T_SUB {printf ("ARM[sub]\n");}
        | T_MOV {printf ("ARM[mov]\n");}
        | T_BX  {printf ("Switching to THUMB mode...\n");}
;

%%

int main (int argc, char *argv[]) {

        extern FILE *yyin;
        ++argv; --argc;
        
        if (argc>0)
                yyin = fopen(argv[0], "r");
        else
                yyin=stdin;

        return armparse();

}

****************************************************************************

armlex is a wrapper for the parser to call the yylex of the scanner...
... but that code enter in an infinite loop!

A can't see the mistake!

> Emacs has a nice GDB-interface. 
I know thanks

> Laurence
Patrick
- -- 



<---------------------------------------------------------------------------------------------------------->
                                                  DERKLING
                                    LRU 338214 (http://counter.li.org)

  #include <best/regards.h>


<---------------------------------------------------------------------------------------------------------->
   Patrick Bellasi <derkling_at_users.sourceforge.net>
   Student (Politecnico di Milano)
       Comp.Sci & Soft.Eng
   
   Contacts:
    - Room +39 02 23952621
    - Home +39 0342 621043 (week-ends)
    - ICQ   344672588
    - MSN   address@hidden
   
   Privacy:
    - PGP   0x72ABC1EE (www.keyserver.net)
      pub  1024D/72ABC1EE 2003-12-04 Patrick Bellasi (PGP key for poste.it) 
<address@hidden>
      Primary key fingerprint: 3958 7B5F 36EC D1F8 C752  9589 C3B7 FD49 72AB 
C1EE
<---------------------------------------------------------------------------------------------------------->
   
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBORQteGk3pQ7APA8RAiUKAJsG++QAzAe3wv9dIaPXCkzgtxwddACfQM7N
BhWE/tICuwWbAl8ExsB5P2U=
=WG30
-----END PGP SIGNATURE-----




reply via email to

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