File: parserprocess.c

package info (click to toggle)
yodl 4.04.00-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,720 kB
  • sloc: ansic: 7,803; perl: 683; cpp: 570; sh: 411; xml: 190; makefile: 164
file content (55 lines) | stat: -rw-r--r-- 1,567 bytes parent folder | download | duplicates (4)
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
#include "parser.ih"

void parser_process(register Parser *pp)
{
    register size_t idx;
    char const *preload;

            /* put all files in reversed order on the lexer's filestack, so */
            /* they will be processed in their reversed order, i.e., in the */
            /* order they were specified on the cmd line                    */

    if (message_show(MSG_DEBUG)) message("Number of args `%u'", 
                                         (unsigned)args_nArgs());

    for (idx = args_nArgs(); idx--; )
    {
        char const *filename = args_arg(idx);
        char *full = file_fullpath(pp->d_symtab_ptr, filename);

        if (!full && strcmp(filename, "-"))
            if (message_show(MSG_EMERG))
                message("Can't read `%s' (cwd: %s, XXincludePath: %s)", 
                        filename, new_getcwd(), 
                        file_includePath(pp->d_symtab_ptr));

        if (message_show(MSG_INFO))
            message("Stacking  `%s' for processing", filename);

        lexer_push_file(&pp->d_lexer, full);
        free(full);
    }

    preload = args_optarg('p');
    if (preload)
        lexer_push_str(&pp->d_lexer, preload);

    do
    {
        p_parse(pp);
    }
    while (p_atexit(pp));

    if (message_errors())
    {
        message("Error(s) detected");
        ostream_destruct(pp->d_outs_ptr);
        if (pp->d_indexName)
        {
            fclose(pp->d_indexFile);
            unlink(pp->d_indexName);
        }
    }
    else if (message_show(MSG_NOTICE))
        message("Parsing completed");
}