including contents of other file conflicts with standard libs

Issue #731 resolved
fredericg created an issue

My goal is to have a common part, used in a lot of structures, in a different file. And to then include that common part in a specific structure. For theories there's a merge procedure, but there is none for structures, so I tried to do so using "include", so far no luck.

What am I doing wrong, or ideas on how I can achieve my goal?

include_main.idp:

vocabulary voc{
    type Klant
    type Bedrag isa int
    Aankoop(Klant, Bedrag)
}

theory theo:voc{}

structure struc:voc{
    Klant = {Fre}
    Bedrag = {0..20}
    include "include_2bincluded.idp"
}

include <mx>
procedure main(){
    printmodels(modelexpand(theo, struc))
}

include_2bincluded.idp

/**
 * Title: A new IDP source file
 * Author: Fre
 */
Aankoop = {Fre, 10}

Error:

Error: [string "local function onemodel(T,S)local configIDP = stdspace.configID..."]:34: unexpected symbol near '}' At /home/frederic/idp_install_p/bin/../share/std/mx.idp:7:15
Error: syntax error, unexpected $end At /home/frederic/Dropbox/KUL/master/masterproef/idp_workspace/belfius/include_main.idp:22:1

Comments (3)

  1. Ingmar Dasseville

    This can be solved by using a real structure as the "common" structure and merging structures:

    vocabulary voc{
        type Klant
        type Bedrag isa int
        Aankoop(Klant, Bedrag)
    }
    
    theory theo:voc{
    
    }
    
    structure struc:voc{
        Klant = {Fre}
        Bedrag = {0..20}
    }
    
    include <mx>
    procedure main(){
        struc2 = merge(struc,common)
        printmodels(modelexpand(theo, struc2))
    }
    
    /**
     * Title: A new IDP source file
     * Author: Fre
     */
    structure common:voc{
    Aankoop = {Fre, 10}
    }
    

    you can run this by giving both files as args to IDP

  2. Log in to comment