のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

feat.c

feat.c 1786行目付近

/* --- Glyph --- */

/* Map feature file glyph name to gid; emit error message and return notdef if
   not found (in order to continue until hotQuitOnError() called) */
static GID featMapGName2GID(hotCtx g, char *gname, int allowNotdef) {
    GID gid;
    char *realname;

    // if (IS_CID(g)) {
    //     zzerr("glyph name specified for a CID font");
    // }

    gid = mapName2GID(g, gname, &realname);

    /* Return the glyph if found in the font. When allowNotdef is set, we
     * always return and callers should check for GID_UNDEF as we can't return
     * GID_NOTDEF in this case. */
    if (gid != GID_UNDEF || allowNotdef == 1) {
        return gid;
    }

    if (realname != NULL && strcmp(gname, realname) != 0) {
        featMsg(hotERROR, "Glyph \"%s\" (alias \"%s\") not in font",
                realname, gname);
    } else {
        featMsg(hotERROR, "Glyph \"%s\" not in font.", gname);
    }
    return GID_NOTDEF;
}

featgram.c 68行目付近

ID
#ifdef __USE_PROTOS
glyph(char *tok, int allowNotdef)
#else
    glyph(tok, allowNotdef) char *tok;
int allowNotdef;
#endif
{
    GID _retv;
    zzRULE;
    Attrib gname, cid;
    zzBLOCK(zztasp1);
    PCCTS_PURIFY(_retv, sizeof(GID))
    zzMake0;
    {
        _retv = 0; /* Suppress optimizer warning */
        if ((LA(1) == T_GNAME)) {
            zzmatch(T_GNAME);
            gname = zzaCur;

            _retv = featMapGName2GID(g, gname.text, allowNotdef);
            if (tok != NULL)
                strcpy(tok, gname.text);
            zzCONSUME;

        } else {
            if ((LA(1) == T_CID)) {
                zzmatch(T_CID);
                cid = zzaCur;

                _retv = cid2gid(g, (CID)(cid).lval);
                zzCONSUME;

            } else {
                zzFAIL(1, zzerr1, &zzMissSet, &zzMissText, &zzBadTok, &zzBadText, &zzErrk);
                goto fail;
            }
        }
        zzEXIT(zztasp1);
        return _retv;
    fail:
        zzEXIT(zztasp1);
        zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
        zzresynch(setwd1, 0x1);
        return _retv;
    }
}
GNode *
#ifdef __USE_PROTOS
pattern(int markedOK)
#else
    pattern(markedOK) int markedOK;
