For the preliminary implementation, a pattern is an expression, with some wildcards.
Wildcards are valid identifiers starting by one underscore.
For instance, _a + _b*_a is supposed to match p + b*p but not p + b*c.
We can use that to define the elements of syntax that we want, for instance to define _x[_inds](_t) as the generic form of a timed and index variable (like v_{i,t+1})
There is a crude python implementation in https://github.com/EconForge/dolang/blob/master/dolang/pattern.py.
Some questions:
- are there available libraries which do it efficiently ?
- we probably want to "type" the wildcard so that, in the above example,
_t could stand for a signed integer and _inds would be expected to be a list of indices
- would we be better of by defining the expression parser ourselve instead of operating on the syntax tree ?
For the preliminary implementation, a pattern is an expression, with some wildcards.
Wildcards are valid identifiers starting by one underscore.
For instance,
_a + _b*_ais supposed to matchp + b*pbut notp + b*c.We can use that to define the elements of syntax that we want, for instance to define
_x[_inds](_t)as the generic form of a timed and index variable (likev_{i,t+1})There is a crude python implementation in https://github.com/EconForge/dolang/blob/master/dolang/pattern.py.
Some questions:
_tcould stand for a signed integer and_indswould be expected to be a list of indices