Example #1
0
        private ParsingResult ParseAndProcess(string text)
        {
            var parsed = parser.Parse(text);

            try {
                processor.Process(parsed.Root, new ProcessingOptions(ProcessingStages));
            }
            catch {
                // here lies the evil
                // temporary, until good error reporting is implemented in processor steps
            }

            return(parsed);
        }
Example #2
0
        public static void IsParsedTo(string code, string expectedResult, bool includeExpressionType = false, bool parenthiseAll = false)
        {
            var parser = new LightParser();
            var result = parser.Parse(code);

            AssertEx.That(() => !result.HasErrors);

            var resultString = new AstToCodeTransformer {
                UseParenthesesInAllExpressions = parenthiseAll
            }.Transform(result.Root);
            var resultExpression = result.Root as IAstExpression;

            if (resultExpression != null && includeExpressionType)
            {
                resultString = resultString + ": " + new TypeFormatter(new BuiltInTypeMap()).Format(resultExpression.ExpressionType);
            }

            Assert.AreEqual(expectedResult, resultString);
        }