3D-ICE 3.0.0
layout_file_parser.c
1/******************************************************************************
2 * This file is part of 3D-ICE, version 3.1.0 . *
3 * *
4 * 3D-ICE is free software: you can redistribute it and/or modify it under *
5 * the terms of the GNU General Public License as published by the Free *
6 * Software Foundation, either version 3 of the License, or any later *
7 * version. *
8 * *
9 * 3D-ICE is distributed in the hope that it will be useful, but WITHOUT *
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
12 * more details. *
13 * *
14 * You should have received a copy of the GNU General Public License along *
15 * with 3D-ICE. If not, see <http://www.gnu.org/licenses/>. *
16 * *
17 * Copyright (C) 2021 *
18 * Embedded Systems Laboratory - Ecole Polytechnique Federale de Lausanne *
19 * All Rights Reserved. *
20 * *
21 * Authors: Arvind Sridhar Alessandro Vincenzi *
22 * Giseong Bak Martino Ruggiero *
23 * Thomas Brunschwiler Eder Zulian *
24 * Federico Terraneo Darong Huang *
25 * Luis Costero Marina Zapater *
26 * David Atienza *
27 * *
28 * For any comment, suggestion or request about 3D-ICE, please register and *
29 * write to the mailing list (see http://listes.epfl.ch/doc.cgi?liste=3d-ice) *
30 * Any usage of 3D-ICE for research, commercial or other purposes must be *
31 * properly acknowledged in the resulting products or publications. *
32 * *
33 * EPFL-STI-IEL-ESL Mail : 3d-ice@listes.epfl.ch *
34 * Batiment ELG, ELG 130 (SUBSCRIPTION IS NECESSARY) *
35 * Station 11 *
36 * 1015 Lausanne, Switzerland Url : http://esl.epfl.ch/3d-ice *
37 ******************************************************************************/
38
39#include <stdio.h> // For the file type FILE
40
41#include "layout_file_parser.h"
42
43#include "../bison/layout_parser.h"
44#include "../flex/layout_scanner.h"
45
46// From Bison manual:
47// The value returned by yyparse is 0 if parsing was successful (return is
48// due to end-of-input). The value is 1 if parsing failed (return is due to
49// a syntax error).
50
51extern int layout_parser_parse
52
53 (Layer_t *layer, Dimensions_t *dimensions,
54 MaterialList_t *materials, yyscan_t scanner) ;
55
56/******************************************************************************/
57
59(
60 String_t filename,
61 Layer_t *layer,
62 MaterialList_t *materials,
63 Dimensions_t *dimensions
64)
65{
66 FILE *input ;
67 int result ;
68 yyscan_t scanner ;
69
70 input = fopen (filename, "r") ;
71
72 if (input == NULL)
73 {
74 fprintf (stderr, "Unable to open layout file %s\n", filename) ;
75
76 return TDICE_FAILURE ;
77 }
78
79 string_copy (&layer->LayoutFileName, &filename) ; // FIXME memory leak
80
81 layout_parser_lex_init (&scanner) ;
82 layout_parser_set_in (input, scanner) ;
83 //layout_set_debug (1, scanner) ;
84
85 result = layout_parser_parse (layer, dimensions, materials, scanner) ;
86
87 layout_parser_lex_destroy (scanner) ;
88 fclose (input) ;
89
90 if (result == 0)
91
92 return TDICE_SUCCESS ;
93
94 else
95
96 return TDICE_FAILURE ;
97}
98
99/******************************************************************************/
100
Error_t parse_layout_file(String_t filename, Layer_t *layer, MaterialList_t *materials, Dimensions_t *dimensions)
char * String_t
Definition: string_t.h:55
void string_copy(String_t *dst, String_t *src)
Definition: string_t.c:53
Collections of all the structures that are needed for the thermal simulation.
Definition: dimensions.h:311
Structure used to store data about the layers that compose the 2D/3D stack.
Definition: layer.h:72
String_t LayoutFileName
Definition: layer.h:87
Error_t
Definition: types.h:401
@ TDICE_SUCCESS
The function returns with success.
Definition: types.h:402
@ TDICE_FAILURE
The function retuerns with a generic error.
Definition: types.h:403