how to build AST ?!

This is a discussion on how to build AST ?! within the C Programming forums, part of the General Programming Boards category; hi guys ,, i want to program an ast for (Variable Declaration) .. ?!! but how to build it ?! ...

  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 04: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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,450
    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;
    };
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,450
    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?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  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, 10: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

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