Closed d4tocchini closed 10 years ago
:+1:
I started looking into this, went to write a spec first, and saw this comment:
This should probably be handled with a preparser or optimizer, not the main PEG grammar
I think we're saying that a preparser would transform:
#box1[size] == #box2[size]
into:
#box1[width] == #box2[width]
#box1[height] == #box2[height]
We'd need a good strategy for not duplicating a lot of code between the two grammars since they'd both need the same rules. I've asked about this here: dmajda/pegjs#268
That comment now seems too certain. Your point about duplicating parser rules hold weight. Probably best this is done within the CCSS grammar anyway so VFL & VGL can use 2-D properties and just send them down the stack.
There are some small details to consider, should the below throw a warning?
#box1[size] == #box2[width];
I say go on with your spec, this would be a super helpful addition!
Would be cool to support things like:
#box1[top-left] == #box2[center];
For reference, this exists if we ever wanted to use it: https://github.com/andreineculau/pegjs-override-action
Any requests for 2D mappings? So far I've configured:
{
"bottom-left": ["left", "bottom"],
"bottom-right": ["right", "bottom"],
center: ["center-x", "center-y"],
"intrinsic-size": ["intrinsic-width", "intrinsic-height"],
position: ["x", "y"],
size: ["width", "height"],
"top-left": ["left", "top"],
"top-right": ["right", "top"]
}
I have 2D sugar working for stays now too.
What's the status of measure
? I see an old spec hinting that 2D should work for this too.
Was it deprecated?
There are some small details to consider, should the below throw a warning?
#box1[size] == #box2[width];
I need some input on this. Currently it will only create a constraint for the width but also doesn't issue any warnings.
Would something like this be preferred?
#box1[width] == #box2[width] !strong;
#box1[height] == #box2[width];
measure was replaced with intrinsics, good catch.
as for #box1[size] == #box2[width];
, it should probably constrain just the width so that 2-d props can be used in things like VFL helpers where the dimension would be inferred.
#box1[size] == #box2[size]
should compile to 2 constraints: