Пример #1
0
void
parse_item(void)
{
    if (!gInItems) {
        fprintf(stderr, "\\item found outside an items environment\n");
        print_page_and_filename();
        print_next_ten_tokens();
        jump();
    }
    curr_node->type = Item;
    get_token();
    if (token.type == Lsquarebrace) {
        /* I should parse the optional argument */
        curr_node->next = alloc_node();
        curr_node = curr_node->next;
        curr_node->type = Description;
        curr_node->next = alloc_node();
        curr_node = curr_node->next;
        gInOptional++;
        parse_HyperDoc();
        gInOptional--;
        curr_node->type = Enddescription;
        if (token.type != Rsquarebrace) {
            fprintf(stderr, "(HyperDoc) Optional arguments must end with ].\n");
            print_next_ten_tokens();
            print_page_and_filename();
            jump();
        }
    }
    else {
        unget_token();
    }
}
Пример #2
0
void
parse_pastebutton(void)
{
    PasteNode *paste;
    TextNode *pb;

    /*
     * this routine parse a \pastebutton expression. The syntax is
     * \pastebutton{name}
     */
    pb = curr_node;
    pb->type = openaxiom_Pastebutton_token;

    /* first thing I should do is get the name */
    get_token();
    if (token.type != openaxiom_Lbrace_token) {
        fprintf(stderr, "(HyperDoc) \\pastebutton needs a name\n");
        print_page_and_filename();
        print_next_ten_tokens();
        jump();
    }
    pb->data.text = alloc_string(get_input_string());

    /*
     * now I should see if the paste area has already been parsed, and if not
     * I should create a spot in the hash table for it
     */
    paste = (PasteNode *) hash_find(gWindow->fPasteHashTable, pb->data.text);
    if (paste == 0) {
        paste = alloc_paste_node(pb->data.text);
        hash_insert(gWindow->fPasteHashTable,(char *) paste, paste->name);
    }
    else if (paste->hasbutton) {
        fprintf(stderr, "(HyperDoc) Tried to redefine paste area %s\n", paste->name);
        print_page_and_filename();
        /* jump(); */
    }
    paste->hasbutton = 1;

    /* Now we need to parse the HyperDoc and for the displayed text */

    get_token();
    if (token.type != openaxiom_Lbrace_token) {
        fprintf(stderr, "(HyperDoc) \\pastebutton was expecting a { \n");
        print_page_and_filename();
        print_next_ten_tokens();
        jump();
    }
    pb->next = alloc_node();
    curr_node = pb->next;
    parse_HyperDoc();
    curr_node->type = openaxiom_Endpastebutton_token;

    /* once that is done I need only make the window for this link */
    pb->link = make_paste_window(paste);
}
Пример #3
0
void
parse_begin_items(void)
{
    TextNode *bi = curr_node;

    /*
     * This procedure parses a begin item. It sets the current
     * node and sees if there is an optional argument for the itemspace
     */

    bi->type = token.type;
    get_token();
    if (token.type == Lsquarebrace) {
        bi->data.node = alloc_node();
        curr_node = bi->data.node;
        gInOptional++;
        parse_HyperDoc();
        gInOptional--;
        curr_node->type = Enddescription;
        if (token.type != Rsquarebrace) {
            fprintf(stderr, "(HyperDoc) Optional arguments must end with ].\n");
            print_next_ten_tokens();
            print_page_and_filename();
            jump();
        }
        curr_node = bi;
    }
    else
        unget_token();
    gInItems++;
}
Пример #4
0
void
parse_mitem(void)
{
    if (!gInItems) {
        fprintf(stderr, "\\mitem found outside an items environment\n");
        print_page_and_filename();
        print_next_ten_tokens();
        jump();
    }
    curr_node->type = Mitem;
}
Пример #5
0
void
parse_centerline(void)
{
    curr_node->type = token.type;
    curr_node->space = token.id[-1];
    curr_node->width = -1;
    curr_node->next = alloc_node();
    curr_node = curr_node->next;
    get_expected_token(Lbrace);
    parse_HyperDoc();
    if (token.type != Rbrace) {
        curr_node->type = Noop;
        fprintf(stderr, "(HyperdDoc) \\centerline was expecting a }\n");
        print_page_and_filename();
        print_next_ten_tokens();
        longjmp(jmpbuf, 1);
    }
    curr_node->type = Endcenter;
}
Пример #6
0
void
htperror(char *msg, int errno)
{
    char obuff[4096];

    /* The first thing I do is create the error message */

    if (errno <= Numerrors) {
        sprintf(obuff, "%s:%s\n", msg, errmess[errno]);
    }
    else {
        sprintf(obuff, "%s:\n", msg);
        fprintf(stderr, "Unknown error type %d\n", errno);
    }
    fprintf(stderr, "%s", obuff);

    print_page_and_filename();

    print_next_ten_tokens();
}
Пример #7
0
void
parse_paste(void)
{
    TextNode *pn = curr_node;
    PasteNode *paste;
    int where;

    if (gParserRegion != Scrolling) {
        fprintf(stderr, "(HyperDoc) Paste areas are only allowed in the scrolling area:");
        print_page_and_filename();
        jump();
    }
    gInPaste++;

    /* now I need to get the name */
    get_token();
    if (token.type != openaxiom_Lbrace_token) {
        fprintf(stderr, "(HyperDoc) A paste area needs a name:\n");
        print_next_ten_tokens();
        print_page_and_filename();
        jump();
    }
    pn->data.text = alloc_string(get_input_string());
    pn->type = openaxiom_Paste_token;

    /*
     * now see if there is already an entry in the hash_table for this thing,
     * if not create it and put it there.
     */
    paste = (PasteNode *) hash_find(gWindow->fPasteHashTable, pn->data.text);
    if (paste == 0) {
        paste = alloc_paste_node(pn->data.text);
        hash_insert(gWindow->fPasteHashTable, (char *)paste, paste->name);
    }
    else if (paste->haspaste) {
        fprintf(stderr, "(HyperDoc) Tried to redefine paste area %s\n", paste->name);
        print_page_and_filename();
        /* jump(); */
    }
    paste->haspaste = 1;
    paste->paste_item = current_item();
    get_token();
    if (token.type == openaxiom_Lsquarebrace_token) {
        /* user wishes to specify a where to send the command */
        where = get_where();
        if (where == -1) {
            paste->where = -1;
            fprintf(stderr, "(HyperDoc) \\begin{paste} was expecting [lisp|unix|ht]\n");
            print_next_ten_tokens();
            print_page_and_filename();
            jump();
        }
        else
            paste->where = where;
        get_token();
    }
    else
        paste->where = openaxiom_FromFile_input;

    /* now try to get the command argument or page name */
    if (token.type != openaxiom_Lbrace_token) {
        paste->where = 0;
        fprintf(stderr, "(HyperDoc) \\begin{paste} was expecting an argument\n");
        print_next_ten_tokens();
        print_page_and_filename();
        jump();
    }
    paste->arg_node = alloc_node();
    curr_node = paste->arg_node;
    parse_HyperDoc();
    curr_node->type = openaxiom_Endarg_token;

    gWindow->fDisplayedWindow = gWindow->fScrollWindow;

    /* Now try to find the displaying text */
    pn->next = alloc_node();
    curr_node = pn->next;
    parse_HyperDoc();
    curr_node->type = openaxiom_Endpaste_token;
    paste->end_node = curr_node;

    paste->begin_node = pn;
    gInPaste--;
}