prochitecture / pml

Translator for PML (Prochitecture Markup Language)
2 stars 0 forks source link

Bugs in first almost complete version #4

Closed vvoovv closed 2 years ago

vvoovv commented 4 years ago

The first part is here

vvoovv commented 4 years ago

Scope modificator (_perbuilding(..), etc) can be applied to any part of the alternative expression or to the whole alternative expression.

See the attached PML file.

scope.txt

polarkernel commented 4 years ago

Scope modificator (per_building(..), etc) can be applied to any part of the alternative expression or to the whole alternative expression.

Should work now. per_building() was the only function that takes another function as argument within alternatives.

vvoovv commented 4 years ago

It outputs

            claddingColor = Value(Alternatives(
                FromAttr("building:colour", FromAttr.Color)PerBuilding(,
                FromBldgAttr("building:colour", FromAttr.Color)),
                Conditional(
                    lambda item: item.getStyleBlockAttr("claddingMaterial") == "brick"PerBuilding(,
                    RandomWeighted( (((0.482, 0.259, 0.184, 1.0),1),((0.773, 0.463, 0.365, 1.0),1),((0.592, 0.424, 0.42, 1.0),1)) ))
                )PerBuilding(,
                RandomWeighted( (((0.482, 0.259, 0.184, 1.0),1),((0.773, 0.463, 0.365, 1.0),1),((0.592, 0.424, 0.42, 1.0),1)) ))
            ))

That raises a syntax error.

The output should be:

            claddingColor = Value(Alternatives(
                PerBuilding(FromAttr("building:colour", FromAttr.Color)),
                FromBldgAttr("building:colour", FromAttr.Color)),
                Conditional(
                    lambda item: item.getStyleBlockAttr("claddingMaterial") == "brick",
                    PerBuilding(RandomWeighted( (((0.482, 0.259, 0.184, 1.0),1),((0.773, 0.463, 0.365, 1.0),1),((0.592, 0.424, 0.42, 1.0),1)) ))(
                ),
                PerBuilding(RandomWeighted( (((0.482, 0.259, 0.184, 1.0),1),((0.773, 0.463, 0.365, 1.0),1),((0.592, 0.424, 0.42, 1.0),1)) )))
            ))
polarkernel commented 4 years ago

That's weird? Using the code I commited yesterday, I get

            claddingColor = Value(Alternatives(
                FromAttr("building:colour", FromAttr.Color),
                PerBuilding(
                    FromBldgAttr("building:colour", FromAttr.Color)
                ),
                Conditional(
                    lambda item: item.getStyleBlockAttr("claddingMaterial") == "brick",
                    PerBuilding(
                        RandomWeighted( (((0.482, 0.259, 0.184, 1.0),1),((0.773, 0.463, 0.365, 1.0),1),((0.592, 0.424, 0.42, 1.0),1)) )
                    )
                ),
                PerBuilding(
                    RandomWeighted( (((0.482, 0.259, 0.184, 1.0),1),((0.773, 0.463, 0.365, 1.0),1),((0.592, 0.424, 0.42, 1.0),1)) )
                )
            ))

Did you get the changes of the two methods of PythonCoder.py starting here?

vvoovv commented 4 years ago

@polarkernel Sorry for the confusion. I used the old version of the pml repo in the blender-osm addon. Yes, it works.

vvoovv commented 4 years ago

The following PML file gives a Python syntax error.

What is more important, the output is incorrect.

It should be

claddingColor = (1.0, 0.0, 0.0, 1.0)

intead of

claddingColor = Value(Constant((1.0, 0.0, 0.0, 1.0))

main.txt

polarkernel commented 4 years ago

The following PML file gives a Python syntax error.

Fixed.

vvoovv commented 4 years ago

It works now. Thanks.

vvoovv commented 4 years ago

Parsing of empty markup fails (see the attached PML file):

item {
    markup: []
}

empty_markup.txt

polarkernel commented 4 years ago

Parsing of empty markup fails

Fixed. What sense does that make? Couldn't the markup just get omitted?

vvoovv commented 4 years ago

I wanted to test something with and without markup and promptly switching between those two cases. That's how I encountered that bug.

vvoovv commented 4 years ago

It works now.