module Fop::Compiler
Public Class Methods
compile(src)
click to toggle source
# File lib/fop/compiler.rb, line 5 def self.compile(src) parser = Parser.new(src) nodes, errors = parser.parse instructions = nodes.map { |node| case node when Nodes::Text, Nodes::Regex Instructions.regex_match(node.regex) when Nodes::Expression arg_error = Validations.validate_args(node) errors << arg_error if arg_error Instructions::ExpressionMatch.new(node) else raise "Unknown node type #{node}" end } return nil, errors if errors.any? return instructions, nil end