Changeset d8bd2ec in mainline


Ignore:
Timestamp:
2012-08-08T04:13:53Z (12 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0b60d2d, 20e95be
Parents:
a66ea217
Message:

Bithenge: add syntax for inputless transforms

Location:
uspace
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bithenge/script.c

    ra66ea217 rd8bd2ec  
    119119        /** The number of parameters. */
    120120        int num_params;
     121        /** @a parse_expression sets this when TOKEN_IN is used. */
     122        bool in_node_used;
    121123} state_t;
    122124
     
    440442        } else if (state->token == TOKEN_IN) {
    441443                next_token(state);
     444                state->in_node_used = true;
    442445                bithenge_expression_t *expr;
    443446                rc = bithenge_in_node_expression(&expr);
     
    882885        if (state->token == '(') {
    883886                next_token(state);
     887                state->in_node_used = false;
    884888                bithenge_expression_t *expr = parse_expression(state);
    885889                expect(state, ')');
     
    890894
    891895                bithenge_transform_t *xform;
    892                 int rc = bithenge_expression_transform(&xform, expr);
     896                int rc;
     897                if (state->in_node_used)
     898                        rc = bithenge_expression_transform(&xform, expr);
     899                else
     900                        rc = bithenge_inputless_transform(&xform, expr);
    893901                if (rc != EOK) {
    894902                        error_errno(state, rc);
  • uspace/dist/src/bithenge/test.bh

    ra66ea217 rd8bd2ec  
    1 transform length = struct {
    2         .len <- uint8;
    3 };
    4 
    51transform pascal_string = struct {
    6         <- length;
     2        <- struct { # An inner struct for testing purposes
     3                .len <- uint8;
     4        };
    75        .string <- ascii <- known_length(.len);
    86};
     
    1614
    1715transform item(little_endian, len) = struct {
    18         .type <- (3*in+1) <- u32(little_endian);
     16        .type <- (3 * in + 1) <- u32(little_endian);
    1917        .name <- pascal_string;
    2018        switch (.type) {
     
    3230
    3331transform main() = struct {
    34         .first_item <- item(true, 3);
    35         .second_item <- item(false, 4);
     32        .first_len <- (3);
     33        .second_len <- (6 - 2);
     34        .first_item <- item(true, .first_len);
     35        .second_item <- item(false, .second_len);
    3636};
Note: See TracChangeset for help on using the changeset viewer.