<commit_before>grammar IMQLang;

////
// Parser
////

compileUnit
    :   EOF
    |   statements EOF
    ;

statements
    :
    (
        statement
    )+
    ;

statement
    :   define_input_stm SEMICOLON
    |   define_output_stm SEMICOLON
    |   set_variable_stm SEMICOLON
    |   set_field_stm SEMICOLON
    |   delete_variable_stm SEMICOLON
    |   select_stm SEMICOLON
    |   branch_stm // no semicolon, uses block syntax
    |   expression SEMICOLON
    ;

define_input_stm
    :   INPUT IDENT (EQUAL expression)?
    ;

define_output_stm
    :   OUTPUT IDENT (EQUAL expression)?
    ;

set_variable_stm
    :   IDENT EQUAL expression
    ;

set_field_stm
    :   variable DOT IDENT EQUAL expression
    ;

delete_variable_stm
    :   DELETE IDENT
    ;

select_stm
    :   expression COLON expression FROM expression
    ;

branch_stm
    :   IF expression L_BRACE statements? R_BRACE
    (
        ELSE L_BRACE statements? R_BRACE
    )?
    ;

expression
    :   orExpr
    ;

orExpr
    :   andExpr
    |   andExpr OR orExpr
    ;

andExpr
    :   equalityExpr
    |   equalityExpr AND andExpr<commit_msg>added else if support to the grammar<commit_after>grammar IMQLang;

////
// Parser
////

compileUnit
    :   EOF
    |   statements EOF
    ;

statements
    :
    (
        statement
    )+
    ;

statement
    :   define_input_stm SEMICOLON
    |   define_output_stm SEMICOLON
    |   set_variable_stm SEMICOLON
    |   set_field_stm SEMICOLON
    |   delete_variable_stm SEMICOLON
    |   select_stm SEMICOLON
    |   branch_stm // no semicolon, uses block syntax
    |   expression SEMICOLON
    ;

define_input_stm
    :   INPUT IDENT (EQUAL expression)?
    ;

define_output_stm
    :   OUTPUT IDENT (EQUAL expression)?
    ;

set_variable_stm
    :   IDENT EQUAL expression
    ;

set_field_stm
    :   variable DOT IDENT EQUAL expression
    ;

delete_variable_stm
    :   DELETE IDENT
    ;

select_stm
    :   expression COLON expression FROM expression
    ;

branch_stm
    :   IF expression L_BRACE statements? R_BRACE
    (
        ELSE IF expression L_BRACE statements? R_BRACE
    )*
    (
        ELSE L_BRACE statements? R_BRACE
    )?
    ;

expression
    :   orExpr
    ;

orExpr
    :   andExpr
    |   andExpr OR orExpr
    ;

andExpr
    :   equalityExpr
    |   equalityExpr AND andExpr
{'fraction_non_alphanumeric': 0.05834405834405834, 'fraction_numerical': 0.0, 'mean_word_length': 2.064388961892247, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '464583', 'n_tokens_mistral': 855, 'n_tokens_neox': 820, 'n_words': 173}