Пример #1
0
        /// <summary>
        /// Will parse the wiki content pushing scopes into the parse handler.
        /// </summary>
        /// <param name="wikiContent">The wiki content.</param>
        /// <param name="macros">The macros to use for parsing.</param>
        /// <param name="scopeAugmenters">The scope augmenters to use for parsing.</param>
        /// <param name="parseHandler">The action method that is used for pushing parsed scopes.</param>
        /// <exception cref="ArgumentNullException">
        /// Thrown when macros is null.
        ///
        /// -- or --
        ///
        /// Thrown when scope augmenters is null.
        /// </exception>
        /// <exception cref="ArgumentException">Thrown when macros is empty.</exception>
        public virtual void Parse(string wikiContent, IEnumerable <IMacro> macros, IDictionary <string, IScopeAugmenter> scopeAugmenters, Action <IList <Scope> > parseHandler)
        {
            if (string.IsNullOrEmpty(wikiContent))
            {
                return;
            }

            Guard.NotNullOrEmpty(macros, "macros");
            Guard.NotNull(scopeAugmenters, "scopeAugmenters");

            foreach (IMacro macro in macros)
            {
                Parse(wikiContent, macro, compiler.Compile(macro), scopeAugmenters.FindByMacro(macro), parseHandler);
            }
        }
Пример #2
0
    private void Compile()
    {
        MacroCompiler             compiler = new MacroCompiler(this);
        SimpleMacroCompilerSource asset    = new SimpleMacroCompilerSource(m_Asset.text);
        MacroCompilerResult       result   = compiler.Compile(asset);

        m_Bank = result.Bank;
        foreach (var unknown in result.UnrecognizedMacros)
        {
            Debug.LogWarning("Unknown macro " + unknown);
        }
        foreach (var unknown in result.UnrecognizedMacroIds)
        {
            Debug.LogWarning("Unknown macro id " + unknown);
        }
        foreach (var exported in result.MacroNames)
        {
            Debug.Log("Exported macro " + exported);
        }
        Debug.Log("Reused strings: " + result.ReusedStrings);
    }