my github avatar

Static Lexer

This website is made using a custom static site generator written in Go. It generates the HTML files from a different file structure with a small custom lexer. The lexer is very simple and is used to include other files and to add some basic things such as metadata and content slots.

The syntax of this lexer is as followed:

Update

I've been working on updating the lexer, i've made an entirely new version since the previous one was very messy and hard to work with. The new lexer, "lexern2" is much more simple and easy to work with, but at the same time also more complex. The lexer is now able to parse more complex things such as statements and expressions. Before the lexer was only able to do static things and could not import data from files that werent loaded yet. The new lexer's process looks as followed:

  1. A new lexer will be made.
  2. The lexer will be given every file found.
  3. The files loaded in will parse through them and save the statements as different nodes.
  4. Once all files are parsed it will call the String method which will go through all the nodes saved per page and generate the html.
  5. The generated html will be saved in the corresponding location of the url metadata.

My next 2 goals is to make the lexer be able to call small functions in order to find all the pages using a certain metadata and loop through it. Mainly to make the navigation bar easier to update. The second goal is to make the lexer logging more useful to find issues, i want to make it so that it logs the line and column of the error. So far syntactically the lexer hasnt changed much, the biggest change is that metadata uses the # token instead of + to save metadata. + is only used to insert metadata to the current file.

Some examples

Navigation
    

    
Pages
    
#url=/projects/lexer;
#title=Lexer;
#tag=project;

{template:
    

Static Lexer

...

}
Template
    
#alias = code;

    
        +content;
    
    
{code:
    #.lang=html;`this is a code block`
}
    

Github repository: [link]