* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <config.h>
#include <stdio.h>
#include <assert.h>
#include <stdbool.h>
#include "typemap.h"
#include "parse.h"
#include "scan.h"
+#include "i18n.h"
/*
* Determine if a declarator declares an identifier (other than a function
struct cdecl *decl;
int rc;
- rc = yylex_init(&scanner);
+ cdecl__init_i18n();
+
+ rc = cdecl__yylex_init(&scanner);
if (rc != 0)
return NULL;
- state = yy_scan_string(declstr, scanner);
- rc = yyparse(scanner, &decl);
- yy_delete_buffer(state, scanner);
- yylex_destroy(scanner);
+ state = cdecl__yy_scan_string(declstr, scanner);
+ rc = cdecl__yyparse(scanner, &decl);
+ cdecl__yy_delete_buffer(state, scanner);
+ cdecl__yylex_destroy(scanner);
if (rc != 0)
return NULL;
cdecl_free(decl);
return NULL;
}
+
+struct cdecl *cdecl_parse_english(const char *english)
+{
+ YY_BUFFER_STATE state;
+ yyscan_t scanner;
+ struct cdecl *decl;
+ int rc;
+
+ cdecl__init_i18n();
+
+ rc = cdecl__yylex_init_extra(true, &scanner);
+ if (rc != 0)
+ return NULL;
+
+ state = cdecl__yy_scan_string(english, scanner);
+ rc = cdecl__yyparse(scanner, &decl);
+ cdecl__yy_delete_buffer(state, scanner);
+ cdecl__yylex_destroy(scanner);
+
+ if (rc != 0)
+ return NULL;
+
+ for (struct cdecl *i = decl; i; i = i->next) {
+ if (!forall_declarators(i, check_parameters))
+ goto err;
+ if (!forall_declarators(i, check_rettypes))
+ goto err;
+ if (!forall_declarators(i, check_arrays))
+ goto err;
+
+ if (!valid_declspecs(i, true))
+ goto err;
+ }
+
+ return decl;
+err:
+ cdecl_free(decl);
+ return NULL;
+}