<commit_before># mini-programming-language

## Language Specification

### 1. Language Definition
* Alphabet:
    * Upper (A-Z) and lower case (a-z) letters of the English alphabet
    * Underline charcter '_'
    * Decimal digits (0-9)


* Lexic:
    * Special symbols:
        * operators     
            * relational: **=, <>, <, >, <]** (<=), **[>** (>=)
            * aritmetici: **+,-,*,/, %,**
            * logici: **#**(and), **##**(or)
        * assigment: **<-**
        * separators: **(), [], begin, end, space, .**
        * reserved words: **if, else, for, while, const, int, program, begin, end, read, write, writeln let, list_of_integer, list_of_string, func, call, and, or**
    * Identifiers ( *a seq. of 3 letters at least* )
        ```pseudo
        letter lower case ::= "a" | "b" | ... | "z" ;   

        letter ::= letter lower case | "A" | "B" | ... | "Z" ;

        identifier ::= letter lower case , {letter lower case "_"} ;
        ```
    * Constants
        1. **integer**
            ```pseudo
            digit ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;

            integer ::= ["-"], digit, {digit} ;
            ```
        2. **string**
            ```pseudo
            character ::= "letter" | "digit" ; 

            string ::= '"', character, {character - '"'}, '"' ;
            ```
        3. **boolean**
            ```pseudo
            boolean ::= "0" | "1" ; 
            ```
### 2. Syntax
* Rules
```pseudo
    program ::= "PROGRAM", space, identifier, space,
                "BEGIN", space, 
                listDeclaration, ";", instructions,
                "END." ;

    listDeclaration :: = declaration | declaration, ";", space, listDeclaration ;

    declaration ::= ("LET" | "let"), identifier, [space], assignment, [space], ":", [space], type ;

    assignment ::= identifier , [space], "<-", (integer | string) ; 

    type ::= "bool" | "int" | "string" ;

    arrayDeclaration ::= "list_of_integer", "[", no., "]", [space], ":", [space], type;                
    
    instructions ::= "begin", (instruction | instruction, ";", space, instructions)  ,"end" ; 

    instruction ::= simpleInstruction | complexInstruction ;

    simpleInstruction ::= assignment | io ;

    complexInstruction ::= instructions | ifInstruction | whileInstruction ; 

    ifInstruction ::= "if", "(", condition, ")", "then", "begin", instruction, "end", ["else", "begin", instruction, "end"] ;

    whileInstruction ::= "while", "(", condition, ")", "execute", "begin", instruction, "end" ;

    io ::= ("read" | "write"), "(" indentifier ")" ;

    space ::= ? space character ? ;
```    <commit_msg>refactored using the EBNF<commit_after># mini-programming-language

## Language Specification

### 1. Language Definition
* Alphabet:
    * Upper (A-Z) and lower case (a-z) letters of the English alphabet
    * Underline charcter '_'
    * Decimal digits (0-9)


* Lexic:
    * Special symbols:
        * operators     
            * relational: **=, <>, <, >, <]** (<=), **[>** (>=)
            * aritmetici: **+,-,*,/, %,**
            * logici: **#**(and), **##**(or)
        * assigment: **<-**
        * separators: **(), [], begin, end, space, .**
        * reserved words: **if, else, for, while, const, int, program, begin, end, read, write, writeln let, list_of_integer, list_of_string, func, call, and, or**
    * Identifiers ( *a seq. of 3 letters at least* )
        ```pseudo
        letter lower case = "a" | "b" | ... | "z" ;   

        letter = letter lower case | "A" | "B" | ... | "Z" ;

        identifier = letter lower case , {letter lower case "_"} ;
        ```
    * Constants
        1. **integer**
            ```pseudo
            digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;

            integer = ["-"], digit, {digit} ;
            ```
        2. **string**
            ```pseudo
            character = "letter" | "digit" ; 

            string = '"', character, {character - '"'}, '"' ;
            ```
        3. **boolean**
            ```pseudo
            boolean = "0" | "1" ; 
            ```
### 2. Syntax
* Rules
```pseudo
    program = "PROGRAM", space, identifier, space,
                "BEGIN", space, 
                listDeclaration, ";", instructions,
                "END." ;

    listDeclaration :: = declaration | declaration, ";", space, listDeclaration ;

    declaration = ("LET" | "let"), identifier, [space], assignment, [space], ":", [space], type ;

    assignment = identifier , [space], "<-", (integer | string) ; 

    type = "bool" | "int" | "string" ;

    arrayDeclaration = "list_of_integer", "[", no., "]", [space], ":", [space], type;                
    
    instructions = "begin", (instruction | instruction, ";", space, instructions)  ,"end" ; 

    instruction = simpleInstruction | complexInstruction ;

    simpleInstruction = assignment | io ;

    complexInstruction = instructions | ifInstruction | whileInstruction ; 

    ifInstruction = "if", "(", condition, ")", "then", "begin", instruction, "end", ["else", "begin", instruction, "end"] ;

    whileInstruction = "while", "(", condition, ")", "execute", "begin", instruction, "end" ;

    io = ("read" | "write"), "(" indentifier ")" ;

    space = ? space character ? ;
```    
{'fraction_non_alphanumeric': 0.2054380664652568, 'fraction_numerical': 0.0075528700906344415, 'mean_word_length': 2.2103030303030304, 'pattern_counts': {'":': 4, '<': 15, '<?xml version=': 0, '>': 11, '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': '3327651', 'n_tokens_mistral': 1651, 'n_tokens_neox': 1587, 'n_words': 415}