Пример #1
0
/**
 * CTRParserProgram
 *
 * Generates the nodes to represent the entire program
 * as an Abstract Syntax Tree (AST).
 */
ctr_tnode *
ctr_cparse_program ()
{
  ctr_tnode *program = ctr_cparse_create_node (CTR_AST_PROGRAM);
  ctr_tlistitem *pli;
  int first = 1;
  while (1)
    {
      ctr_tlistitem *li = ctr_cparse_statement ();
      if (first)
	{
	  first = 0;
	  program->nodes = li;
	}
      else
	{
	  pli->next = li;
	}
      if (li->node == NULL || li->node->type == CTR_AST_NODE_ENDOFPROGRAM)
	{
	  li->node = ctr_cparse_fin ();
	  break;
	}
      pli = li;
    }
  return program;
}
Пример #2
0
/**
 * CTRParserProgram
 *
 * Generates the nodes to represent the entire program
 * as an Abstract Syntax Tree (AST).
 */
ctr_tnode* ctr_cparse_program() {
	ctr_tnode* program = CTR_PARSER_CREATE_PROGRAM_NODE();
	ctr_tlistitem* pli;
	int first = 1;
	while(1) {
		ctr_tlistitem* li = ctr_cparse_statement();
		if (first) {
			first = 0;
			program->nodes = li;
		} else {
			pli->next = li;
		}
		if (li->node->type == CTR_AST_NODE_ENDOFPROGRAM) break;
		pli = li;
	}
	return program;
}