-
Notifications
You must be signed in to change notification settings - Fork 0
Language
The following is the basic structure of the 3lm language:
Class my_name ; Comment
attribute = <expression>
body = <expression>
SubClass my_sub_name
End
End
Extended version:
Import relative/path/to/extra.3lm
Class my_name
attribute = <expression>
---
Body in markdown text.
---
SubClass my_sub_name
End
End
Tips:
--- are opening of the body and optionally closing the body.
Notice that the language has different contexts. For imports, for expressions, for body and the general layout.
A file with 3lm extension is considered a 3lm file. By being a provided input file, it can import other 3lm files.
A 3lm file contains import statements at the top. The imports don't necessarily have to state the extension since the parser automatically checks against 3lm extension
import myfile1
import myfile2.3lm
A 3lm file defines an unlimited number of blocks. A block is basically a node with optional sub-nodes.
- Blocks are defined by specifying its class or type, and optionally its name.
- Blocks can be nested inside blocks.
- In the previous examples, There's a block with type
Classand namemy_name. - Block types are CamelCase. Starting with a capital letter and with only ASCII letters and numbers.
- Block names are preferably snake_case. With only ASCII letters and numbers.
A block can have unlimited number of attributes that evaluates an expression on interpretation.
- An attribute, in the previous examples, is "attribute" or "body".
- Attributes are preferably snake_case. Only English letters and numbers, beginning with a letter or an underscore.
- A special attribute named body, can be represented in another way (see below).
A block can also have a body component if a body attribute isn't specified.
- The body can be an attribute that evaluates an expression.
- It can also be started by three hyphens. Text after it is called body content. It can end with three other hyphens in the same indentation level of the starting ones (in a single, separate line of text).
- In the previous example, the body content is a string "Body in markdown text.".
- The body content can be started in any indentation, the first character encountered other than whitespace is the initial content's indentation level. Next lines should be either at this indentation level or higher.
- This means the body is trimmed, from left-to-right, of extra indentations in the same amount of body content's indentation.
Class my_name
;attribute = <expression>
---
I started after 2 ignored spaces.
Me too.
I start with a space.
I start early.
My indents are none.
---
;another_attribute = <expression>
End
The body here is
Me too.
I start with a space.
I start early.
My indents are none.