Menu

#20 User defined ParserNode mistake

open
nobody
None
5
2013-01-24
2011-08-27
Anonymous
No

x1
{
#include <stdio.h>
#include <string.h>

typedef struct MyParseNode {
char type;
} MyParseNode;
#undef D_ParseNode_User
#define D_ParseNode_User MyParseNode

#include "d.h"

}

S : 'S' A* 'E' {
printf("[%c/%02X]\n", $1.type, $1.type);
}
;

A : 'A' | 'a' {
$$.type = *$n0.start_loc.s;
}
;

Discussion

  • Nobody/Anonymous

     
  • Nobody/Anonymous

    Excuse me, I push the button early.

    The Input is: SaAE
    The Output is : [ /00]

    In this grammar, I set the UserParserNode, and save one char in type, but the printf can output the right result.
    It seems DParser drop some UserParserNodes when use syntax "A*"

     
  • Nobody/Anonymous

    Another comment, when I use "Stmt*", I can get right node from d_get_child(), when use "( Stmt )*", I will get this bug either.

     
  • Nobody/Anonymous

    Sorry for my question, I review the source code, I think I had solved them now.
    ( Stmt )* get D_ParseNode must use d_get_child(d_get_child(&$n1, 1), 0), and Stmt* use d_get_child only one.

     

Log in to post a comment.

Auth0 Logo