示例#1
0
        private void ParseAndCaptureErrors()
        {
            var dslParser = new DslParser(tokenizer, new Lazy <DslSyntax>(() => rhetosProjectContext.DslSyntax), rhetosLogProvider);

            try
            {
                dslParser.OnKeyword       += OnKeyword;
                dslParser.OnMemberRead    += OnMemberRead;
                dslParser.OnUpdateContext += OnUpdateContext;
                _ = dslParser.GetConcepts().ToList();
            }
            catch (DslSyntaxException e)
            {
                result.DslParserErrors.Add(CreateAnalysisError(e));
            }
            catch (Exception e)
            {
                result.DslParserErrors.Add(new CodeAnalysisError {
                    Message = e.ToString()
                });
            }
            finally
            {
                dslParser.OnKeyword       -= OnKeyword;
                dslParser.OnMemberRead    -= OnMemberRead;
                dslParser.OnUpdateContext -= OnUpdateContext;
            }
        }
示例#2
0
        private static IEnumerable <ConceptSyntaxNode> DslParserParse(string[] dslScripts, Type[] conceptTypes)
        {
            var dslParser = new DslParser(
                new TestTokenizer(dslScripts),
                new Lazy <DslSyntax>(() => DslSyntaxHelper.CreateDslSyntax(conceptTypes)),
                new ConsoleLogProvider());
            var parsedConcepts = dslParser.GetConcepts();

            Console.WriteLine("Parsed concepts: " + string.Join("\r\n", parsedConcepts.Select(c => c.Concept.TypeName)));
            return(parsedConcepts);
        }
        static List <IConceptInfo> DslModelFromScript(string dsl, IConceptInfo[] conceptInfoPluginsForGenericParser)
        {
            var nullDslParser = new DslParser(
                new TestTokenizer(dsl),
                new Lazy <DslSyntax>(() => DslSyntaxHelper.CreateDslSyntax(conceptInfoPluginsForGenericParser)),
                new ConsoleLogProvider());

            Console.WriteLine("Parsed concepts:");
            Console.WriteLine(string.Join(Environment.NewLine, nullDslParser.GetConcepts().Select(ci => " - " + ci.GetUserDescription())));

            var dslModel = NewDslModel(nullDslParser, conceptInfoPluginsForGenericParser);

            return(dslModel.Concepts.ToList());
        }