diff options
author | Florian Müllner <fmuellner@gnome.org> | 2013-11-29 01:12:40 +0100 |
---|---|---|
committer | Florian Müllner <fmuellner@gnome.org> | 2013-11-29 18:45:31 +0000 |
commit | e4efb97c8a20f5dcbf6cd2736bd5bcd92e1d814d (patch) | |
tree | baa632338c6712a1582fe0711d4c46e4f2a13637 /giscanner/scannerparser.y | |
parent | 9112ec1e845015a17bba49fb1dd385a2c6e9efd7 (diff) | |
download | gobject-introspection-e4efb97c8a20f5dcbf6cd2736bd5bcd92e1d814d.tar.gz |
scanner: Support boolean constants
Aliasing TRUE or FALSE is not very common, but done occasionally
for extra clarity. Namely G_SOURCE_REMOVE / G_SOURCE_CONTINUE are
self-explanatory, unlike the "raw" booleans.
https://bugzilla.gnome.org/show_bug.cgi?id=719566
Diffstat (limited to 'giscanner/scannerparser.y')
-rw-r--r-- | giscanner/scannerparser.y | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/giscanner/scannerparser.y b/giscanner/scannerparser.y index faf73410..6cbf36ad 100644 --- a/giscanner/scannerparser.y +++ b/giscanner/scannerparser.y @@ -226,7 +226,7 @@ toggle_conditional (GISourceScanner *scanner) %token <str> IDENTIFIER "identifier" %token <str> TYPEDEF_NAME "typedef-name" -%token INTEGER FLOATING CHARACTER STRING +%token INTEGER FLOATING BOOLEAN CHARACTER STRING %token INTL_CONST INTUL_CONST %token ELLIPSIS ADDEQ SUBEQ MULEQ DIVEQ MODEQ XOREQ ANDEQ OREQ SL SR @@ -326,6 +326,12 @@ primary_expression $$->const_int = value; $$->const_int_is_unsigned = (rest && (rest[0] == 'U')); } + | BOOLEAN + { + $$ = gi_source_symbol_new (CSYMBOL_TYPE_CONST, scanner->current_file, lineno); + $$->const_boolean_set = TRUE; + $$->const_boolean = g_ascii_strcasecmp (yytext, "true") == 0 ? TRUE : FALSE; + } | CHARACTER { $$ = gi_source_symbol_new (CSYMBOL_TYPE_CONST, scanner->current_file, lineno); @@ -1475,7 +1481,7 @@ function_macro_define object_macro_define : object_macro constant_expression { - if ($2->const_int_set || $2->const_double_set || $2->const_string != NULL) { + if ($2->const_int_set || $2->const_boolean_set || $2->const_double_set || $2->const_string != NULL) { $2->ident = $1; gi_source_scanner_add_symbol (scanner, $2); gi_source_symbol_unref ($2); |