Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrototypeContext.adl does not compile #1461

Open
stefjoosten opened this issue Jan 20, 2024 · 1 comment
Open

PrototypeContext.adl does not compile #1461

stefjoosten opened this issue Jan 20, 2024 · 1 comment

Comments

@stefjoosten
Copy link
Contributor

stefjoosten commented Jan 20, 2024

What happened

I tried to compile the AmpersandData/PrototypeContext/PrototypeContext.adl` code with the Ampersand-v5.0.0 compiler, expecting it to compile stand-alone. This code is used to generate prototypes, so I know apriori that it is correct. However, I got compiler errors:

/Users/sjo00577/git/Ampersand/AmpersandData/PrototypeContext/Navbar.adl:44:82 error:
  A relation is used that is not defined: pf_ifcRoles ==============================
/Users/sjo00577/git/Ampersand/AmpersandData/PrototypeContext/Navbar.adl:44:97 error:
  A relation is used that is not defined: pf_navItemRoles ==============================

Surprisingly, I could not find declarations of the missing relations anywhere in the entire Ampersand repo. So, I speculated that maybe these are "magical declarations" and decided to add these declaratioins in PrototypeContext.adl. An unlikely speculation, but then, a second declaration of the same thing doesn't hurt in Ampersand.

  RELATION pf_ifcRoles[Interface*Role] 
  RELATION pf_navItemRoles[NavMenuItem*Role]

Now I got type conflicts:

/Users/sjo00577/git/Ampersand/AmpersandData/PrototypeContext/Navbar.adl:77:132 error:
  Type error, cannot match:
    the concept PF_NavMenuItem (Src of I[PF_NavMenuItem ])
    and concept NavMenuItem (Src of isSubItemOf [NavMenuItem *NavMenuItem ];isSubItemOf [NavMenuItem *NavMenuItem ]~)==============================
/Users/sjo00577/git/Ampersand/AmpersandData/PrototypeContext/Interfaces.adl:24:82 error:
  Type error, cannot match:
    the concept Interface (Tgt of isPublic [Interface *Interface ])
    and concept PF_Interface (Src of V [PF_Interface *Role ])==============================

I figured that maybe there is more magic in this thing.
So, I added

  CLASSIFY Interface IS PF_Interface
  CLASSIFY NavMenuItem IS PF_NavMenuItem

But the search wasn't over. I now got stuck with four compiler errors, the first of which reads:

/Users/sjo00577/git/Ampersand/AmpersandData/PrototypeContext/Navbar.adl:77:111 error:
  Type error, cannot match:
    the concept NavMenuItem (Src of I[PF_NavMenuItem ]-isSubItemOf [NavMenuItem *NavMenuItem ];isSubItemOf [NavMenuItem *NavMenuItem ]~)
    and concept PF_NavMenu (Src of I[PF_NavMenu ])==============================

Now I'm really puzzled because this is code that runs correctly when I use it to generate prototypes.
I inspected the code of the prototype framework to see which part of the metamodel it uses. This appears to be

    const
        REL_IFC_ROLES               = 'pf_ifcRoles[PF_Interface*Role]',
        REL_IFC_IS_PUBLIC           = 'isPublic[PF_Interface*PF_Interface]',
        REL_IFC_IS_API              = 'isAPI[PF_Interface*PF_Interface]',
        REL_IFC_LABEL               = 'label[PF_Interface*PF_Label]',
        REL_ROLE_LABEL              = 'label[Role*PF_Label]',
        REL_SESSION_ALLOWED_ROLES   = 'sessionAllowedRoles[SESSION*Role]',
        REL_SESSION_ACTIVE_ROLES    = 'sessionActiveRoles[SESSION*Role]',
        REL_NAV_LABEL               = 'label[PF_NavMenuItem*PF_Label]',
        REL_NAV_IS_VISIBLE          = 'isVisible[PF_NavMenuItem*PF_NavMenuItem]',
        REL_NAV_IS_PART_OF          = 'isPartOf[PF_NavMenuItem*PF_NavMenu]',
        REL_NAV_IFC                 = 'ifc[PF_NavMenuItem*PF_Interface]',
        REL_NAV_SEQ_NR              = 'seqNr[PF_NavMenuItem*PF_SeqNr]',
        REL_NAV_SUB_OF              = 'isSubItemOf[PF_NavMenuItem*PF_NavMenuItem]';

@Michiel-s, can you explain to me what I cannot explain?

What I expected

Version of ampersand that was used

Steps to reproduce

Screenshot / Video

Context / Source of ampersand script

@hanjoosten
Copy link
Member

Ah, this makes sence to me. Let me try to explain. Initially, I made modifications to all ADL files in FormalAmpersand as well as in PrototypeContext. One of the changes I made was to remove the prefix pf_ from everything. The prefix has no more use, for a namespace is generated automatically for the FormalAmpersand files as well as the PrototypeContext files. I also changes everything else so all these files abide to the new 5.0 syntax (Mostly Name and Label stuff).

Because at the time I did these changes there was no such thing as LABEL, the original names were not preserved as LABEL. This is where you came in. As we discussed previously, you started all over again with the files in AmpersandData. I forgot to inform you that I had removed the prefixes in PrototypeContext files. So please go on with your effort, and don't forget to remove the pf_ prefixes. Sorry for not telling you this before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants