Esempio n. 1
0
        public ModelSpecification Parse(ICodeLoader loadingStrategy)
        {
            if (loadingStrategy == null)
                throw new ArgumentNullException();

            loadedCode = loadingStrategy.Load();

            if (loadedCode == null)
                throw new InvalidOperationException("Code must be loaded before it's possible to parse");

            tokensEnumerator = scanner.Scan(loadedCode).GetEnumerator();

            modelSpecification = new ModelSpecification();
            modelSpecification.Code = loadedCode;

            ParseViewModels();

            return modelSpecification;
        }
Esempio n. 2
0
        public HashSet<string> Parse(ICodeLoader loadingStrategy)
        {
            if (loadingStrategy == null) throw new ArgumentNullException();

            var code = string.Format("{0}\n{1}\n@config",
                GenerateConfigDslCode(),
                loadingStrategy.Load());

            Hash result = null;
            try
            {
                result = ParseCode(code);
            }
            catch (MissingMethodException ex)
            {
                throw new InvalidSyntaxException(string.Format("Invalid syntax. {0}", ex.Message), ex);
            }
            catch (SyntaxErrorException ex)
            {
                throw new InvalidSyntaxException(string.Format("INvalid syntax. {0}", ex.Message), ex);
            }

            return ConvertResultToSemanticModel(result);
        }