summaryrefslogtreecommitdiff
path: root/src/lib/eolian/eo_parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/eolian/eo_parser.c')
-rw-r--r--src/lib/eolian/eo_parser.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 524b31a383..74c76d3a7d 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -1,4 +1,5 @@
1#include <assert.h> 1#include <assert.h>
2#include <limits.h>
2 3
3#ifdef HAVE_CONFIG_H 4#ifdef HAVE_CONFIG_H
4# include "config.h" 5# include "config.h"
@@ -2278,10 +2279,37 @@ found_class:
2278static void 2279static void
2279parse_chunk(Eo_Lexer *ls, Eina_Bool eot) 2280parse_chunk(Eo_Lexer *ls, Eina_Bool eot)
2280{ 2281{
2282 Eina_Bool parsing_header = EINA_TRUE;
2283 Eina_Bool has_version = EINA_FALSE;
2281 while (ls->t.token >= 0) 2284 while (ls->t.token >= 0)
2282 /* set eot to EINA_TRUE so that we only allow parsing of one class */ 2285 switch (ls->t.kw)
2283 if (parse_unit(ls, eot)) 2286 {
2284 eot = EINA_TRUE; 2287 case KW_hash_version:
2288 {
2289 CASE_LOCK(ls, version, "#version specifier");
2290 if (!parsing_header)
2291 eo_lexer_syntax_error(ls, "header keyword outside of unit header");
2292 eo_lexer_get(ls);
2293
2294 check(ls, TOK_NUMBER);
2295 if (ls->t.kw != NUM_INT)
2296 eo_lexer_syntax_error(ls, "invalid #version value");
2297 if (ls->t.value.u > USHRT_MAX)
2298 eo_lexer_syntax_error(ls, "#version too high");
2299 else if (ls->t.value.u < 0)
2300 eo_lexer_syntax_error(ls, "#version too low");
2301
2302 ls->unit->version = (unsigned short)(ls->t.value.u);
2303 eo_lexer_get(ls);
2304 break;
2305 }
2306 default:
2307 parsing_header = EINA_FALSE;
2308 /* set eot to EINA_TRUE so that we only allow parsing of one class */
2309 if (parse_unit(ls, eot))
2310 eot = EINA_TRUE;
2311 break;
2312 }
2285} 2313}
2286 2314
2287Eolian_Unit * 2315Eolian_Unit *