Abstract : We develop a non-anticipative calculus for functionals of a continuous semimartingale, using an extension of the Ito formula to path-dependent functionals which possess certain directional derivatives. The construction is based on a pathwise derivative, introduced by B Dupire, for functionals on the space of right-continuous functions with left limits. We show that this functional derivative admits a suitable extension to the space of square-integrable martingales. This extension defines a weak derivative which is shown to be the inverse of the Ito integral and which may be viewed as a non-anticipative ''lifting" of the Malliavin derivative. These results lead to a constructive martingale representation formula for Ito processes. By contrast with the Clark-Haussmann-Ocone formula, this representation only involves non-anticipative quantities which may be computed pathwise.