Esempio n. 1
0
        public static UnboundReferences ParseBimlFiles(IEnumerable<BimlFile> bimlFiles, ISymbolTableProvider astRootNode, LanguageSettings languageSettings)
        {
            var unboundReferences = new UnboundReferences();
            foreach (BimlFile bimlFile in bimlFiles)
            {
                var xdocument = bimlFile.XDocument;
                if (xdocument != null && xdocument.Root != null)
                {
                    try
                    {
                        SideEffectManager.SideEffectMode = AstSideEffectMode.NoSideEffects;
                        ParseDocument(bimlFile, astRootNode, unboundReferences, languageSettings);
                        SideEffectManager.SideEffectMode = AstSideEffectMode.ConsistencySideEffects;

                        bimlFile.IsParseable = true;
                    }
                    catch (Exception)
                    {
                        bimlFile.IsParseable = false;
                    }
                }
            }

            unboundReferences.ResolveAll(astRootNode.SymbolTable);
            return unboundReferences;
        }
Esempio n. 2
0
 public ParserContext(XElement element, IFrameworkItem parentFrameworkItem, ITemplate currentTemplate, BimlFile bimlFile, UnboundReferences unboundReferences, LanguageSettings languageSettings)
 {
     XElement          = element;
     FrameworkItem     = parentFrameworkItem;
     Template          = currentTemplate;
     BimlFile          = bimlFile;
     UnboundReferences = unboundReferences;
     LanguageSettings  = languageSettings;
 }
Esempio n. 3
0
 public ParserContext(XElement element, IFrameworkItem parentFrameworkItem, ITemplate currentTemplate, BimlFile bimlFile, UnboundReferences unboundReferences, LanguageSettings languageSettings)
 {
     XElement = element;
     FrameworkItem = parentFrameworkItem;
     Template = currentTemplate;
     BimlFile = bimlFile;
     UnboundReferences = unboundReferences;
     LanguageSettings = languageSettings;
 }
Esempio n. 4
0
        public IIR Execute(IIR predecessorIR)
        {
            var xmlIR = predecessorIR as XmlIR;
            if (xmlIR == null)
            {
                // Message.Trace(Severity.Error, Resources.ErrorPhaseWorkflowIncorrectInputIRType, PredecessorIR.GetType().ToString(), this.Name);
            }

            var astIR = new AstIR(xmlIR) { AstRootNode = new AstRootNode(null) };

            var unboundReferences = new UnboundReferences();
            var languageSettings = new LanguageSettings(_defaultXmlNamespace, typeof(AstNode));
            foreach (BimlFile bimlFile in astIR.BimlFiles)
            {
                if (bimlFile.XDocument.Root != null)
                {
                    AstParser.ParseDocument(bimlFile, astIR.AstRootNode, unboundReferences, languageSettings);
                }
            }

            unboundReferences.ResolveAll(astIR.AstRootNode.SymbolTable);
            CompileTimeResolver.ResolveAll(astIR.AstRootNode.SymbolTable, unboundReferences);

            if (unboundReferences.Count > 0)
            {
                foreach (var unboundReference in unboundReferences)
                {
                    string filename = unboundReference.BimlFile.Name;
                    string refName = unboundReference.XValue;
                    string refTypeFriendlyName = unboundReference.BoundProperty.PropertyType.Name;
                    string xml = unboundReference.XObject.ToString();
                    int line = ((IXmlLineInfo)unboundReference.XObject).LineNumber;
                    int offset = ((IXmlLineInfo)unboundReference.XObject).LinePosition;
                    var friendlyNames = (FriendlyNameAttribute[])unboundReference.BoundProperty.PropertyType.GetCustomAttributes(typeof(FriendlyNameAttribute), false);
                    if (friendlyNames != null && friendlyNames.Length > 0)
                    {
                        refTypeFriendlyName = friendlyNames[0].FriendlyName;
                    }

                    // TODO: Fatal Error
                    MessageEngine.Trace(filename, line, offset, Severity.Error, "V0101", null, "Could not resolve reference to '{0}' of type '{1}'. '{2}' is invalid.", refName, refTypeFriendlyName, xml);
                }

                throw new InvalidOperationException("Parsing was unsuccessful.");
            }

            return astIR;
        }
Esempio n. 5
0
 public static UnboundReferences ParseElement(XElement element, IFrameworkItem frameworkItem, BimlFile bimlFile, UnboundReferences unboundReferences, LanguageSettings languageSettings)
 {
     frameworkItem.BoundXObject = new XObjectMapping(element, null);
     RecursiveParseElement(new ParserContext(element, frameworkItem, null, bimlFile, unboundReferences, languageSettings));
     return(unboundReferences);
 }
Esempio n. 6
0
 public static UnboundReferences ParseDocument(BimlFile bimlFile, IFrameworkItem frameworkItem, UnboundReferences unboundReferences, LanguageSettings languageSettings)
 {
     RecursiveParseElement(new ParserContext(bimlFile.XDocument.Root, frameworkItem, null, bimlFile, unboundReferences, languageSettings));
     return(unboundReferences);
 }
Esempio n. 7
0
        public static UnboundReferences ParseBimlFiles(IEnumerable <BimlFile> bimlFiles, ISymbolTableProvider astRootNode, LanguageSettings languageSettings)
        {
            var unboundReferences = new UnboundReferences();

            foreach (BimlFile bimlFile in bimlFiles)
            {
                var xdocument = bimlFile.XDocument;
                if (xdocument != null && xdocument.Root != null)
                {
                    try
                    {
                        SideEffectManager.SideEffectMode = AstSideEffectMode.NoSideEffects;
                        ParseDocument(bimlFile, astRootNode, unboundReferences, languageSettings);
                        SideEffectManager.SideEffectMode = AstSideEffectMode.ConsistencySideEffects;

                        bimlFile.IsParseable = true;
                    }
                    catch (Exception)
                    {
                        bimlFile.IsParseable = false;
                    }
                }
            }

            unboundReferences.ResolveAll(astRootNode.SymbolTable);
            return(unboundReferences);
        }
Esempio n. 8
0
 public static UnboundReferences ParseElement(XElement element, IFrameworkItem frameworkItem, BimlFile bimlFile, UnboundReferences unboundReferences, LanguageSettings languageSettings)
 {
     frameworkItem.BoundXObject = new XObjectMapping(element, null);
     RecursiveParseElement(new ParserContext(element, frameworkItem, null, bimlFile, unboundReferences, languageSettings));
     return unboundReferences;
 }
Esempio n. 9
0
 public static UnboundReferences ParseDocument(BimlFile bimlFile, IFrameworkItem frameworkItem, UnboundReferences unboundReferences, LanguageSettings languageSettings)
 {
     RecursiveParseElement(new ParserContext(bimlFile.XDocument.Root, frameworkItem, null, bimlFile, unboundReferences, languageSettings));
     return unboundReferences;
 }