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); }
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 }); } }
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 }); } }
public override StatementBuilder VisitEval(PapSyntaxTreeNodeEval node) { return(PapEvalCodeParser.ConvertToStatement(node.Expression)); }
public override StatementBuilder VisitIf(PapSyntaxTreeNodeIf node) { return(new IfStatementBuilder(PapEvalCodeParser.ConvertToExpression(node.Condition), Visit(node.ThenStatements), node.ElseStatements != null ? Visit(node.ElseStatements) : null)); }