Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2002-05

Calling yyparse() several times fails.

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ralf Paaschen

Hi.

I wrote the following program to show the problem.

It uses very simple plex and pyacc modules that only try to find out if a line of the input contais the word "hallo". The main program does the following:
* open a file
* parse it
* print "----successful parse!----"
* reopen it
* parse it again
...

The first time parsing the file works well.
The second time works almost, but have a look yourself:

LEX: Found HALLO
YACC: Line containing Hallo found.
LEX: Found some text.
YACC: Line with some other text found.
LEX: Found HALLO
YACC: Line containing Hallo found.
---------successful parse!---------------
Reset.
LEX: Found HALLO
YACC: Line containing Hallo found.
LEX: Found some text.
YACC: Line with some other text found.
LEX: Found HALLO
YACC: Line containing Hallo found.
Runtime error 103 at 0x08053A3A
0x08053A3A
0x080480B0
0x00000000

The runtime error is 103 but the return code of the program was 0147 (shown by gdb).

I have tested version 1.0.4 and 1.0.6 of fpc under Linux on i386. Both with the same result.

I can't say if is a fpc problem or a problem of the state machine generated by pyacc.

I have added the following files to this mail:
* Makefile - for easier testing :-)
* yaccerror.pp - the main program
* yaccerror_lex.l - the lex file
* yaccerror_yacc.y - the yacc file
* hallofile.txt - the textfile used above

What I have done so far:
- looked through the documentation/examples of tply41a.
- written a program that opens a textfile and displays all lines several times to see if "Reset" works. It worked.
- some sessions with DDD (frontend for gdb)
- tested fpc 1.0.4 ad 1.0.6

Thank you,

Ralf Paaschen

Reply by email

Jonas Maebe
to Ralf Paaschen
Ralf Paaschen wrote 5 lines
YACC: Line containing Hallo found. Runtime error 103 at 0x08053A3A 0x08053A3A 0x080480B0 0x00000000

Compile everything with -gl, then you'll get line numbers next to the reutrn addresses, which should help you pinpoint the problem.

Jonas

Reply by email

Ralf Paaschen
to Jonas Maebe
Jonas Maebe wrote 10 lines
On Fri, 3 May 2002, Ralf Paaschen wrote: > YACC: Line containing Hallo found. > Runtime error 103 at 0x08053A3A > 0x08053A3A > 0x080480B0 > 0x00000000 Compile everything with -gl, then you'll get line numbers next to the reutrn addresses, which should help you pinpoint the problem.

I just tried this but the line number I get is the one where yyparse() is called. But thanks to the output on screen and DDD/gdb I know that most of the yyparse procedure gets executed.

But I turned on the pyacc debug code. Then every internal state is printed. And there is a difference towards the end of execution of the both yyparse calls:

YACC: Line containing Hallo found.
state 2, char -1
reduce 2
state 1, char 0
---------successful parse!---------------

YACC: Line containing Hallo found.
state 2, char -1
reduce 2
Runtime error 103 at 0x0805426C

The "state 1, char 0" is never reached in the second case.

But at the moment I don't know how this can help me...

Greetings,
Ralf

Reply by email