htpl

 view release on metacpan or  search on metacpan

htpl-parse.c  view on Meta::CPAN

/** HTPL Macro parser **********************************
 ** This file is created automatically by htpl-crp.pl **
 ** Do not attempt to edit *****************************/

#define __HTPARSE__
#include "htpl.h"
#include "htpl-sh.h"
#include "perf.h"

#define RETURN(x) {int v = (x); destroypersist(); return v;}
#define numtokens (persist->tokens->num)

int parse_htpl_graph(stack, untag)
    int untag;
    STR stack; {

    TOKEN token;
    static done = 0;
    STR buff;
    int code;
    static int nesting = 0;
    static int refcount = 0;

    refcount++;
    makepersist(stack);
    printcode("{\n");
    if (numtokens < 3) RETURN(croak("%sGRAPH called with %d arguments, minimum needed is 3", (untag ? "/" : ""), numtokens))
    if (!done) {
        done = 1;
        printcode("use HTML::HTPL::Graph;\n");
    }
    printcode("	my $g = new HTML::HTPL::Graph;\n");
    printfcode(" $g->set('data' => [${\"%s\"}->project(\"%s\")]);\n", gettoken(1), gettoken(2));
    printfcode(" $g->set('labels' => [${\"%s\"}->project(\"%s\")]);\n", gettoken(1), gettoken(3));
    if (numtokens >= 4)  {
        printfcode(" $g->set('width' => %s);\n", gettoken(4));
    }
    if (numtokens >= 5)  {
        printfcode(" $g->set('cols' => %s);\n", gettoken(5));
    }
    if (numtokens >= 6)  {
        printfcode(" $g->set('legend' => [split(/:/, \"%s\")]);\n", gettokenlist(6, " ", "", ""));
    }
    printcode("	print $g->ashtml;\n");
    printcode("}\n");
    nesting = 0;
    RETURN(1)
}

int parse_htpl_combobox(stack, untag)
    int untag;
    STR stack; {

    TOKEN token;
    static done = 0;
    STR buff;
    int code;
    static int nesting = 0;
    static int refcount = 0;

    refcount++;
    makepersist(stack);
    nesting++;
    if (nesting > 1) RETURN(croak("Infinite loop in COMBOBOX"))
    kludge_reunifying = 1;
    asprintf(&buff, "SERVBOXEN DECIDE 0 %s", gettokenlist(1, " ", "", ""));
    kludge_reunifying = 0;
    nest++;
    code = parse_htpl(buff, untag);
    nest--;
    if (!code) {
        croak("Unification of '%s' failed", buff);
        free(buff);
        RETURN(0)
    }
    free(buff);

    nesting = 0;
    RETURN(1)
}

int parse_htpl_fetchit(stack, untag)
    int untag;
    STR stack; {

    TOKEN token;
    static done = 0;
    STR buff;
    int code;
    static int nesting = 0;
    static int refcount = 0;

    refcount++;
    makepersist(stack);
    if (numtokens < 1) RETURN(croak("%sFETCHIT called with %d arguments, minimum needed is 1", (untag ? "/" : ""), numtokens))
    if (numtokens > 1) RETURN(croak("%sFETCHIT called with %d arguments, maximum needed is 1", (untag ? "/" : ""), numtokens))
    printfcode("${\"%s\"}->fetch;\n", gettoken(1));
    nesting = 0;
    RETURN(1)
}

int parse_htpl_catch(stack, untag)
    int untag;
    STR stack; {

    TOKEN token;
    static done = 0;
    STR buff;
    int code;
    static int nesting = 0;

htpl-parse.c  view on Meta::CPAN

            "CONSTRUCTOR",
            "CONTINUE",
            "COPY",
            "COUNTER",
            "DEFAULT",
            "DEFINE",
            "DESTRUCTOR",
            "DIE",
            "DIR",
            "DISPOSE",
            "ELSE",
            "END",
            "ENDIF",
            "EXIT",
            "FETCH",
            "FETCHCELL",
            "FETCHCOLS",
            "FETCHIT",
            "FETCHITORBREAK",
            "FILE",
            "FILTER",
            "FOR",
            "FOREACH",
            "GRAPH",
            "IF",
            "IFNOTNULL",
            "IFNULL",
            "IMG",
            "INIT",
            "LDAP",
            "LISTBOX",
            "LOAD",
            "LOOP",
            "MAIL",
            "MEM",
            "MERGE",
            "METHOD",
            "NET",
            "NEXT",
            "OUT",
            "PROC",
            "PROJECT",
            "PTS",
            "PUBLISH",
            "REDIRECT",
            "REM",
            "REQ_SYMBOL",
            "REWIND",
            "SERVBOXEN",
            "SQL",
            "SWITCH",
            "TEXT",
            "THROW",
            "TIME",
            "TRY"};
        static int htpl_locations[] = { 17, 18, 30, 39, 46, 56, 63, -1, 12, 21, 37, 61, -1, 25, 43, 59, 62, 65, -1, 9, 27, 33, 54, 57, -1, 1, 2, 7, 41, 44, 48, 52, -1, 13, 19, 22, 23, 26, 42, 49, 64, -1, 11, 31, 38, 47, 50, 58, -1, 3, 8, 14, 24, 29, ...
        static int htpl_shortcuts[] = { 0, 8, 13, 19, 25, 33, 42, 49, 60, 68 };
        static struct hash_t htpl_hash = {htpl_table,
             htpl_locations, htpl_shortcuts};

        static parser funs[] = { parse_htpl_assert, parse_htpl_auth, parse_htpl_auth_create, parse_htpl_break, parse_htpl_call, parse_htpl_case, parse_htpl_catch, parse_htpl_class, parse_htpl_cleanup, parse_htpl_clsutils, parse_htpl_combobox, parse_h...
        int n;
        parser fun;
        n = search_hash(&htpl_hash, token, 0);
        if (n < 0) RETURN(0)
        fun = funs[n];
        RETURN(fun(stack, untag))
    }
}

int parse_(stack, untag)
    int untag;
    STR stack; {

    TOKEN token;
    static done = 0;
    STR buff;
    int code;
    static int nesting = 0;
    static int refcount = 0;

    refcount++;
    makepersist(stack);
    eat(&stack, token);
    {
        static char *htpl_table[] = {"HTPL"};
        static int htpl_locations[] = { 0, -1 };
        static int htpl_shortcuts[] = { -1, -1, -1, -1, -1, -1, 0, -1, -1, -1 };
        static struct hash_t htpl_hash = {htpl_table,
             htpl_locations, htpl_shortcuts};

        static parser funs[] = { parse_htpl };
        int n;
        parser fun;
        n = search_hash(&htpl_hash, token, 0);
        if (n < 0) RETURN(0)
        fun = funs[n];
        RETURN(fun(stack, untag))
    }
}



( run in 0.648 second using v1.01-cache-2.11-cpan-59e3e3084b8 )