Changeset 03b2b2c in mainline for uspace/app/bithenge/test.c


Ignore:
Timestamp:
2012-06-24T17:32:30Z (12 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0d1a8fd
Parents:
da0fef6
Message:

Bithenge: add working but useless script parser.

File:
1 edited

Legend:

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

    rda0fef6 r03b2b2c  
    4242#include "source.h"
    4343#include "print.h"
     44#include "script.h"
     45#include "transform.h"
    4446#include "tree.h"
    4547
    4648int main(int argc, char *argv[])
    4749{
    48         if (argc < 2) {
     50        int rc;
     51        if (argc < 3) {
    4952                // {True: {}, -1351: "\"false\"", "true": False, 0: b"..."}
    5053                const char data[] = "'Twas brillig, and the slithy toves";
     
    6669                bithenge_node_destroy(node);
    6770        } else {
    68                 bithenge_node_t *node;
    69                 int rc = bithenge_node_from_source(&node, argv[1]);
     71                bithenge_transform_t *transform;
     72                rc = bithenge_parse_script(argv[1], &transform);
     73                if (rc != EOK) {
     74                        printf("Error parsing script: %s\n", str_error(rc));
     75                        return 1;
     76                }
     77
     78                bithenge_node_t *node, *node2;
     79                int rc = bithenge_node_from_source(&node, argv[2]);
    7080                if (rc != EOK) {
    7181                        printf("Error creating node from source: %s\n", str_error(rc));
    7282                        return 1;
    7383                }
    74                 rc = bithenge_print_node(BITHENGE_PRINT_PYTHON, node);
     84
     85                rc = bithenge_transform_apply(transform, node, &node2);
     86                if (rc != EOK) {
     87                        printf("Error applying transform: %s\n", str_error(rc));
     88                        return 1;
     89                }
     90
     91                bithenge_node_destroy(node);
     92                bithenge_transform_dec_ref(transform);
     93
     94                rc = bithenge_print_node(BITHENGE_PRINT_PYTHON, node2);
    7595                if (rc != EOK) {
    7696                        printf("Error printing node: %s\n", str_error(rc));
     
    7898                }
    7999                printf("\n");
    80                 bithenge_node_destroy(node);
    81100        }
    82101
Note: See TracChangeset for help on using the changeset viewer.