i am developing parser using bison…in my grammar i am getting this error
Here is a code
extern NodePtr CreateNode(NodeType, ...);
extern NodePtr ReplaceNode(NodeType, NodePtr);
extern NodePtr MergeSubTrees(NodeType, ...);
...................
NodePtr rootNodePtr = NULL; /* pointer to the root of the parse tree */
NodePtr nodePtr = NULL; /* pointer to an error node */
...........................
NodePtr mainMethodDecNodePtr = NULL;
................
/* YYSTYPE */
%union {
NodePtr nodePtr;
}
i am getting this error whenever i use like $$.nodePtr or $1.nodePtr … I am getting Parser.y:1302.32-33: $1 of `Expressi
on’ has no declared type
That means that the first item (terminal or non-terminal) on the RHS of the
Expressionrule on line 1302 of parser.y has no type declared for it. If its a terminal, you need to add%tokendeclarations for it, and if its a non-terminal, you need to add a%typedeclaration for it. When you do that (probably either$type <nodePtr>or%token <nodePtr>), you will access the value as just$1(no.nodePtrsuffix)edit
sounds like line 1302 should be
$$ = $1;. The%type <nodePtr> XXXshould go in the first section, where XXX is the non-terminal for this rule. When you use%unionin a .y file, the tags declared in the union should ONLY be used in%typeand%tokendeclarations — they should not appear in any action in the .y file