lib/pione/transformer/rule-definition-transformer.rb in pione-0.1.3 vs lib/pione/transformer/rule-definition-transformer.rb in pione-0.1.4

- old
+ new

@@ -16,43 +16,55 @@ :rule_conditions => sequence(:conditions), :block => simple(:block) }) { inputs = Naming::InputLine.values(conditions) outputs = Naming::OutputLine.values(conditions) params = Parameters.merge(*Naming::ParamLine.values(conditions)) - features = Feature::AndExpr.new(*Naming::FeatureLine.values(conditions)) - condition = RuleCondition.new(inputs, outputs, params, features, TicketExpr.empty, TicketExpr.empty) + features = Feature.empty if Naming::FeatureLine.values(conditions).empty? + features = Feature::AndExpr.new(*Naming::FeatureLine.values(conditions)) unless features + constraints = Constraints.new(Naming::ConstraintLine.values(conditions)) + condition = RuleCondition.new(inputs, outputs, params: params, features: features, constraints: constraints) case block when ActionBlock ActionRule when FlowBlock FlowRule + when EmptyBlock + EmptyRule end.new(rule_expr, condition, block) } # Transform +:input_line+ as Naming::InputLine. rule(:input_line => simple(:data_expr)) { TypeDataExpr.check(data_expr) Naming.InputLine(data_expr) } - # Transform +:output_line+ as Naming::OutputLine. + # Transform +output_line+ as Naming::OutputLine. rule(:output_line => simple(:data_expr)) { TypeDataExpr.check(data_expr) Naming.OutputLine(data_expr) } - # Transform +:param_line+ as Naming::ParamLine. + # Transform +param_line+ as Naming::ParamLine. rule(:param_line => simple(:param)) { - unless TypeAssignment.match(param) or TypeParameters.match(param) + unless TypeAssignment.match(param) or TypeParameters.match(param) or param.kind_of?(Variable) raise PioneModelTypeError.new(param, TypeAssignment) end Naming.ParamLine(param) } # Transform +:feature_line+ as Naming::FeatureLine. rule(:feature_line => simple(:feature)) { TypeFeature.check(feature) Naming.FeatureLine(feature) + } + + rule(:constraint_line => simple(:constraint)) { + Naming.ConstraintLine(constraint) + } + + rule(:annotation_line => simple(:expr)) { + Naming.AnnotationLine(expr) } end end end