user2614036
user2614036

Reputation: 11

Bison generated Parser exits before reading through entire file

I have a BISON generated Parser for a subset of Verilog. I see that the parser jumps to the end of file before reading the entire file. I'm pasting a snippet of the Log from the parser and the file I am trying to parse.

   Stack now 0 1 6 10 13 29 13 29 13 29 13 29 13 29 13 29 13 29 13 29 13
   Entering state 29
   Reading a token: --accepting rule at line 85(";")
   Next token is token SEMICOLON (design.v:1.207: )
   Shifting token SEMICOLON (design.v:1.207: )
   Entering state 13
   Reading a token: --accepting rule at line 100("0")
   Next token is token NUMBER (design.v:1.208: )
   Reducing stack by rule 12 (line 174):**
      $1 = token SEMICOLON (design.v:1.207: )
   -> $$ = nterm module_item_list (design.v:1.207: )
   Stack now 0 1 6 10 13 29 13 29 13 29 13 29 13 29 13 29 13 29 13 29 13 29
   Entering state 44
   Reducing stack by rule 11 (line 172):
      $1 = token SEMICOLON (design.v:1.185: )

the piece of code that is being parsed is below

wire [3:0] z;
wire w1, w2, w3, w4, w5, w6, w7;
not (z[0], a[0]);  
xnor (z[1], a[0], a[1]);

It fails at the end of "not();"

Any inputs appreciated.. Thanks.

Upvotes: 0

Views: 115

Answers (1)

user2614036
user2614036

Reputation: 11

Actually it looks like the buffer being read by the Lexer is becoming null. I output the buffer for every token read .. and this is what it looks like..

    nor (z[3], w2, w3);
    nor (w4, sel, z[3]);
    nor (w5, sel, z[2]);
    and (w6, sel, z[1]);
    and (w7, sel, z[0]);
    or (out[1], w4, w6);
    or (out[0], w5, w7);
    endmodule

And 
  *yy_cp]
Let's check 
    yy_cp );  
    xnor (z[1], a[0], a[1]);
    or (w1, a[0], a[1]);
    xnor (z[2], a[2], w1);
    and (w2, a[2], a[1]);
    and (w3, a[2], a[0]);
    nor (z[3], w2, w3);
    nor (w4, sel, z[3]);
    nor (w5, sel, z[2]);
    and (w6, sel, z[1]);
    and (w7, sel, z[0]);
    or (out[1], w4, w6);
    or (out[0], w5, w7);
endmodule

And *yy_cp)
 Let's check yy_cp ;0_0And *yy_cp;

So here yy_cp is the buffer being read and *yy_cp is the actual character for every pass. If you see at one instant yy_cp has the entire code .. the next moment it is ) 0.. I wonder if it is a problem with the grammar or what?

No this is not a homework problem.

Thanks for all your suggestions..

Upvotes: 1

Related Questions