Thread: boost::spirit, abstract syntax tree question

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    244

    boost::spirit, abstract syntax tree question

    is there some trick to have an epsilon_p as a root_node?

    (using ast_parse)

    so id like this grammar to work:
    Code:
    expression_0
    = expression_1 >> *(root_node_d[epsilon_p] >> expression_2) //!!! doesnt work
    ;
    
    expression_1
    = expression_2 >> *(
        (root_node_d[ch_p('+')] >> expression_2) // works perfectly
        (root_node_d[ch_p('-')] >> expression_2)
    );
    
    expression_2
    = identifier
    | value
    | inner_node_d['(' >> expression_0 >> ')']
    ;
    
    
    expression
    = expression_0
    ;


    unfortunately, there is no root node created for the rule expression_0.
    so instead of building the abstract syntax tree for
    "a b c d"
    as
    Code:
            []
           /  \d
          []
         /  \
       []    c
      /  \
    a   b
    the tree is built as:
    Code:
           []
    /    |     |     \
    a   b    c      d
    signature under construction

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    630
    Did you post on boost spirit newsgroup?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. changing a tree into a list question..
    By transgalactic2 in forum C Programming
    Replies: 20
    Last Post: 11-11-2008, 08:40 AM
  2. Includes making me insane >.<
    By IceDane in forum C Programming
    Replies: 14
    Last Post: 04-14-2008, 10:24 AM
  3. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  4. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM
  5. Help: One Question for each: Linked List and Tree
    By Yin in forum C++ Programming
    Replies: 1
    Last Post: 04-14-2002, 12:57 AM