コード例 #1
0
    public static bool ReadLines(object context, TextReader reader, LineParserDelegate parser, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(0)] ref      // ERROR: Optional parameters aren't supported in C#
                                 int lineNumber)
    {
        string line = reader.ReadLine();

        while (line != null)
        {
            line        = line.Trim(' ', '\x09');
            lineNumber += 1;
            if (line.StartsWith("/*"))
            {
                int startingLine = lineNumber;
                while (line != null && !line.EndsWith("*/"))
                {
                    line        = reader.ReadLine();
                    lineNumber += 1;
                }
                if (line == null)
                {
                    throw new ApplicationException(string.Format("Line {0}: Block comment not closed correctly.", startingLine));
                }
            }
            else if (line.StartsWith("//"))
            {
            }
            // Ignore single line comments.
            else if (!parser.Invoke(context, reader, line.Trim(' ', '\x09'), ref lineNumber))
            {
                return(false);
            }
            line = reader.ReadLine();
        }

        return(true);
    }
コード例 #2
0
        public static bool ReadLines(object context, TextReader reader, LineParserDelegate parser, ref int lineNumber)
        {
            string line = reader.ReadLine();

            while (line != null)
            {
                line        = line.Trim(' ', '\x09');
                lineNumber += 1;
                if (line.StartsWith("/*"))
                {
                    int startingLine = lineNumber;
                    while (line != null && !line.EndsWith("*/"))
                    {
                        line        = reader.ReadLine();
                        lineNumber += 1;
                    }
                    if (line == null)
                    {
                        throw new ApplicationException(string.Format("Line {0}: Block comment not closed correctly.", startingLine));
                    }
                }
                else if (line.StartsWith("//"))
                {
                }
                // Ignore single line comments.
                else if (!parser.Invoke(context, reader, line.Trim(' ', '\x09'), ref lineNumber))
                {
                    return(false);
                }
                line = reader.ReadLine();
            }

            return(true);
        }
コード例 #3
0
        public static bool ReadLines(object context, TextReader reader, LineParserDelegate parser, ref int lineNumber)
        {
            string line = reader.ReadLine();
            while (line != null) {
                line = line.Trim(' ', '\x09');
                lineNumber += 1;
                if (line.StartsWith("/*")) {
                    int startingLine = lineNumber;
                    while (line != null && !line.EndsWith("*/")) {
                        line = reader.ReadLine();
                        lineNumber += 1;
                    }
                    if (line == null) {
                        throw new ApplicationException(string.Format("Line {0}: Block comment not closed correctly.", startingLine));
                    }
                }
                else if (line.StartsWith("//")) {
                }
                // Ignore single line comments.
                else if (!parser.Invoke(context, reader, line.Trim(' ', '\x09'), ref lineNumber)) {
                    return false;
                }
                line = reader.ReadLine();
            }

            return true;
        }
コード例 #4
0
    public static bool ReadLines(object context, TextReader reader, LineParserDelegate parser, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(0)] ref  // ERROR: Optional parameters aren't supported in C#
int lineNumber)
    {
        string line = reader.ReadLine();
        while (line != null) {
            line = line.Trim(' ', '\x09');
            lineNumber += 1;
            if (line.StartsWith("/*")) {
                int startingLine = lineNumber;
                while (line != null && !line.EndsWith("*/")) {
                    line = reader.ReadLine();
                    lineNumber += 1;
                }
                if (line == null) {
                    throw new ApplicationException(string.Format("Line {0}: Block comment not closed correctly.", startingLine));
                }
            }
            else if (line.StartsWith("//")) {
            }
            // Ignore single line comments.
            else if (!parser.Invoke(context, reader, line.Trim(' ', '\x09'), ref lineNumber)) {
                return false;
            }
            line = reader.ReadLine();
        }

        return true;
    }