コード例 #1
0
ファイル: Preprocessor.cs プロジェクト: Paul1nh0/Singularity
    protected override bool _moveNext()
    {
        while (iee.MoveNext())
        {
            bool val;

            if (iee.Current.tag != "PREPROC")
            {
                if (conditional)
                {
                    iee.Current.coord.line += linedelta;
                    if (file != null)
                    {
                        iee.Current.coord.file = file;
                    }
                    return(true);
                }
                continue;
            }
            tokenize(iee.Current);

            bool status = tokens.MoveNext();
            switch (tokens.Current.tag)
            {
            default:
                error("unknown preprocessor command: " + tokens.Current.tag);
                break;

            case "define":
                doDefine();
                break;

            case "undef":
                doUndef();
                break;

            case "line":
                doLine();
                break;

            case "error":
                doError();
                break;

            case "warning":
                doWarning();
                break;

            case "region":
                subordinate = new RegionEnumerator(table, iee, emitting && conditional);
                if (subordinate.MoveNext())
                {
                    return(true);
                }
                subordinate = null;
                continue;

            case "endregion":
                error("unexpected #endregion");
                break;

            case "pragma":
                doPragma();
                break;

            case "if":
                val         = eval();
                subordinate = new IfEnumerator(table, iee, emitting && conditional, val);
                if (subordinate.MoveNext())
                {
                    return(true);
                }
                subordinate = null;
                continue;

            case "elif":
                val          = eval();
                conditional  = val && !condHistory;
                condHistory |= conditional;
                break;

            case "else":
                conditional = !condHistory;
                condHistory = true;
                continue;

            case "endif":
                return(false);
            }
        }
        error("unfinished #if");
        return(false);
    }
コード例 #2
0
ファイル: Preprocessor.cs プロジェクト: Paul1nh0/Singularity
    protected override bool _moveNext()
    {
        System.Diagnostics.Trace.Assert(emitting);
        while (iee.MoveNext())
        {
            if (iee.Current.tag != "PREPROC")
            {
                iee.Current.coord.line += linedelta;
                if (file != null)
                {
                    iee.Current.coord.file = file;
                }
                return(true);
            }
            tokenize(iee.Current);
            bool status = tokens.MoveNext();
            switch (tokens.Current.tag)
            {
            default:
                error("unknown preprocessor command: " + tokens.Current.tag);
                break;

            case "define":
                doDefine();
                break;

            case "undef":
                doUndef();
                break;

            case "line":
                doLine();
                break;

            case "error":
                doError();
                break;

            case "warning":
                doWarning();
                break;

            case "region":
                subordinate = new RegionEnumerator(table, iee, emitting);
                if (subordinate.MoveNext())
                {
                    return(true);
                }
                subordinate = null;
                continue;

            case "endregion":
                error("unexpected #endregion");
                break;

            case "pragma":
                doPragma();
                break;

            case "if":
                bool val = eval();
                subordinate = new IfEnumerator(table, iee, emitting, val);
                if (subordinate.MoveNext())
                {
                    return(true);
                }
                subordinate = null;
                continue;

            case "elif":
                error("unexpected #elif");
                break;

            case "else":
                error("unexpected #else");
                break;

            case "endif":
                error("unexpected #endif");
                break;
            }
        }
        return(false);
    }