module Harby

module Grammar
        grammar Arguments
                include Command
                include List
                include Numeric
                include Regex
                include String

                rule arguments
                        ' '* first_arg:argument rest_args:(' '+ arg:argument)* ' '* {
                                def args
                                        [first_arg] + rest_args
                                end

                                def parsed_args
                                        @parsed_args ||= args.map { |arg| arg.parsed_value }
                                end

                                def rest_args
                                        super.elements.map { |space_and_arg| space_and_arg.arg }
                                end
                        }
                end

                rule argument
                        command / list / numeric / regex / string
                end
        end
end

end