Skip to content

ProImpact/first-abstract-syntax-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My first Abstract Syntax Tree (AST)

Hi !!, this is a simple (ast) with a recursive-descent expression compilation for parse my family generation it's just an excercie in my jurney for learn how compilers works and make my own some day.

How it's works

The structure is like a json but you can add multiple names the first level it's the first generation

Ex:

{
    "Odinn"
    "Zeus"
}

For add the Odin's generation:

{
    "Odinn"
    {
        "Emiliano"
        "Atenea"
        "Mixra"
        {
            "Axtrox"
            "Loky"
            {
                "Zeus"
                "Hulk"
            }
        }
    }
    "Zeus"
}

Output:

Members of the 1 generation
        ["Odinn" "Zeus"]
Members of the 2 generation
        ["Emiliano" "Atenea" "Mixra"]
Members of the 3 generation
        ["Axtrox" "Loky"]
Members of the 4 generation
        ["Zeus" "Hulk"]

Under the hood the recursion tree it's saved into

type Node struct {
	data   string
	childs []*Node
}

About

Simple Abstract Syntaax Tree(AST) in Golang

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages