コード例 #1
0
        /// <summary>
        ///     Preprocesses, Lexes and Parses a C# compilation unit. Subscribe to the OnError
        ///     event before calling this method to receive error notifications.
        ///     After calling Parse, the Defines property contains the list of preprocessor
        ///     symbols defined as a result of #define and #undef directives in this
        ///     compilation unit.
        /// </summary>
        public CompilationUnitNode Parse(Token[] tokens, LineMap lineMap)
        {
            this.lineMap = lineMap;
            CompilationUnitNode parseTree = parser.Parse(tokens);

            this.lineMap = null;

            return(parseTree);
        }
コード例 #2
0
        /// <summary>
        ///     Lexes a compilation unit.
        /// </summary>
        /// <param name="text"> The text to lex. </param>
        /// <param name="defines">
        ///     The set of preprocessor symbols defined in source.
        ///     Is modified to include results of #define/#undef found in this compilation unit.
        /// </param>
        /// <param name="lineMap">
        ///     The LineMap contains the source text to file/line mapping
        ///     as a result of #line directives.
        /// </param>
        /// <param name="includeComments"> Should comment tokens be generated. </param>
        /// <returns></returns>
        public Token[] Lex(char[] text, IDictionary defines, LineMap lineMap, bool includeComments)
        {
            // initialize
            this.text            = new TextBuffer(text);
            this.defines         = defines;
            this.lineMap         = lineMap;
            this.includeComments = includeComments;

            LexFile();

            this.text            = null;
            this.defines         = null;
            this.lineMap         = null;
            this.includeComments = false;

            return((Token[])tokens.ToArray(typeof(Token)));
        }