rbbarbosa / Petit

Petit programming language and compiler
BSD 3-Clause "New" or "Revised" License
8 stars 1 forks source link

new union member struct node_list * #5

Open rbbarbosa opened 10 months ago

rbbarbosa commented 10 months ago

In tutorial IV, should we include an example where node lists are created and placed on the value stack? Example:

%union{ char lexeme; struct node node; struct node_list *node_list; }

rbbarbosa commented 10 months ago

Otherwise, generate an Unknown parent node, then: foreach child addchild(program, child) or modify the category from Unknown to Program

rbbarbosa commented 10 months ago

A good way to address this is to update tutorial IV according to:

program: program function | function function: IDENTIFIER '(' parameters ')' '=' expression

This exposes the problem of creating lists of nodes. Initially, the "function" production creates a Program node directly, because it is the top-level start production.