/// <summary>
        /// Semantically parses the specified <see cref="TextRange"/> of the <see cref="Document"/>.
        /// </summary>
        /// <param name="document">The <see cref="Document"/> to examine.</param>
        /// <param name="parseTextRange">A <see cref="TextRange"/> indicating the offset range to parse.</param>
        /// <param name="flags">A <see cref="SemanticParseFlags"/> that indicates semantic parse flags.</param>
        public override void PerformSemanticParse(Document document, TextRange parseTextRange, SemanticParseFlags flags)
        {
            if (null == document.Filename)
            {
                throw new Exception("Document Filename must be set");
            }

            string source   = document.GetCoreTextBuffer().ToString();
            string filename = System.IO.Path.GetFullPath(document.Filename); // Normalise the path;

            // Remove any pending SemanticParse tasks for this document
            object key = new KeyValuePair <Document, object>(document, m_performSemanticParseKey);

            m_plugin.TaskQueue.RemoveTasks(key);

            // Queue a SemanticParse task for this document
            m_plugin.TaskQueue.AddTask(() =>
            {
                var textBufferReader = new StringTextBufferReader(source, 0, 0);
                var cu = MergableLexicalParserManager.PerformSemanticParse(this, textBufferReader, filename) as CompilationUnit;
                if (null != cu)
                {
                    cu.SourceKey = filename;
                    cu.Source    = source;
                    m_plugin.Database.ProcessSynchronous(cu);
                    document.SemanticParseData = cu;
                }
            }, TaskQueue.Thread.Worker, key);
        }
        /// <summary>
        /// Semantically parses the text in the <see cref="MergableLexicalParserManager"/>.
        /// </summary>
        /// <param name="manager">The <see cref="MergableLexicalParserManager"/> that is managing the mergable language and the text to parse.</param>
        /// <returns>An object that contains the results of the semantic parsing operation.</returns>
        protected override object PerformSemanticParse(MergableLexicalParserManager manager)
        {
            var lexicalParser = new LuatRecursiveDescentLexicalParser(this, manager);

            lexicalParser.InitializeTokens();

            var semanticParser = new LuatSemanticParser(lexicalParser);

            semanticParser.Parse();

            return(semanticParser.CompilationUnit);
        }
Exemple #3
0
        /// <summary>
        /// Semantically parses the text in the <see cref="MergableLexicalParserManager"/>.
        /// </summary>
        /// <param name="manager">The <see cref="MergableLexicalParserManager"/> that is managing the mergable language and the text to parse.</param>
        /// <returns>An object that contains the results of the semantic parsing operation.</returns>
        protected override object PerformSemanticParse(MergableLexicalParserManager manager)
        {
            var lexicalParser = new LuatRecursiveDescentLexicalParser(this, manager);
            lexicalParser.InitializeTokens();

            var semanticParser = new LuatSemanticParser(lexicalParser);
            semanticParser.Parse();

            return semanticParser.CompilationUnit;
        }
Exemple #4
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <c>LuatRecursiveDescentLexicalParser</c> class.
        /// </summary>
        /// <param name="language">The <see cref="SimpleSyntaxLanguage"/> to use.</param>
        /// <param name="manager">The <see cref="MergableLexicalParserManager"/> to use for coordinating merged languages.</param>
        public LuatRecursiveDescentLexicalParser(LuatSyntaxLanguage language, MergableLexicalParserManager manager) : base(language, manager)
        {
        }
		/////////////////////////////////////////////////////////////////////////////////////////////////////
		// OBJECT
		/////////////////////////////////////////////////////////////////////////////////////////////////////

		/// <summary>
		/// Initializes a new instance of the <c>LuatRecursiveDescentLexicalParser</c> class.
		/// </summary>
		/// <param name="language">The <see cref="SimpleSyntaxLanguage"/> to use.</param>
		/// <param name="manager">The <see cref="MergableLexicalParserManager"/> to use for coordinating merged languages.</param>
		public LuatRecursiveDescentLexicalParser(LuatSyntaxLanguage language, MergableLexicalParserManager manager) : base(language, manager) {}