mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
DataFilter Grammar for [index]
.. expressions like a+b*c[n] were being parsed as equivalent to (a+b*c)[n] instead of a+b+(c[n]). .. to resolve this symbol[index] is declared first in the grammar and whilst it will introduce reduce/reduce warnings that is actually what we want (we declare it early to override the definition from expr below). .. keener yacc wizards might have a more elegant solution for this one....
This commit is contained in:
@@ -2705,6 +2705,7 @@ Result Leaf::eval(DataFilterRuntime *df, Leaf *leaf, float x, long it, RideItem
|
||||
returning.vector[1]=calc.b;
|
||||
returning.vector[2]=calc.r2;
|
||||
returning.vector[3]=calc.see;
|
||||
returning.number = calc.m + calc.b + calc.r2 + calc.see; // sum
|
||||
|
||||
return returning;
|
||||
}
|
||||
|
||||
@@ -297,7 +297,17 @@ lexpr:
|
||||
}
|
||||
;
|
||||
|
||||
array: expr '[' expr ']' {
|
||||
array:
|
||||
symbol '[' expr ']' { // reduce/reduce conflict, but added here so gets resolved
|
||||
// first (order appeared in this file.
|
||||
// e.g. a+b[1] is resolved as a+(b[1]) rather than (a+b)[1]
|
||||
$$ = new Leaf(@1.first_column, @4.last_column);
|
||||
$$->type = Leaf::Index;
|
||||
$$->lvalue.l = $1;
|
||||
$$->fparms << $3;
|
||||
$$->op = 0;
|
||||
}
|
||||
| expr '[' expr ']' {
|
||||
$$ = new Leaf(@1.first_column, @4.last_column);
|
||||
$$->type = Leaf::Index;
|
||||
$$->lvalue.l = $1;
|
||||
|
||||
Reference in New Issue
Block a user