TelluIoT / ThingML

The ThingML modelling language
https://github.com/TelluIoT/ThingML
Apache License 2.0
104 stars 32 forks source link

Check uniqueness of names in the parser #155

Closed jakhog closed 6 years ago

jakhog commented 7 years ago

Currently, this nonsensical piece of ThingML code is accepted by the compilers as valid code:

datatype MyByte<1> @c_type "uint8_t";
datatype MyInt<2> @c_type "uint16_t";
datatype MyInt<1> @c_type "uint8_t";

thing MyThing
{
    message MyByteMessage( p : MyByte );
    message MyIntMessage( p : MyInt );
    message MyIntMessage( p : MyByte );

    property MyProperty : MyByte
    property MyProperty : MyInt

    required port MyPort { sends MyByteMessage }
    required port MyPort { sends MyIntMessage }
    provided port MyPort { receives MyIntMessage }

    function MyFunction() : MyByte do end
    function MyFunction() : MyInt do end

    statechart MyStates init MyState
    {
        state MyState {}
        state MyState {}
    }
}

configuration MyConfiguration
{
    instance MyInstance : MyThing
    instance MyInstance : MyThing
}

In my mind, the parser should not allow for multiple definitions with the same name like this 🙃

jakhog commented 6 years ago

There are tests for this now, and most of them succeed