trans.c 577 Bytes
Newer Older
Christian Müller's avatar
aalta  
Christian Müller committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
/* 
 * 定义AST转化函数
 * File:   trans.c
 * Author: yaoyinbo
 *
 * Created on October 20, 2013, 3:32 PM
 */
#include "trans.h"

#include <stdlib.h>

ltl_formula *
getAST (const char *input)
{
  ltl_formula *formula;
  yyscan_t scanner;
  YY_BUFFER_STATE state;

  if (yylex_init (&scanner))
    {
      // couldn't initialize
      return NULL;
    }

  state = yy_scan_string (input, scanner);
  if (yyparse (&formula, scanner))
    {
      // error parsing
      return NULL;
    }

  yy_delete_buffer (state, scanner);
  yylex_destroy (scanner);

  return formula;
}