OLD | NEW |
1 package parser | 1 package parser |
2 | 2 |
3 import ( | 3 import ( |
4 "fmt" | 4 "fmt" |
5 | 5 |
6 "skia.googlesource.com/buildbot.git/perf/go/types" | 6 "skia.googlesource.com/buildbot.git/perf/go/types" |
7 ) | 7 ) |
8 | 8 |
9 type NodeType int | 9 type NodeType int |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 // NewContext create a new parsing context that includes the basic functions. | 64 // NewContext create a new parsing context that includes the basic functions. |
65 func NewContext(tile *types.Tile) *Context { | 65 func NewContext(tile *types.Tile) *Context { |
66 return &Context{ | 66 return &Context{ |
67 Tile: tile, | 67 Tile: tile, |
68 Funcs: map[string]Func{ | 68 Funcs: map[string]Func{ |
69 "filter": filterFunc, | 69 "filter": filterFunc, |
70 "norm": normFunc, | 70 "norm": normFunc, |
71 "fill": fillFunc, | 71 "fill": fillFunc, |
72 "ave": aveFunc, | 72 "ave": aveFunc, |
| 73 "ratio": ratioFunc, |
73 }, | 74 }, |
74 } | 75 } |
75 } | 76 } |
76 | 77 |
77 // Eval parses and evaluates the given string expression and returns the Traces,
or | 78 // Eval parses and evaluates the given string expression and returns the Traces,
or |
78 // an error. | 79 // an error. |
79 func (ctx *Context) Eval(exp string) ([]*types.PerfTrace, error) { | 80 func (ctx *Context) Eval(exp string) ([]*types.PerfTrace, error) { |
80 ctx.formula = exp | 81 ctx.formula = exp |
81 n, err := parse(exp) | 82 n, err := parse(exp) |
82 if err != nil { | 83 if err != nil { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 l.nextItem() | 154 l.nextItem() |
154 continue | 155 continue |
155 case itemRParen: | 156 case itemRParen: |
156 break Loop | 157 break Loop |
157 default: | 158 default: |
158 return fmt.Errorf("Invalid token in args: %d", it.typ) | 159 return fmt.Errorf("Invalid token in args: %d", it.typ) |
159 } | 160 } |
160 } | 161 } |
161 return nil | 162 return nil |
162 } | 163 } |
OLD | NEW |