Example #1
0
        private PreprocessorLine DoIf(PreprocessorIfLine ifLine)
        {
            PreprocessorLine line;

            if (ifLine.Value)
            {
                line = LexBlock();
                switch (line.Type)
                {
                case PreprocessorTokenType.Endif:
                    line = null;
                    break;

                case PreprocessorTokenType.Elif:
                    line = SkipElifBlock();
                    break;

                case PreprocessorTokenType.Else:
                    line = SkipElseBlock();
                    break;

                case PreprocessorTokenType.EndOfLine:
                    ReportError(PreprocessorError.UnexpectedEndOfFile);
                    break;

                case PreprocessorTokenType.EndRegion:
                default:
                    ReportError(PreprocessorError.UnexpectedDirective);
                    break;
                }
            }
            else
            {
                line = SkipBlock();
                switch (line.Type)
                {
                case PreprocessorTokenType.Else:
                    line = DoElse();
                    break;

                case PreprocessorTokenType.Elif:
                    return(DoIf((PreprocessorIfLine)line));

                case PreprocessorTokenType.Endif:
                    line = null;
                    break;

                case PreprocessorTokenType.EndOfLine:
                    ReportError(PreprocessorError.UnexpectedEndOfFile);
                    break;

                case PreprocessorTokenType.EndRegion:
                default:
                    ReportError(PreprocessorError.UnexpectedDirective);
                    break;
                }
            }

            return(line);
        }
Example #2
0
        private PreprocessorLine DoIf(PreprocessorIfLine ifLine) {
            PreprocessorLine line;

            if (ifLine.Value) {
                line = LexBlock();
                switch (line.Type) {
                    case PreprocessorTokenType.Endif:
                        line = null;
                        break;
                    case PreprocessorTokenType.Elif:
                        line = SkipElifBlock();
                        break;

                    case PreprocessorTokenType.Else:
                        line = SkipElseBlock();
                        break;

                    case PreprocessorTokenType.EndOfLine:
                        ReportError(PreprocessorError.UnexpectedEndOfFile);
                        break;

                    case PreprocessorTokenType.EndRegion:
                    default:
                        ReportError(PreprocessorError.UnexpectedDirective);
                        break;
                }
            }
            else {
                line = SkipBlock();
                switch (line.Type) {
                    case PreprocessorTokenType.Else:
                        line = DoElse();
                        break;

                    case PreprocessorTokenType.Elif:
                        return DoIf((PreprocessorIfLine)line);

                    case PreprocessorTokenType.Endif:
                        line = null;
                        break;

                    case PreprocessorTokenType.EndOfLine:
                        ReportError(PreprocessorError.UnexpectedEndOfFile);
                        break;

                    case PreprocessorTokenType.EndRegion:
                    default:
                        ReportError(PreprocessorError.UnexpectedDirective);
                        break;
                }
            }

            return line;
        }