Re:Puffs: Parsing Untrusted File Formats Safely
by evincarofautumn on Thursday November 16, 2017 @11:16AM
(#15713815)
One way to do it would be to have a default associativity between different operators, but chains of the same operator can override it, e.g. suppose “⧺” means concatenation (rightward), “×” means repetition (leftward), and the default is leftward:
[1, 2] ⧺ [3, 4] ⧺ [5, 6] × 2 × 3
(([1, 2] ⧺ ([3, 4] ⧺ [5, 6])) × 2) × 3
[ [ [1…6], [1…6] ],
[ [1…6], [1…6] ],
[ [1…6], [1…6] ] ]
I dunno how good an idea that would be in practice, though.
Re:Puffs: Parsing Untrusted File Formats Safely
by klodolph on Thursday November 16, 2017 @11:06AM
(#15713738)
Think exponentiation, where 2^3^4 might be 2^(3^4), but where subtraction 2-3-4 is (2-3)-4.
Re:Puffs: Parsing Untrusted File Formats Safely
by mnarayan01 on Thursday November 16, 2017 @11:13AM
(#15713791)
Consider:
2-3^4
Re:Puffs: Parsing Untrusted File Formats Safely
by irishsultan on Thursday November 16, 2017 @12:18PM
(#15714470)
Since there is no precedence in this (hypothetical) language that would be an invalid expression.
That… is true, and I have a hard time computing how it would even work.