Skip to content

Tutorial

Kenan Masri edited this page Feb 13, 2023 · 3 revisions

3LM File

A 3LM file (path/to/file.3lm) is a text file that contains a layout for structured data. It is mainly like a markup language. Currently it is going to be used for defining books, courses, pages, wikis and educational and teaching information.

In this tutorial we're going to look for one proposed example of using this language.

Random Example

The following is an example 3LM file that provides a Course object containing two Page objects and an some_id attribute. The two Page objects both contain a title and an implicit body attribute.

Course my_course
	some_id = “abcdef123...”
	---
	Description of course.
	---
	Page
		title = “Welcome to the first page of my course”
		---
		This is the body content of the page. You can write as much as you’d like!
		---
	End
	Page
		title = “Second page”
		---
		”Marie François Xavier Bichat” is the founder of histology.
		---
	End
...
End

Notice that the Page objects have no names, thus, their name attribute is an empty string.

Some Questions

What happens when I run this file?

Typically what will happen is three things:

  1. Lexing the contents of the file (This means generating tokens)
  2. Parsing the generated tokens. (This step is useful for API)
  3. Interpreting those tokens. (This step is the most useful one for users)

While parsing is similar to interpreting, Interpretation just visits each node in the AST and evaluates mathematical expressions in the attributes. It also runs the plugins defined against them. For example, json plugin converts the interpretation to JSON.

The abstract syntax tree nodes are defined in a Python file here: (AST in Python)

Can I use this in my project?

Yes, you'll have to check the API documentation for it to be useful. Or you can write your own plugin. Giving credits is highly appreciated and I'd love to see your project, reach me @kenanmasri!

One thing to note is this language is in continuous development so your support matters!

Clone this wiki locally