Example #1
0
        public static object Convert(SyntaxNode node)
        {
            var parser = new PapEvalCodeParser();

            parser.Visit(node);

            var result = parser.Result;

            if (result == null)
            {
                throw new InvalidPapException("Ausdruck ergab kein Resultat");
            }

            return(result);
        }
Example #2
0
        private void GenerateConstants(ModuleBuilder target, IEnumerable <PapConstant> constants)
        {
            foreach (var constant in constants)
            {
                var valueExpression = PapEvalCodeParser.ConvertToExpression(constant.Value);
                var type            = TypeMapping.Map(constant.Type);

                target.Constants.Add(new ConstantBuilder(Visibilities.Private,
                                                         type,
                                                         constant.Name,
                                                         type.CanBeCompileTimeConstant,
                                                         valueExpression)
                {
                    Summary = constant.Documentation
                });
            }
        }
Example #3
0
        private void GenerateProperties(ModuleBuilder target,
                                        Visibilities defaultVisibility,
                                        IEnumerable <PapVariable> variables)
        {
            foreach (var variable in variables)
            {
                var defaultValueExpression = variable.Default != null
                    ? PapEvalCodeParser.ConvertToExpression(variable.Default)
                    : null;

                target.Properties.Add(new AutoPropertyBuilder(defaultVisibility,
                                                              TypeMapping.Map(variable.Type),
                                                              variable.Name,
                                                              defaultValueExpression)
                {
                    Summary = variable.Documentation
                });
            }
        }
Example #4
0
 public override StatementBuilder VisitEval(PapSyntaxTreeNodeEval node)
 {
     return(PapEvalCodeParser.ConvertToStatement(node.Expression));
 }
Example #5
0
 public override StatementBuilder VisitIf(PapSyntaxTreeNodeIf node)
 {
     return(new IfStatementBuilder(PapEvalCodeParser.ConvertToExpression(node.Condition),
                                   Visit(node.ThenStatements),
                                   node.ElseStatements != null ? Visit(node.ElseStatements) : null));
 }