Exemplo n.º 1
0
int main(int argc, char ** argv)
{
  FILE *input;
  Exp parse_tree;
  if (argc > 1) 
  {
    input = fopen(argv[1], "r");
    if (!input)
    {
      fprintf(stderr, "Error opening input file.\n");
      exit(1);
    }
  }
  else input = stdin;
  /* The default entry point is used. For other options see Parser.h */
  parse_tree = pExp(input);
  if (parse_tree)
  {
    printf("\nParse Succesful!\n");
    printf("\n[Abstract Syntax]\n");
    printf("%s\n\n", showExp(parse_tree));
    printf("[Linearized Tree]\n");
    printf("%s\n\n", printExp(parse_tree));
    return 0;
  }
  return 1;
}
int main(int argc, char ** argv)
{
  FILE *input;
  Exp parse_tree;
  if (argc > 1) 
  {
    input = fopen(argv[1], "r");
    if (!input)
    {
      fprintf(stderr, "Error opening input file.\n");
      exit(1);
    }
  }
  else input = stdin;
  /* The default entry point is used. For other options see Parser.h */
  parse_tree = pExp(input);
  if (parse_tree)
  {
    printf("%d\n",interpret(parse_tree));
    return 0;
  }
  return 1;
}