Compare commits

...

2 Commits

Author SHA1 Message Date
Øyvind Skaaden b06406e48a Added yylex_destroy 2022-02-27 19:15:26 +01:00
Øyvind Skaaden 6b3065fe11 removed comment 2022-02-27 19:15:12 +01:00
2 changed files with 1 additions and 31 deletions

View File

@ -23,6 +23,7 @@ int yyerror ( const char *error );
/* These are defined in the parser generated by bison */
extern int yylineno;
extern int yylex ( void );
extern int yylex_destroy( void );
extern char yytext[];
/* Global state */

View File

@ -291,37 +291,6 @@ flatten(node_t **simplified, node_t *root)
static void
simplify_tree ( node_t **simplified, node_t *root )
{
/* TODO: Simplify the syntax tree structure
1. prune children: Delete nodes which can only ever have 1 child and no
meaningful data, and associate their child directly with their parent.
2. resolve constant expressions: Compute the value of subtrees representing
arithmetic with constants, and replace them with their value.
3. flatten: Delete internal nodes of list structures, leaving only a parent
node with a list type, and all list items as its children. Print list items
can be associated directly with the print statement.
VARIABLE_LIST VARIABLE_LIST
VARIABLE_LIST IDENTIFIER_DATA(i)
VARIABLE_LIST IDENTIFIER_DATA(j)
VARIABLE_LIST IDENTIFIER_DATA(k)
VARIABLE_LIST IDENTIFIER_DATA(l)
IDENTIFIER_DATA(i) becomes IDENTIFIER_DATA(m)
IDENTIFIER_DATA(j)
IDENTIFIER_DATA(k)
IDENTIFIER_DATA(l)
IDENTIFIER_DATA(m)
Tip: implement these three steps as separate functions to complete one task
at the time. e.g.:
prune_children(root);
redolve_constant_expressions(root);
flatten(root);
simplified = &root->children[0];
node_finalize(root);
*/
if (!root)
return;