diff options
Diffstat (limited to 'plugins/kaitai/grammar.y')
-rw-r--r-- | plugins/kaitai/grammar.y | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/plugins/kaitai/grammar.y b/plugins/kaitai/grammar.y index 2f2b820..9745dc8 100644 --- a/plugins/kaitai/grammar.y +++ b/plugins/kaitai/grammar.y @@ -31,9 +31,10 @@ typedef void *yyscan_t; #include "expression.h" #include "record.h" +#include "records/bits.h" +#include "records/delayed.h" #include "records/item.h" #include "records/list.h" -#include "records/value.h" } @@ -580,7 +581,9 @@ YY_DECL; %token ROOT "_root" %token PARENT "_parent" %token LAST "_" +%token IO "_io" %token METH_IO "._io" +%token IO_EOF ".eof" %token TRUE_CONST "true" %token FALSE_CONST "false" @@ -622,6 +625,7 @@ YY_DECL; %type <value> field %type <value> enumeration %type <value> stream +%type <value> stream_meths @@ -714,6 +718,7 @@ YY_DECL; | field { $$ = $1; } | enumeration { $$ = $1; } | stream { $$ = $1; } + | stream_meths { $$ = $1; } | arithmetic_expr { $$ = $1; } | relational_expr { $$ = $1; } | logical_expr { $$ = $1; } @@ -1487,7 +1492,35 @@ YY_DECL; } - stream : any_expr "._io" + stream : "_io" + { + GBinContent *__content; + mrange_t __range; + vmpa2t __next; + + if (locals->last == NULL) + { + __content = g_match_record_get_content(locals->root); + + g_binary_content_compute_start_pos(__content, &__next); + + } + else + { + __content = g_match_record_get_content(locals->last); + + g_match_record_get_range(locals->last, &__range); + compute_mrange_end_addr(&__range, &__next); + + } + + $$.stream = g_kaitai_stream_new(__content, &__next); + $$.type = GVT_STREAM; + + g_object_unref(G_OBJECT(__content)); + + } + | any_expr "._io" { GBinContent *__content; mrange_t __range; @@ -1508,6 +1541,15 @@ YY_DECL; } ; + stream_meths : stream ".eof" + { + $$.status = g_kaitai_stream_has_reached_eof($1.stream);; + $$.type = GVT_BOOLEAN; + + EXIT_RESOLVED_VALUE($1); + + } + ; %% @@ -1656,8 +1698,11 @@ static bool reduce_resolved_kaitai_expression(resolved_value_t *in_out) while (result && in_out->type == GVT_RECORD) { - if (G_IS_RECORD_VALUE(in_out->record)) - result = g_record_value_compute_value(G_RECORD_VALUE(in_out->record), &deeper); + if (G_IS_RECORD_BIT_FIELD(in_out->record)) + result = g_record_bit_field_get_value(G_RECORD_BIT_FIELD(in_out->record), &deeper); + + else if (G_IS_RECORD_DELAYED(in_out->record)) + result = g_record_delayed_compute_value(G_RECORD_DELAYED(in_out->record), &deeper); else if (G_IS_RECORD_ITEM(in_out->record)) result = g_record_item_get_value(G_RECORD_ITEM(in_out->record), &deeper); |