#endif
{
    GNode *_retv;
    zzRULE;
    Attrib t;
    zzBLOCK(zztasp1);
    PCCTS_PURIFY(_retv, sizeof(GNode *))
    zzMake0;
    {
        GNode **insert = &_retv;
        {
            zzBLOCK(zztasp2);
            int zzcnt = 1;
            zzMake0;
            {
                do {
                    {
                        zzBLOCK(zztasp3);
                        zzMake0;
                        {
                            if ((setwd3[LA(1)] & 0x20)) {
                                {
                                    zzBLOCK(zztasp4);
                                    zzMake0;
                                    {
                                        GID gid;
                                        gid = glyph(NULL, FALSE);

                                        *insert = newNode(h);
                                        (*insert)->gid = gid;
                                        (*insert)->nextCl = NULL;
                                        zzEXIT(zztasp4);
                                    }
                                }
                            } else {
                                if ((setwd3[LA(1)] & 0x40)) {
                                    {
                                        zzBLOCK(zztasp4);
                                        zzMake0;
                                        {
                                            GNode *gc;
                                            gc = glyphClass(false, false, NULL);

                                            *insert = gc;
                                            zzEXIT(zztasp4);
                                        }
                                    }
                                } else {
                                    zzFAIL(1, zzerr16, &zzMissSet, &zzMissText, &zzBadTok, &zzBadText, &zzErrk);
                                    goto fail;
                                }
                            }
                            zzEXIT(zztasp3);
                        }
                    }
                    {
                        zzBLOCK(zztasp3);
                        zzMake0;
                        {
                            if ((LA(1) == 156)) {
                                zzmatch(156);

                                if (markedOK) {
                                    /* Mark this node: */
                                    (*insert)->flags |= FEAT_MARKED;
                                } else
                                    zzerr("cannot mark a replacement glyph pattern");
                                zzCONSUME;

                            } else {
                                if ((setwd3[LA(1)] & 0x80)) {
                                } else {
                                    zzFAIL(1, zzerr17, &zzMissSet, &zzMissText, &zzBadTok, &zzBadText, &zzErrk);
                                    goto fail;
                                }
                            }
                            zzEXIT(zztasp3);
                        }
                    }
                    {
                        zzBLOCK(zztasp3);
                        zzMake0;
                        {
                            while ((LA(1) == K_lookup)) {
                                zzmatch(K_lookup);
                                zzCONSUME;
                                zzmatch(T_LABEL);
                                t = zzaCur;

                                {
                                    int labelIndex;
                                    if ((*insert) == NULL)
                                        zzerr("Glyph or glyph class must precede a lookup reference in a contextual rule.");

                                    labelIndex = featGetLabelIndex(t.text);
                                    (*insert)->lookupLabels[(*insert)->lookupLabelCount] = labelIndex;
                                    (*insert)->lookupLabelCount++;
                                    if ((*insert)->lookupLabelCount > 255)
                                        zzerr("Too many lookup references in one glyph position.");
                                    _retv->flags |= FEAT_LOOKUP_NODE; /* used to flag that lookup key was used.  */
                                }
                                zzCONSUME;

                                zzLOOP(zztasp3);
                            }
                            zzEXIT(zztasp3);
                        }
                    }
                    insert = &(*insert)->nextSeq;
                    zzLOOP(zztasp2);
                } while ((setwd4[LA(1)] & 0x1));
                zzEXIT(zztasp2);
            }
        }
        (*insert) = NULL;
        zzEXIT(zztasp1);
        return _retv;
    fail:
        zzEXIT(zztasp1);
        zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
        zzresynch(setwd4, 0x2);
        return _retv;
    }
}
void
#ifdef __USE_PROTOS
substitute(void)
#else
substitute()
#endif
{
    zzRULE;
    zzBLOCK(zztasp1);
    zzMake0;
    {
        GNode *targ;
        GNode *repl = NULL;
        int targLine;
        int type = 0;
        {
            zzBLOCK(zztasp2);
            zzMake0;
            {
                if ((LA(1) == K_except)) {
                    zzmatch(K_except);
                    type = GSUBChain;
                    h->syntax.numExcept++;
                    zzCONSUME;

                    targ = pattern(1);

                    targ->flags |= FEAT_IGNORE_CLAUSE;
                    addSub(targ, NULL, type, zzline);
                    {
                        zzBLOCK(zztasp3);
                        zzMake0;
                        {
                            while ((LA(1) == 155)) {
                                zzmatch(155);
                                zzCONSUME;
                                targ = pattern(1);

                                targ->flags |= FEAT_IGNORE_CLAUSE;
                                addSub(targ, NULL, type, zzline);
                                zzLOOP(zztasp3);
                            }
                            zzEXIT(zztasp3);
                        }
                    }
                } else {
                    if ((setwd5[LA(1)] & 0x10)) {
                    } else {
                        zzFAIL(1, zzerr23, &zzMissSet, &zzMissText, &zzBadTok, &zzBadText, &zzErrk);
                        goto fail;
                    }
                }
                zzEXIT(zztasp2);
            }
        }
        {
            zzBLOCK(zztasp2);
            zzMake0;
            {
                if ((LA(1) == K_reverse)) {
                    {
                        zzBLOCK(zztasp3);
                        zzMake0;
                        {
                            zzmatch(K_reverse);
                            type = GSUBReverse;
                            zzCONSUME;

                            targ = pattern(1);

                            targLine = zzline;
                            {
                                zzBLOCK(zztasp4);
                                zzMake0;
                                {
                                    if ((LA(1) == K_by)) {
                                        zzmatch(K_by);
                                        zzCONSUME;
                                        {
                                            zzBLOCK(zztasp5);
                                            zzMake0;
                                            {
                                                if ((LA(1) == K_NULL)) {
                                                    zzmatch(K_NULL);
                                                    addSub(targ, NULL, type, targLine);
                                                    zzCONSUME;

                                                } else {
                                                    if ((setwd5[LA(1)] & 0x20)) {
                                                        repl = pattern(0);

                                                        addSub(targ, repl, type, targLine);
                                                    } else {
                                                        zzFAIL(1, zzerr24, &zzMissSet, &zzMissText, &zzBadTok, &zzBadText, &zzErrk);
                                                        goto fail;
                                                    }
                                                }
                                                zzEXIT(zztasp5);
                                            }
                                        }
                                    } else {
                                        if ((LA(1) == 157)) {
                                        } else {
                                            zzFAIL(1, zzerr25, &zzMissSet, &zzMissText, &zzBadTok, &zzBadText, &zzErrk);
                                            goto fail;
                                        }
                                    }
                                    zzEXIT(zztasp4);
                                }
                            }
                            zzEXIT(zztasp3);
                        }
                    }
                } else {
                    if ((LA(1) == K_substitute)) {
                        {
                            zzBLOCK(zztasp3);
                            zzMake0;
                            {
                                zzmatch(K_substitute);
                                zzCONSUME;
                                targ = pattern(1);

                                targLine = zzline;
                                {
                                    zzBLOCK(zztasp4);
                                    zzMake0;
                                    {
                                        if ((setwd5[LA(1)] & 0x40)) {
                                            {
                                                zzBLOCK(zztasp5);
                                                zzMake0;
                                                {
                                                    if ((LA(1) == K_by)) {
                                                        zzmatch(K_by);
                                                        zzCONSUME;
                                                    } else {
                                                        if ((LA(1) == K_from)) {
                                                            zzmatch(K_from);
                                                            type = GSUBAlternate;
                                                            zzCONSUME;

                                                        } else {
                                                            zzFAIL(1, zzerr26, &zzMissSet, &zzMissText, &zzBadTok, &zzBadText, &zzErrk);
                                                            goto fail;
                                                        }
                                                    }
                                                    zzEXIT(zztasp5);
                                                }
                                            }
                                            {
                                                zzBLOCK(zztasp5);
                                                zzMake0;
                                                {
                                                    if ((LA(1) == K_NULL)) {
                                                        zzmatch(K_NULL);
                                                        zzCONSUME;
                                                    } else {
                                                        if ((setwd5[LA(1)] & 0x80)) {
                                                            repl = pattern(0);

                                                        } else {
                                                            zzFAIL(1, zzerr27, &zzMissSet, &zzMissText, &zzBadTok, &zzBadText, &zzErrk);
                                                            goto fail;
                                                        }
                                                    }
                                                    zzEXIT(zztasp5);
                                                }
                                            }
                                        } else {
                                            if ((LA(1) == 157)) {
                                            } else {
                                                zzFAIL(1, zzerr28, &zzMissSet, &zzMissText, &zzBadTok, &zzBadText, &zzErrk);
                                                goto fail;
                                            }
                                        }
                                        zzEXIT(zztasp4);
                                    }
                                }
                                addSub(targ, repl, type, targLine);
                                zzEXIT(zztasp3);
                            }
                        }
                    } else {
                        zzFAIL(1, zzerr29, &zzMissSet, &zzMissText, &zzBadTok, &zzBadText, &zzErrk);
                        goto fail;
                    }
                }
                zzEXIT(zztasp2);
            }
        }
        zzEXIT(zztasp1);
        return;
    fail:
        zzEXIT(zztasp1);
        zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
        zzresynch(setwd6, 0x1);
    }
}
void
#ifdef __USE_PROTOS
statement(void)
#else
statement()
#endif
{
    zzRULE;
    zzBLOCK(zztasp1);
    zzMake0;
    {
        {
            zzBLOCK(zztasp2);
            zzMake0;
            {
                if ((LA(1) == K_feature)) {
                    featureUse();
                } else {
                    if ((LA(1) == K_script)) {
                        scriptAssign();
                    } else {
                        if ((LA(1) == K_language)) {
                            languageAssign();
                        } else {
                            if ((LA(1) == K_lookupflag)) {
                                lookupflagAssign();
                            } else {
                                if ((LA(1) == T_GCLASS)) {
                                    glyphClassAssign();
                                } else {
                                    if ((LA(1) == K_ignore)) {
                                        ignoresub_or_pos();
                                    } else {
                                        if ((setwd14[LA(1)] & 0x1)) {
                                            substitute();
                                        } else {
                                            if ((LA(1) == K_markClass)) {
                                                mark_statement();
                                            } else {
                                                if ((setwd14[LA(1)] & 0x2)) {
                                                    position();
                                                } else {
                                                    if ((LA(1) == K_parameters)) {
                                                        parameters();
                                                    } else {
                                                        if ((LA(1) == K_sizemenuname)) {
                                                            sizemenuname();
                                                        } else {
                                                            if ((LA(1) == K_feat_names)) {
                                                                featureNames();
                                                            } else {
                                                                if ((LA(1) == K_subtable)) {
                                                                    subtable();
                                                                } else {
                                                                    if ((LA(1) == 157)) {
                                                                    } else {
                                                                        zzFAIL(1, zzerr69, &zzMissSet, &zzMissText, &zzBadTok, &zzBadText, &zzErrk);
                                                                        goto fail;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                zzEXIT(zztasp2);
            }
        }
        zzmatch(157);
        zzCONSUME;
        zzEXIT(zztasp1);
        return;
    fail:
        zzEXIT(zztasp1);
        zzsyn(zzMissText, zzBadTok, (ANTLRChar *)"", zzMissSet, zzMissTok, zzErrk, zzBadText);
        zzresynch(setwd14, 0x4);
    }
}