To understand the source code, let's first re-visit the syntax of `pdetoode`. 

    pdetoode[u[variables], t, grid, differenceorder, periodic]
    pdetoode[{u, v, …}[variables], t, {grid1, grid2, …}, differenceorder, periodic]
    pdetoode[{u[variables], v[variables], …}, t, {grid1, grid2, …}, differenceorder, periodic]


As mentioned [there](https://mathematica.stackexchange.com/a/127997/1871):

> The syntax of `pdetoode` is as follows: 1st argument is the function
> to be discretized (which can be a list i.e. `pdetoode` can handle PDE system), 2nd argument is the independent variable in the
> resulting ODE system (usually it's the variable playing the role of
> "time" in the underlying model), 3rd argument is the list of
> spatial grid, 4th argument is difference order, 5th argument is to determine whether periodic b.c. should be set or not. (5th argument is optional, the default setting is `False`. )

<strike>Well, sometimes I feel that this syntax is a design miss, perhaps I should have made the syntax more simlar with `NDSolve`. </strike> We know, method of lines is a method that discretizes PDE(s) to a system of ODEs i.e. we need to discretize all the independent variables except for `t` (to be more precise, the independent variable of the resulting ODEs). For example, if the original dependent variable is `u[x, t, y]`, it'll eventually be transformed to something like `u[x, y][t]`; if it's `Derivative[1, 1, 1][u][x, t, y]`, it's transformed to something like `fdd[{1, 1}, {gridx, gridy}, Outer[{x, y}|->u[x, y]'[t], gridx, gridy], …]`.

To automate the process, it's clear we need to know the **pos**ition of `t`. This is programmatically detected by 

    pos = Position[{var}, time][[1, 1]]

We also need to extract `x`, `y`, etc., because we need to determine whether we are discretizing b.c. or not (`pdetoode` can directly handle b.c. by design!), and this is done by

    pat = Repeated[_, {pos - 1}]

Hope now it is a bit clearer.