grammar{
    start: (import | export | include_files | model | NEWLINE)+;

    import: IMPORT MV_URL AS MODEL_ID;
    export: EXPORT MODEL_ID TO MV_URL;
    include_files: INCLUDE STRVALUE NEWLINE;

    model: MODEL_ID MODEL_ID NEWLINE? LCURLY NEWLINE? (model_element)* RCURLY;

    model_element: MODEL_ID MODEL_ID? inheritance? (LPAR MODEL_ID COMMA MODEL_ID RPAR)? NEWLINE? LCURLY NEWLINE? (model_attribute)* RCURLY NEWLINE?;

    inheritance: COLON MODEL_ID (COMMA MODEL_ID)*;

    model_attribute : (MODEL_ID COLON MODEL_ID (LCURLY NEWLINE? model_attr_instance* RCURLY)? NEWLINE?)
                    | (model_attr_instance)
                    | (DOLLAR ANYTHING_EXCEPT_DOLLAR DOLLAR NEWLINE?);

    model_attr_instance: MODEL_ID ASSIGN value NEWLINE?;

    value
        : DEC_NUMBER
        | FLOAT_NUMBER
        | TRUE
        | FALSE
        | STRVALUE;

    tokens{
        IMPORT: 'import';
        AS: 'as';
        MODEL_ID: '[a-zA-Z_][a-zA-Z_0-9]*';
        MV_URL: '[a-zA-Z_0-9/]*';
        LCURLY: '{';
        RCURLY: '}';
        NEWLINE: '(\r?\n)+';
        DEC_NUMBER: '[+-]?(0|[1-9]\d*[lL]?)';
        FLOAT_NUMBER: '[+-]?((\d+\.\d*|\.\d+)([eE][-+]?\d+)?|\d+[eE][-+]?\d+)';
        STRVALUE: 'u?r?("(?!"").*?(?<!\\)(\\\\)*?"|\'(?!\'\').*?(?<!\\)(\\\\)*?\')';
        TRUE: 'True';
        FALSE: 'False';
        ASSIGN: '=';
        DOLLAR: '\$';
        WS: '[ ]+' @Impl;
        COLON : ':';
        LPAR: '\(';
        RPAR: '\)';
        COMMA: ',';
        EXPORT: 'export';
        TO: 'to';
        ANYTHING_EXCEPT_DOLLAR: '[^$]*';
        INCLUDE: 'include';
    }
}
