⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parser.c

📁 我搜集到的一个java常用类库的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
        /*           if this is the end tag for ancestor element          then infer end tag for this element        */        if (node->type == EndTag)        {            if (node->tag == tag_form)            {                lexer->badForm = yes;                ReportWarning(lexer, rowgroup, node, DISCARDING_UNEXPECTED);                continue;            }            if (node->tag == tag_tr || node->tag == tag_td || node->tag == tag_th)            {                ReportWarning(lexer, rowgroup, node, DISCARDING_UNEXPECTED);                FreeNode(node);                continue;            }            for (parent = rowgroup->parent;                    parent != null; parent = parent->parent)            {                if (node->tag == parent->tag)                {                    UngetToken(lexer);                    TrimEmptyElement(lexer, rowgroup);                    return;                }            }        }        /*          if THEAD, TFOOT or TBODY then implied end tag        */        if (node->tag->model & CM_ROWGRP)        {            if (node->type != EndTag)                UngetToken(lexer);            TrimEmptyElement(lexer, rowgroup);            return;        }        if (node->type == EndTag)        {            ReportWarning(lexer, rowgroup, node, DISCARDING_UNEXPECTED);            continue;        }                if (!(node->tag == tag_tr))        {            node = InferredTag(lexer, "tr");            ReportWarning(lexer, rowgroup, node, MISSING_STARTTAG);            UngetToken(lexer);        }       /* node should be <TR> */        InsertNodeAtEnd(rowgroup, node);        ParseTag(lexer, node, IgnoreWhitespace);    }    TrimEmptyElement(lexer, rowgroup);}void ParseColGroup(Lexer *lexer, Node *colgroup, uint mode){    Node *node, *parent;    if (colgroup->tag->model & CM_EMPTY)        return;    while ((node = GetToken(lexer, IgnoreWhitespace)) != null)    {        if (node->tag == colgroup->tag && node->type == EndTag)        {            FreeNode(node);            colgroup->closed = yes;            return;        }        /*           if this is the end tag for an ancestor element          then infer end tag for this element        */        if (node->type == EndTag)        {            if (node->tag == tag_form)            {                lexer->badForm = yes;                ReportWarning(lexer, colgroup, node, DISCARDING_UNEXPECTED);                continue;            }            for (parent = colgroup->parent;                    parent != null; parent = parent->parent)            {                if (node->tag == parent->tag)                {                    UngetToken(lexer);                    return;                }            }        }        if (node->type == TextNode)        {            UngetToken(lexer);            return;        }        /* deal with comments etc. */        if (InsertMisc(colgroup, node))            continue;        /* discard unknown tags */        if (node->tag == null)        {            ReportWarning(lexer, colgroup, node, DISCARDING_UNEXPECTED);            FreeNode(node);            continue;        }        if (node->tag != tag_col)        {            UngetToken(lexer);            return;        }        if (node->type == EndTag)        {            ReportWarning(lexer, colgroup, node, DISCARDING_UNEXPECTED);            continue;        }                /* node should be <COL> */        InsertNodeAtEnd(colgroup, node);        ParseTag(lexer, node, IgnoreWhitespace);    }}void ParseTableTag(Lexer *lexer, Node *table, uint mode){    Node *node, *parent;    uint istackbase;    DeferDup(lexer);    istackbase = lexer->istackbase;    lexer->istackbase = lexer->istacksize;        while ((node = GetToken(lexer, IgnoreWhitespace)) != null)    {        if (node->tag == table->tag && node->type == EndTag)        {            FreeNode(node);            lexer->istackbase = istackbase;            table->closed = yes;            TrimEmptyElement(lexer, table);            return;        }        /* deal with comments etc. */        if (InsertMisc(table, node))            continue;        /* discard unknown tags */        if (node->tag == null && node->type != TextNode)        {            ReportWarning(lexer, table, node, DISCARDING_UNEXPECTED);            FreeNode(node);            continue;        }        /* if TD or TH or text or inline or block then infer <TR> */        if (node->type != EndTag)        {            if (node->tag == tag_td ||                 node->tag == tag_th ||                node->tag == tag_table)            {                UngetToken(lexer);                node = InferredTag(lexer, "tr");                ReportWarning(lexer, table, node, MISSING_STARTTAG);            }            else if (node->type == TextNode                       || (node->tag->model & (CM_BLOCK | CM_INLINE)))            {                InsertNodeBeforeElement(table, node);                ReportWarning(lexer, table, node, TAG_NOT_ALLOWED_IN);                lexer->exiled = yes;                if (!node->type == TextNode)                    ParseTag(lexer, node, IgnoreWhitespace);                lexer->exiled = no;                continue;            }            else if (node->tag->model & CM_HEAD)            {                MoveToHead(lexer, table, node);                continue;            }        }        /*           if this is the end tag for an ancestor element          then infer end tag for this element        */        if (node->type == EndTag)        {            if (node->tag == tag_form)            {                lexer->badForm = yes;                ReportWarning(lexer, table, node, DISCARDING_UNEXPECTED);                continue;            }            if (node->tag && node->tag->model & (CM_TABLE|CM_ROW))            {                ReportWarning(lexer, table, node, DISCARDING_UNEXPECTED);                FreeNode(node);                continue;            }            for (parent = table->parent;                    parent != null; parent = parent->parent)            {                if (node->tag == parent->tag)                {                    ReportWarning(lexer, table, node, MISSING_ENDTAG_BEFORE);                    UngetToken(lexer);                    lexer->istackbase = istackbase;                    TrimEmptyElement(lexer, table);                    return;                }            }        }        if (!(node->tag->model & CM_TABLE))        {            UngetToken(lexer);            ReportWarning(lexer, table, node, TAG_NOT_ALLOWED_IN);            lexer->istackbase = istackbase;            TrimEmptyElement(lexer, table);            return;        }        if (node->type == StartTag || node->type == StartEndTag)        {            InsertNodeAtEnd(table, node);;            ParseTag(lexer, node, IgnoreWhitespace);            continue;        }        /* discard unexpected text nodes and end tags */        ReportWarning(lexer, table, node, DISCARDING_UNEXPECTED);        FreeNode(node);    }    ReportWarning(lexer, table, node, MISSING_ENDTAG_FOR);    TrimEmptyElement(lexer, table);    lexer->istackbase = istackbase;}void ParsePre(Lexer *lexer, Node *pre, uint mode){    Node *node, *parent;    if (pre->tag->model & CM_EMPTY)        return;    if (pre->tag->model & CM_OBSOLETE)        CoerceNode(lexer, pre, tag_pre);    InlineDup(lexer, null); /* tell lexer to insert inlines if needed */    while ((node = GetToken(lexer, Preformatted)) != null)    {        if (node->tag == pre->tag && node->type == EndTag)        {            FreeNode(node);            TrimSpace(lexer, pre);            pre->closed = yes;            TrimEmptyElement(lexer, pre);            return;        }        if (node->tag == tag_html)        {            if (node->type == StartTag || node->type == StartEndTag)                ReportWarning(lexer, pre, node, DISCARDING_UNEXPECTED);            FreeNode(node);            continue;        }        if (node->type == TextNode)        {            /* if first check for inital newline */            if (pre->content == null)            {                if (lexer->lexbuf[node->start] == '\n')                    ++(node->start);                if (node->start >= node->end)                {                    FreeNode(node);                    continue;                }            }            InsertNodeAtEnd(pre, node);            continue;        }        /* deal with comments etc. */        if (InsertMisc(pre, node))            continue;        /* discard unknown  and PARAM tags */        if (node->tag == null || node->tag == tag_param)        {            ReportWarning(lexer, pre, node, DISCARDING_UNEXPECTED);            FreeNode(node);            continue;        }        if (node->tag == tag_p)        {            if (node->type == StartTag)            {                ReportWarning(lexer, pre, node, USING_BR_INPLACE_OF);                /* trim white space before <p> in <pre>*/                TrimSpace(lexer, pre->last);                            /* coerce both <p> and </p> to <br> */                CoerceNode(lexer, node, tag_br);                InsertNodeAtEnd(pre, node);            }            else            {                ReportWarning(lexer, pre, node, DISCARDING_UNEXPECTED);                FreeNode(node);            }            continue;        }        if (node->tag->model & CM_HEAD && !(node->tag->model & CM_BLOCK))        {            MoveToHead(lexer, pre, node);            continue;        }        /*           if this is the end tag for an ancestor element          then infer end tag for this element        */        if (node->type == EndTag)        {            if (node->tag == tag_form)            {                lexer->badForm = yes;                ReportWarning(lexer, pre, node, DISCARDING_UNEXPECTED);                continue;            }            for (parent = pre->parent;                    parent != null; parent = parent->parent)            {                if (node->tag == parent->tag)                {                    ReportWarning(lexer, pre, node, MISSING_ENDTAG_BEFORE);                    UngetToken(lexer);                    TrimSpace(lexer, pre);                    TrimEmptyElement(lexer, pre);                    return;                }            }        }        /* what about head content, HEAD, BODY tags etc? */        if (!(node->tag->model & CM_INLINE))        {            if (node->type != StartTag)            {                ReportWarning(lexer, pre, node, DISCARDING_UNEXPECTED);                continue;            }             ReportWarning(lexer, pre, node, MISSING_ENDTAG_BEFORE);            lexer->excludeBlocks = yes;            /* check if we need to infer a container */            if (node->tag->model & CM_LIST)            {                UngetToken(lexer);                node = InferredTag(lexer, "ul");                AddAttribute(node, "style", "margin-left: -2em");            }            else if (node->tag->model & CM_DEFLIST)            {                UngetToken(lexer);                node = InferredTag(lexer, "dl");            }            else if (node->tag->model & CM_TABLE)            {                UngetToken(lexer);                node = InferredTag(lexer, "table");            }            InsertNodeAfterElement(pre, node);            pre = InferredTag(lexer, "pre");            InsertNodeAfterElement(node, pre);            ParseTag(lexer, node, IgnoreWhitespace);            lexer->excludeBlocks = no;            continue;        }#if 0        if (!(node->tag->model & CM_INLINE))        {            ReportWarning(lexer, pre, node, MISSING_ENDTAG_BEFORE);            UngetToken(lexer);            return;        }#endif        if (node->type == StartTag || node->type == StartEndTag)        {            /* trim white space before <br> */            if (node->tag == tag_br)                TrimSpace(lexer, pre->last);                        InsertNodeAtEnd(pre, node);            ParseTag(lexer, node, Preformatted);            continue;        }        /* discard unexpected tags */        ReportWarning(lexer, pre, node, DISCARDING_UNEXPECTED);        FreeNode(node);    }    ReportWarning(lexer, pre, node, MISSING_ENDTAG_FOR);    TrimEmptyElement(lexer, pre);}void ParseOptGroup(Lexer *lexer, Node *field, uint mode){    Node *node;    lexer->insert = null;  /* defer implicit inline start tags */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -