<commit_before>rock tutorial
=============

nodes
-----

Everything is an AST node. Includes are nodes. Variable declarations are nodes.

tokens
------

Tokens are used to determine where a nodes come from (File, line number)
from the parsing phase.

When you create nodes from scratch you can use 'nullToken' which means
the node was created ex nihilo.

types
-----

BaseType are ArrayList, List, Pointer
FuncType is Func (T) -> K
PointerType is Int*, Char*
ReferenceType is Int@

creating types
--------------

    intType := BaseType new("Int", nullToken)

NB: It's a bad idea to use 'nullToken', it'll give strange error messages.
If you're manipulating the AST from existing nodes, you're probably better
off using the closest node's token.

creating a variable
-------------------

e.g. the code

    myvar: Int
    
is constructed with

    intType := BaseType new("Int", nullToken)
    vDecl := VariableDecl new(intType, "myvar", nullToken)
    
In this case it's probably better to use IntLiteral type though (you can
also use NullLiteral, etc.)

    vDecl := VariableDecl new(IntLiteral type, "myvar", nullToken)
    
creating literals
-----------------

    kalamazoo := 42
    
is constructed with

    vDecl := VariableDecl new(null, "kalamazoo", IntLiteral new(42, nullToken))
    
A null type for a VariableDecl will infer 


classes
-------

    Dog: class {}
    
is constructed with

    dogClass := ClassDecl new("Dog", nullToken)
    
You can add member variables, e.g.

    Dog: class {
        name: String
    }
    
With

    vDecl := VariableDecl new(StringLiteral type, "name", nullToken)


function calls
--------------

    exit()
    
Is created with

    FunctionCall new("exit", nullToken)
    
Also,

    exit(128)
    
Is created with

    call := FunctionCall new("exit", nullToken)
    call getArguments() add(IntLiteral new(128, nullToken))

member calls
------------

    msg := "Hi world"
    msg println()
    
Is created with

    vDecl := VariableDecl new(null, "msg", StringLiteral new("Hi world", nullToken), nullToken)
    vAcc := VariableAccess new(vDecl, nullToken)
    fCall := FunctionCall new(vAcc, "println", nullToken)

variable accesses
-----------------

Above, we use a VariableAccess to call a method on a variable.

VariableAccesses can be created from different things.

Either you directly know the VariableDecl you wanna access and you can do

    VariableAccess new(vDecl, nullToken)
    
Or you just know its name and you want it resolved

    VariableAccess new("myVariable", nullToken)
    
You can even have a VariableAccess to a type

    VariableAccess new(IntLiteral type, nullToken)
    
Which is useful, for example, if you want to have a variable access
to "Int size". See below for member accesses


member accesses
---------------

They're like variable accesses, but with a non-null expr.

So to do for example

    Int size
    
We'd do

    intAccess := VariableAccess new(IntLiteral type, nullToken)
    sizeAccess := VariableAccess new(intAccess, "size", nullToken)


<commit_msg>Fixed tutorial<commit_after>rock tutorial
=============

nodes
-----

Everything is an AST node. Includes are nodes. Variable declarations are nodes.

tokens
------

Tokens are used to determine where a nodes come from (File, line number)
from the parsing phase.

When you create nodes from scratch you can use 'nullToken' which means
the node was created ex nihilo.

types
-----

BaseType are ArrayList, List, Pointer
FuncType is Func (T) -> K
PointerType is Int*, Char*
ReferenceType is Int@

creating types
--------------

    intType := BaseType new("Int", nullToken)

NB: It's a bad idea to use 'nullToken', it'll give strange error messages.
If you're manipulating the AST from existing nodes, you're probably better
off using the closest node's token.

creating a variable
-------------------

e.g. the code

    myvar: Int
    
is constructed with

    intType := BaseType new("Int", nullToken)
    vDecl := VariableDecl new(intType, "myvar", nullToken)
    
In this case it's probably better to use IntLiteral type though (you can
also use NullLiteral, etc.)

    vDecl := VariableDecl new(IntLiteral type, "myvar", nullToken)
    
creating literals
-----------------

    kalamazoo := 42
    
is constructed with

    vDecl := VariableDecl new(null, "kalamazoo", IntLiteral new(42, nullToken))
    
A null type for a VariableDecl will infer 


classes
-------

    Dog: class {}
    
is constructed with

    dogClass := ClassDecl new("Dog", nullToken)
    
You can add member variables, e.g.

    Dog: class {
        name: String
    }
    
With

    vDecl := VariableDecl new(StringLiteral type, "name", nullToken)
    dogClass addVariable(vDecl)


function calls
--------------

    exit()
    
Is created with

    FunctionCall new("exit", nullToken)
    
Also,

    exit(128)
    
Is created with

    call := FunctionCall new("exit", nullToken)
    call getArguments() add(IntLiteral new(128, nullToken))

member calls
------------

    msg := "Hi world"
    msg println()
    
Is created with

    vDecl := VariableDecl new(null, "msg", StringLiteral new("Hi world", nullToken), nullToken)
    vAcc := variableAccess new(vDecl, nullToken)
    fCall := FunctionCall new(vAcc, "println", nullToken)

variable accesses
-----------------

Above, we use a VariableAccess to call a method on a variable.

VariableAccesses can be created from different things.

Either you directly know the VariableDecl you wanna access and you can do

    VariableAccess new(vDecl, nullToken)
    
Or you just know its name and you want it resolved

    VariableAccess new("myVariable", nullToken)
    
You can even have a VariableAccess to a type

    VariableAccess new(IntLiteral type, nullToken)
    
Which is useful, for example, if you want to have a variable access
to "Int size". See below for member accesses


member accesses
---------------

They're like variable accesses, but with a non-null expr.

So to do for example

    Int size
    
We'd do

    intAccess := VariableAccess new(IntLiteral type, nullToken)
    sizeAccess := VariableAccess new(intAccess, "size", nullToken)

instanciating objects
---------------------

    dog := Dog new()
    
Is constructed like

    dogClass := VariableAccess new("DogClass", nullToken)
    newCall := FunctionCall new("new", nullToken)
    dogDecl := VariableDecl new(null, "dog", newCall, nullToken)
    
    


{'fraction_non_alphanumeric': 0.11647461849891, 'fraction_numerical': 0.003114294612270321, 'mean_word_length': 2.8438061041292637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2309680', 'n_tokens_mistral': 1888, 'n_tokens_neox': 1744, 'n_words': 753}