Source

arana-main / arana / lexnparse.rl

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
/*
 * lexnparse.rl
 *
 * (c) Copyright 2009 by Georg Brandl.
 *
 * Heavily borrowed from the Potion lexer, which is
 * (c) Copyright 2008 why the lucky stiff.
 */

#include "arana.h"

#define TOKEN(id)     TOKEN2(id, AR_NONE)
#define TOKEN2(id, v)                                                   \
    ps->tokstart = ts; ps->tokend = te; ps->lasttok = AR_TOK_##id;      \
    /* printf(#id " %s\n", AR_IS_STRING(v) ? AR_AS_CHARP(v) : ""); */   \
    tok = AR_ALLOCT(ArToken);                                           \
    if (!tok) AR_RAISE_OOM();                                           \
    tok->value = v;                                                     \
    tok->lineno = ps->lineno;                                           \
    tok->col = ps->tokstart - ps->lineoffset;                           \
    ArParse(pParser, AR_TOK_##id, tok, ps, 0)
#define ISLAST(id)    ps->lasttok == AR_TOK_##id

#define STATESTACKSIZE  100
#define INDENTSTACKSIZE 1


%%{
    machine utf8;

    comma       = ",";
    newline     = "\r"? "\n" %{ ps->lineno++; ps->lineoffset = p; };
    whitespace  = " " | "\f" | "\t" | "\v";
    utfw        = alnum | "_" | "$" | "@" | "{" | "}" |
                  (0xc4 0xa8..0xbf) | (0xc5..0xdf 0x80..0xbf) |
                  (0xe0..0xef 0x80..0xbf 0x80..0xbf) |
                  (0xf0..0xf4 0x80..0xbf 0x80..0xbf 0x80..0xbf);
    utf8        = 0x09 | 0x0a | 0x0d | (0x20..0x7e) |
                  (0xc2..0xdf) (0x80..0xbf) |
                  (0xe0..0xef 0x80..0xbf 0x80..0xbf) |
                  (0xf0..0xf4 0x80..0xbf 0x80..0xbf 0x80..0xbf);
}%%

%%{
    machine arana_tok;
    include utf8;

    comment     = "#"+ (utf8 - newline)*;
    commentline = whitespace* comment newline?;
    emptyline   = whitespace* newline;
    linecont    = "\\" newline;

    name        = [a-zA-Z_][a-zA-Z0-9_]*;
    privname    = "@" [a-zA-Z0-9_]*;
    colonname   = [a-zA-Z_]* ":" [a-zA-Z_][a-zA-Z0-9_]*;
    none        = "None";
    true        = "True";
    false       = "False";
    int         = [0-9]{1,9};
    float       = ("0" | [1-9] [0-9]*)
                  ("."  [0-9]+)? ("e" [\-+] [0-9]+)?;

    # strings
    quote1      = '"';
    interp1     = "#{";
    escape1     = "\\\""|"\\'"|"\\/"|"\\\\"|"\\#"|
                  "\\a"|"\\b"|"\\f"|"\\n"|"\\r"|"\\t"|"\\v";
    #escuni1     = "\\u" [0-9a-fA-F]{4};
    escx1       = "\\x" [0-9a-fA-F]{2};
    schar1      = utf8 -- ("\\" | "#" | '"' | "\n");
    stringpart  = (escape1 | escx1 | schar1)*;

    quote2      = "'";
    rawstring   = ( [^'\\\n] | /\\./ )* "'";

    # regular expressions
    regexpr     = (utf8 -- ("\\/" | "\n"))* "/";

    string1 := |*
        # end of the string
        quote1     => { TOKEN(INTERP_END); fret; };
        # start of #{} area
        interp1    => { // fcall'ing body here instead of fgoto'ing to keep the
                        // string state on the stack
                        TOKEN(LBRACE); ps->nesting++; fcall body; };
        stringpart => { TOKEN2(INTERP_STRING, ar_string_decode(AR_ISIG, ts, te, 1)); };
    *|;

    string2 := |*
        rawstring  => { TOKEN2(CONST, ar_string_decode(AR_ISIG, ts, te-1, 2));
                        ps->stringtype = 0; fret; };
    *|;

    regex := |*
        regexpr    => { TOKEN2(CONST, ar_string_decode(AR_ISIG, ts, te-1, 3));
                        ps->stringtype = 0; fret; };
    *|;

    body := |*
        # ignored characters (not at line start)
        whitespace;
        comment;
        linecont;

        # syntactically relevant newlines
        newline     => { if (ps->nesting == 0) { TOKEN(NEWLINE); fgoto indent; } };

        # syntactic elements
        ";"         => { TOKEN(SEMICOLON); };
        "{"         => { TOKEN(LBRACE); ps->nesting++; fcall body; };
        "}"         => { TOKEN(RBRACE); ps->nesting--; fret; };
        "["         => { TOKEN(LBRACKET); ps->nesting++; };
        "]"         => { TOKEN(RBRACKET); ps->nesting--; };
        "("         => { TOKEN(LPAREN); ps->nesting++; };
        ")"         => { TOKEN(RPAREN); ps->nesting--; };
        "."         => { TOKEN(DOT); };
        ","         => { TOKEN(COMMA); };
        ":"         => { TOKEN(COLON); };

        # keywords
        "if"        => { TOKEN(IF); };
        "else"      => { TOKEN(ELSE); };
        "for"       => { TOKEN(FOR); };
        "in"        => { TOKEN(IN); };
        "pass"      => { TOKEN(PASS); };
        #"def"       => { TOKEN(DEF); };
        #"import"    => { TOKEN(IMPORT); };
        #"while"     => { TOKEN(WHILE); };
        #"with"      => { TOKEN(WITH); };
        #"try"       => { TOKEN(TRY); };
        #"except"    => { TOKEN(EXCEPT); };

        # operators
        "||"|"or"   => { TOKEN(OR); };
        "&&"|"and"  => { TOKEN(AND); };
        "!"|"not"   => { TOKEN(NOT); };

        "=="        => { TOKEN(EQ); };
        "!="        => { TOKEN(NEQ); };
        ">"         => { TOKEN(GT); };
        ">="        => { TOKEN(GTE); };
        "<"         => { TOKEN(LT); };
        "<="        => { TOKEN(LTE); };

        "|"         => { TOKEN(PIPE); };
        "^"         => { TOKEN(CARET); };
        "&"         => { TOKEN(AMP); };
        "~"         => { TOKEN(TILDE); };
        "<<"        => { TOKEN(BITL); };
        ">>"        => { TOKEN(BITR); };
        "+"         => { TOKEN(ADD); };
        "-"         => { TOKEN(SUB); };
        "*"         => { TOKEN(MUL); };
        "%"         => { TOKEN(MOD); };
        "**"        => { TOKEN(POW); };

        # special -- division or regex literal, decide by previous token
        "/"         => { if (ISLAST(RPAREN) || ISLAST(RBRACKET) ||
                               ISLAST(NAME) || ISLAST(CONST)) {
                             TOKEN(DIV);
                         } else {
                             ps->stringtype = AR_STR_REGEX; fcall regex;
                         } };

        # assignment operators
        "="         => { TOKEN(ASSIGN); };
        "+="        => { TOKEN(ADDASSIGN); };
        "++"        => { TOKEN(MADD); };
        "-="        => { TOKEN(SUBASSIGN); };
        "--"        => { TOKEN(MSUB); };
        "*="        => { TOKEN(MULASSIGN); };
        "/="        => { TOKEN(DIVASSIGN); };
        "%="        => { TOKEN(MODASSIGN); };
        "**="       => { TOKEN(POWASSIGN); };
        #"|="        => { TOKEN(PIPEASSIGN); };
        #"^="        => { TOKEN(CARETASSIGN); };
        #"&="        => { TOKEN(AMPASSIGN); };
        #"<<="       => { TOKEN(BITLASSIGN); };
        #">>="       => { TOKEN(BITRASSIGN); };

        # literals/constants
        none        => { TOKEN2(CONST, AR_NONE); };
        true        => { TOKEN2(CONST, AR_TRUE); };
        false       => { TOKEN2(CONST, AR_FALSE); };
        int         => { TOKEN2(CONST, ar_atol(AR_ISIG, ts, te - ts, 10)); };
        float       => { TOKEN2(CONST, ar_atof(AR_ISIG, ts, te - ts)); };
        quote1      => { TOKEN(INTERP_START);
                         ps->stringtype = AR_STR_DOUBLE; fcall string1; };
        quote2      => { ps->stringtype = AR_STR_SINGLE; fcall string2; };

        # others
        name        => { TOKEN2(NAME, AR_STRING2(ts, te - ts)); };
        privname    => { TOKEN2(NAME, AR_STRING2(ts, te - ts)); };
        colonname   => { TOKEN2(NAME, AR_STRING2(ts, te - ts)); };
    *|;

    # the tokenizer starts in this state
    indent := |*
        commentline;
        emptyline;
        whitespace* => {
            int res = processindent(wslen(ts, te, &ps->indentstyle), ps);
            if (res == 3) { AR_RAISE_OOM(); }
            else if (res == 2) { fbreak; }
            else if (res == 1) { TOKEN(INDENT); }
            else if (res < 0) {
                for (; res < 0; res++) { TOKEN(DEDENT); }
            }
            fgoto body;
        };
        # if no indentation is found
        # XXX I don't know why whitespace* above doesn't match the empty string
        /./ => {
            fhold;  // keep this character
            int res = processindent(0, ps);
            if (res == 3) { AR_RAISE_OOM(); }
            else if (res == 2) { fbreak; }
            else if (res == 1) { assert(0); }  // can't happen
            else if (res < 0) {
                for (; res < 0; res++) { TOKEN(DEDENT); }
            }
            fgoto body;
        };
    *|;

    write data nofinal;

    prepush {
        if (top == stacksize-1) {
            stacksize *= 2;
            stack = AR_REALLOCTN(stack, int, stacksize);
            if (!stack) AR_RAISE_OOM();
        }
    }
}%%

/* tokenizer helper routines */

static int
wslen(char *start, char *end, char *style)
{
    int len = 0;
    if (start == end) return 0;
    if (*style == '\0')
        *style = *start;
    else if (*start != *style)
        return -1;
    while (start < end) {
        if (*start++ != *style) return -1;
        len++;
    }
    return len;
}

static int
processindent(int indent, ArParseState *ps)
{
//    printf("line %d, found indent: %d\n", (int)ps->lineno, indent);
    if (indent == -1) {
        ps->errortype = AR_SYN_ERROR_INCONSISTENT_INDENTATION;
        return 2;
    }
    int curindent = ps->indentstack[ps->indenttop];
    if (ps->indenttop == -1) {
        // first code line
        if (indent != 0) {
            ps->errortype = AR_SYN_ERROR_UNEXPECTED_INDENT;
            return 2;
        }
        // set initial indentation
        ps->indentstack[0] = 0;
        ps->indenttop = 0;
    } else if (indent > curindent) {
        // more indentation -- simply push the new length
        if (ps->indenttop == ps->indentstacksize-1) {
            ps->indentstacksize *= 2;
            ps->indentstack = AR_REALLOCTN(ps->indentstack, int,
                                           ps->indentstacksize);
            if (!ps->indentstack) return 3;
        }
        ps->indentstack[++ps->indenttop] = indent;
        return 1;
    } else if (indent < curindent) {
        // less indentation -- check if the level is on the stack
        for (int i = ps->indenttop-1; i >= 0; i--)
            if (ps->indentstack[i] == indent) {
                // found state on stack: emit DEDENT tokens as needed
                int ndedent = (ps->indenttop - i);
                ps->indenttop = i;
                return -ndedent;
            }
        // no matching indentation found => indentation error
        ps->errortype = AR_SYN_ERROR_INVALID_DEDENT;
        return 2;
    }
    // otherwise, no indentation change
    return 0;
};

static AR
ar_atol(AR_SIG, char *ptr, int len, int base)
{
    char buf[len+1];
    memcpy(buf, ptr, len);
    buf[len] = '\0';
    return AR_INTEGER(strtol(buf, NULL, base));
}

static AR
ar_atof(AR_SIG, char *ptr, int len)
{
    char buf[len+1];
    memcpy(buf, ptr, len);
    buf[len] = '\0';
    return AR_FLOAT(strtod(buf, NULL));
}

// XXX: what about multiline strings?
static AR
ar_string_decode(AR_SIG, char *start, char *end, int type)
{
    char buf[(end-start)+1];
    char *p = start;
    char *q = buf;
    char c;

    while (p < end) {
        if (*p == '\\') {
            p++;
            if (type > 1) {
                // raw-type literal (single quote or regex)
                if (*p == '\'') {
                    *q++ = '\'';
                    p++;
                } else {
                    *q++ = '\\';
                    *q++ = *p++;
                }
            } else {
                switch (c = *p++) {
                    case '\0':
                        // invalid escape (shouldn't happen)
                        continue;
                    case '"':
                    case '\'':
                    case '\\':
                    case '/':
                    case '#':
                        *q++ = c;
                        break;
                    case 'a':
                        *q++ = '\a';
                        break;
                    case 'b':
                        *q++ = '\b';
                        break;
                    case 'f':
                        *q++ = '\f';
                        break;
                    case 'n':
                        *q++ = '\n';
                        break;
                    case 'r':
                        *q++ = '\r';
                        break;
                    case 't':
                        *q++ = '\t';
                        break;
                    case 'v':
                        *q++ = '\v';
                        break;
                    case 'x': {
                        char code;
                        char cp[3];
                        memcpy(cp, p, 2); cp[2] = '\0';
                        code = strtoul(cp, NULL, 16);
                        *q++ = code;
                        p += 2;
                    }
/*
                    case 'u': {
                        unsigned long code;
                        char cp[5];
                        memcpy(cp, p, 4); cp[4] = '\0';
                        code = strtoul(cp, NULL, 16);
                        if (code < 0x80) {
                            *q++ = code;
                        } else if (code < 0x7ff) {
                            *q++ = (code >> 6) | 0xc0;
                            *q++ = (code & 0x3f) | 0x80;
                        } else if (code < 0xffff) {
                            *q++ = (code >> 12) | 0xe0;
                            *q++ = ((code >> 6) & 0x3f) | 0x80;
                            *q++ = (code & 0x3f) | 0x80;
                        }
                        p += 4;
                    }
*/
                    default:
                        // invalid escape (shouldn't happen)
                        continue;
                }
            }
        } else {
            *q++ = *p++;
        }
    }
    // XXX: return regex when type == 3
    return AR_STRING2(buf, q-buf);
}

void
arana_parse_error(AR_SIG, ArParseState *ps)
{
    char buf[400];
    int offset = ps->tokstart - ps->lineoffset;
    switch (ps->errortype) {
    case 0:
        snprintf(buf, 400, "Invalid syntax: %.*s>>>%.*s<<<",
                 (int)offset, ps->lineoffset,
                 (int)(ps->tokend - ps->tokstart), ps->tokstart);
        break;
    case AR_SYN_ERROR_INDENT_EXPECTED:
        sprintf(buf, "Expected an indented block");
        break;
    case AR_SYN_ERROR_UNEXPECTED_INDENT:
        sprintf(buf, "Unexpected indent");
        break;
    case AR_SYN_ERROR_UNEXPECTED_DEDENT:
        sprintf(buf, "Unexpected dedent");
        break;
    case AR_SYN_ERROR_INCONSISTENT_INDENTATION:
        sprintf(buf, "Inconsistent indentation "
                "(use either only spaces or only tabs)");
        break;
    case AR_SYN_ERROR_INVALID_DEDENT:
        sprintf(buf, "Invalid indentation level");
        break;
    case AR_SYN_ERROR_EOL_IN_STRING:
        sprintf(buf, "End of line while scanning string or regex literal");
        break;
    case AR_SYN_ERROR_UNEXPECTED_NEWLINE:
        sprintf(buf, "Unexpected end of line");
        break;
    default:
        AR_FATAL("arana_parse_error: unhandled errortype value\n");
    }
    ps->AI->error = AR_SYNTAX_ERROR(buf, ps->filename, ps->lineno, offset);
    arana_traceback_push(AR_ISIG, ps->filename, ps->lineno, NULL);
    arana_error_jump(AR_ISIG);
}

ArToplevelNode *
arana_parse(AR_SIG, AR filename, FILE *fp, const char *s, const char *ps1, const char *ps2)
{
    ArParseState *ps;
    // variables required by ragel
    int cs, act;
    char *p, *pe, *eof = 0;
    char *ts, *te;
    // the stack where the tokenizer stores its states
    int stacksize = STATESTACKSIZE, top = 0, *stack;
    // the input buffer, the initial buffer size is bufsize
    char *buffer;
    int bufsize, space, prefixlen = 0;
    int done, line = 0;
    ArToken *tok = NULL;  // current token

    if (fp) {
        bufsize = 1024;
        buffer = AR_ALLOC(bufsize);
        done = 0;
    } else {
        bufsize = 0;
        buffer = (char *)s;
        done = 1;  // for string input, there is only one step
    }

    void *pParser = ArParseAlloc(GC_malloc);
    if (!pParser) AR_RAISE_OOM();
    stack = AR_ALLOCTN(int, stacksize);
    if (!stack) AR_RAISE_OOM();
    ps = AR_ALLOCT(ArParseState);
    if (!ps) AR_RAISE_OOM();
    ps->AI = AI;
    ps->CF = CF;
    ps->ast = NULL;
    ps->filename = AR_AS_CHARP(filename);
    ps->lineno = 1;
    ps->lasttok = -1;
    ps->nesting = 0;
    ps->indentstacksize = INDENTSTACKSIZE;
    ps->indentstack = AR_ALLOCTN(int, INDENTSTACKSIZE);
    if (!ps->indentstack) AR_RAISE_OOM();
    ps->indenttop = -1;
    ps->indentstyle = '\0';
    ps->errortype = 0;

    %% write init;

#ifndef NDEBUG
    //ArParseTrace(stderr, "[parser] ");
#endif

    do {
        space = bufsize - prefixlen;
        if (bufsize > 0 && space < 2) {
            bufsize *= 2;
            buffer = AR_REALLOC(buffer, bufsize);
            if (!buffer) AR_RAISE_OOM();
            space = bufsize - prefixlen;
        }
        p = buffer + prefixlen;

        if (ps1) {
            // interactive?
            printf("%s ", line == 0 ? ps1 : ps2);
            char *ret = fgets(p, space, fp);
            if (ret == NULL)
                goto return_now;
            pe = p + strlen(p);
            // empty line: finishes multi-line construct
            if (pe == p + 1) {
                if (line > 0)
                    goto finish_now;
                else // single empty line: start over again
                    continue;
            }
            line++;
            eof = pe;  // flush the last token
        } else if (fp) {
            char *ret = fgets(p, space, fp);
            if (ret == NULL) {  // EOF
                done = 1;
                eof = pe = p;
            } else {
                pe = p + strlen(p);
            }
        } else {
            eof = pe = p + strlen(p);
        }

        ps->lineoffset = p;
        ps->tokstart = p;
        ps->tokend = p;

        %% write exec;

        if (cs == arana_tok_error) {
            if (ps->stringtype > 0)
                ps->errortype = AR_SYN_ERROR_EOL_IN_STRING;
            ps->tokstart = p;
            ps->tokend = p+1;
            AR_PARSE_ERROR(ps);
        }

        if (ts == 0)  // end of last token = end of last block
            prefixlen = 0;
        else {        // got a prefix to preserve, move it to the block start
            prefixlen = pe - ts;
            memmove(buffer, ts, prefixlen);
            te = buffer + (te-ts);
            ts = buffer;
        }

        if (ps1 && line == 1) {  // interactive mode: try to finish after first line
            if (ArParse(pParser, AR_TOK_END, 0, ps, 1) == 0) {
                ArParse(pParser, 0, 0, ps, 0);
                goto return_now;
            }
        }
    } while (!done);

  finish_now:
    // if EOF isn't yet valid
    if (ArParse(pParser, AR_TOK_END, 0, ps, 1) == 1) {
        // make sure to properly finish all statements and blocks
        ArParse(pParser, AR_TOK_NEWLINE, 0, ps, 1);
        for (; ps->indenttop > 0; ps->indenttop--)
            ArParse(pParser, AR_TOK_DEDENT, 0, ps, 0);
        ArParse(pParser, AR_TOK_END, 0, ps, 0);
    }
    ArParse(pParser, 0, 0, ps, 0);

  return_now:
    ArParseFree(pParser, GC_free);
    if (fp) AR_FREE(buffer);
    AR_FREE(stack);

    return ps->ast;
}

/* main lexing/parsing entry points */

ArToplevelNode *
arana_parse_file(AR_SIG, FILE *fp, AR filename)
{
    return arana_parse(AR_ISIG, filename, fp, NULL, NULL, NULL);
}

ArToplevelNode *
arana_parse_interactive(AR_SIG, FILE *fp, AR filename, char *ps1, char *ps2)
{
    ArToplevelNode *ret;
    ret = arana_parse(AR_ISIG, filename, fp, NULL, ps1, ps2);
    if (!ret)
        return NULL;

    /* magically assign @ if we compiled an expression */
    if (ret->v.Module.stmts->count == 1 &&
        AR_AST_IS(ret->v.Module.stmts->items[0], Compound)) {
        ArStmtNode *comp = ret->v.Module.stmts->items[0];
        if (comp->v.Compound.stmts->count == 1 &&
            AR_AST_IS(comp->v.Compound.stmts->items[0], ExprStmt)) {
            ArStmtNode *expr = comp->v.Compound.stmts->items[0];
            expr->v.ExprStmt.expr = AR_AST(Assign,
                                           AR_AST(Name, "@", AR_CTX_Store),
                                           expr->v.ExprStmt.expr);
        }
    }
    return ret;
}

ArToplevelNode *
arana_parse_string(AR_SIG, char *s, AR filename)
{
    return arana_parse(AR_ISIG, filename, NULL, s, NULL, NULL);
}