Thread: how to build AST ?!

  1. #1
    C 1337 Meshal's Avatar
    Join Date
    Nov 2006
    Posts
    70

    how to build AST ?!

    hi guys ,,

    i want to program an ast for (Variable Declaration) .. ?!!

    but how to build it ?!

    i write this struct and i get many errors !!

    Code:
    #define max 20
    typedef struct
    {
    
    struct child[max];
    
    char *info;
    }ast;
    Code:
    ast tree;
    is this work fine ??

    for example can i parse this :

    int a , b , c , d ;
    Last edited by Meshal; 12-13-2006 at 05:44 AM.

  2. #2
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Your problem is addressed in Microsoft's knowledge base article Q555375. I hope that helps.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  3. #3
    C 1337 Meshal's Avatar
    Join Date
    Nov 2006
    Posts
    70
    sorry for my question i know it`s ambigous !

    the problem is

    this work find

    Code:
    tree -> child[0] -> str
    but this not and why ?!!

    Code:
    tree -> child[0] -> child[0] - > str

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Do you want to create the n-child tree?
    Code:
    typedef struct node_tag node;
    #define MAX_NODES 20
    
    struct node_tag
    {
       node* childs[MAX_NODES]
       char*  info;
    };
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  5. #5
    C 1337 Meshal's Avatar
    Join Date
    Nov 2006
    Posts
    70
    yes thanks it works fine now but i face another problem !!!!

    that when i want to insert in the node that left to the left node i face a problem

    this work fine to me

    Code:
    tree -> child[0] -> str
    but if i want to insert in the node that left to the child[0] a problem occur !! for example

    Code:
    tree -> child[0] - > child[0] -> str

  6. #6
    C 1337 Meshal's Avatar
    Join Date
    Nov 2006
    Posts
    70
    how can i insert to the left to the child[0] ??

  7. #7
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    you should post some code showing your affort in processing that type of the tree.
    Actually, are you sure you need something more complex than a regular binary tree?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  8. #8
    C 1337 Meshal's Avatar
    Join Date
    Nov 2006
    Posts
    70
    Ok , i`ll post my code after i come back to my home ,
    thanks for trying to helping me i appreaciate that !!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. PlaySound
    By cangel in forum C++ Programming
    Replies: 16
    Last Post: 10-08-2009, 05:29 PM
  2. How to build, run Boland C++ 6 source file via VS2005?
    By userpingz in forum C++ Programming
    Replies: 2
    Last Post: 05-21-2009, 03:25 AM
  3. Replies: 0
    Last Post: 10-07-2008, 12:09 PM
  4. any SDK for build binaries on ARM5 platform?
    By George2 in forum Tech Board
    Replies: 0
    Last Post: 12-14-2006, 11:23 PM
  5. Boom, Headoshot!!
    By mrafcho001 in forum A Brief History of Cprogramming.com
    Replies: 50
    Last Post: 07-21-2005, 08:28 PM