C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 07-20-2006, 03:27 PM   #1
Registered User
 
Join Date: Oct 2002
Posts: 69
draw tree graph of yacc parsing

I'm trying to display a tree graph of my lex / yacc / bison parsing, but really have no idea where to start. This is my first time using lex / yacc, and all the generated files (like calc.yacc_tab.c) are filled with so many #defines and #ifndefs that I don't know where to begin.

The parsing is done and working, and now I just need to somehow display the pathing it takes while tracing through the parsing process. Can anybody give me a starting point for this? I assume recursion is used throughout the process (since it's supposed to be a recursive descent parser), but I don't see where the recursion happens, or where the functions are called from. I'll link the rar file of all the code, and hopefully someone can help!

http://www.talz13.com/downloads/other/project.rar

I'd really like to be able to draw something like the samples on this page, but that is all about ruby, and I don't know how the inner workings of the yacc process go.

TIA,
talz13
talz13 is offline   Reply With Quote
Old 07-22-2006, 10:56 PM   #2
Registered User
 
Join Date: Oct 2002
Posts: 69
Does anybody know how to turn out a kind of graph like this from a yacc parsing? Not from the base grammar, but from the path that the parsing follows?
Code:
          12           
     .----' `----.     
    20          15     
  .-' `-.     .-' `-.  
 29    23    17    22  
/  \  /  \  /          
35 40 26 51 19
talz13 is offline   Reply With Quote
Old 07-23-2006, 01:33 AM   #3
and the hat of vanishing
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,214
> I assume recursion is used throughout the process (since it's supposed to be a recursive descent parser)
So pick a point in your parse code which you think is recursively called, and put a breakpoint there in your debugger.
Then see if it is called recursively.

Unless you call back into the yacc parse function from your yacc rules, then the answer is probably no recursion is used.

My guess is you need to track the recursion via your yacc input files. Say for example when you see an opening brace, you increment a count, and when you see a closing brace, you decrement the count.

I was also ignoring you because I've no way to decode your compression format.
If you're going to just dump your entire project for someone else to sort out (not recommended), at least pick a format everyone should be able to decode.
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Up to 8Mb PlusNet broadband from only £5.99 a month!
Salem is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Interpreter.c moussa C Programming 4 05-28-2008 05:59 PM
Binary Search Trees Part III Prelude A Brief History of Cprogramming.com 16 10-02-2004 03:00 PM
Request for comments Prelude A Brief History of Cprogramming.com 15 01-02-2004 10:33 AM
Binary Tree Search C++Newbie C++ Programming 5 03-22-2002 12:38 PM
BST/Red and Black Tree ghettoman C++ Programming 0 10-24-2001 10:45 PM


All times are GMT -6. The time now is 08:46 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22