Skip to content

Commit aa0a9fc

Browse files
committed
feat: .
Closes #11
1 parent 61c410f commit aa0a9fc

File tree

9 files changed

+7529
-1137
lines changed

9 files changed

+7529
-1137
lines changed

.stylua.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ call_parentheses = "Always"
88
collapse_simple_statement = "Never"
99
space_after_function_names = "Never"
1010
block_newline_gaps = "Never"
11-
remove_trailing_whitespace = true

README.md

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -115,46 +115,48 @@ The parser generates a tree of nodes. Here is the specification for each node ty
115115
<details>
116116
<summary>Click to expand AST Specification</summary>
117117

118-
#### **Literals & Identifiers**
119-
* `{ kind = "Variable", name = <string>, variableType = <"Local" | "Global" | "Upvalue"> }`
120-
* `{ kind = "StringLiteral", value = <string> }`
121-
* `{ kind = "NumericLiteral", value = <number> }`
122-
* `{ kind = "BooleanLiteral", value = <bool> }`
123-
* `{ kind = "NilLiteral" }`
124-
* `{ kind = "VarargExpression" }`
125-
126-
#### **Expressions**
127-
* `{ kind = "FunctionExpression", body = <Block>, parameters = <list_of_strings>, isVarArg = <bool> }`
128-
* `{ kind = "UnaryOperator", operator = <string>, operand = <node> }`
129-
* `{ kind = "BinaryOperator", operator = <string>, left = <node>, right = <node> }`
130-
* `{ kind = "FunctionCall", callee = <node>, arguments = <list_of_nodes>, isMethodCall = <bool> }`
131-
* `{ kind = "IndexExpression", base = <node>, index = <node>, isPrecomputed = <bool>? }`
132-
* `{ kind = "TableConstructor", elements = <list_of_TableElement> }`
133-
* `{ kind = "TableElement", key = <node>, value = <node>, isImplicitKey = <bool> }`
134-
* `{ kind = "ParenthesizedExpression", expression = <node> }`
135-
136-
#### **Statements**
137-
* `{ kind = "LocalDeclarationStatement", variables = <list_of_strings>, initializers = <list_of_nodes> }`
138-
* `{ kind = "LocalFunctionDeclaration", name = <string>, body = <FunctionExpression> }`
139-
* `{ kind = "AssignmentStatement", lvalues = <list_of_nodes>, expressions = <list_of_nodes> }`
140-
* `{ kind = "CallStatement", expression = <FunctionCall> }`
141-
* `{ kind = "IfClause", condition = <node>, body = <Block> }`
142-
* `{ kind = "IfStatement", clauses = <list_of_IfClauses>, elseClause = <Block>? }`
143-
* `{ kind = "WhileStatement", condition = <node>, body = <Block> }`
144-
* `{ kind = "RepeatStatement", body = <Block>, condition = <node> }`
145-
* `{ kind = "ForNumericStatement", variable = <Identifier>, start = <node>, limit = <node>, step = <node>?, body = <Block> }`
146-
* `{ kind = "ForGenericStatement", iterators = <list_of_strings>, expressions = <list_of_nodes>, body = <Block> }`
147-
* `{ kind = "DoStatement", body = <Block> }`
148-
* `{ kind = "ReturnStatement", expressions = <list_of_nodes> }`
149-
* `{ kind = "BreakStatement" }`
150-
151-
#### **Program Structure**
152-
* `{ kind = "Block", statements = <list_of_statement> }`
153-
* `{ kind = "Program", body = <Block> }`
118+
```lua
119+
-- Literals & Identifiers
120+
{ kind = "Variable", name = <string>, variableType = <"Local" | "Global" | "Upvalue"> }
121+
{ kind = "StringLiteral", value = <string> }
122+
{ kind = "NumericLiteral", value = <number> }
123+
{ kind = "BooleanLiteral", value = <bool> }
124+
{ kind = "NilLiteral" }
125+
{ kind = "VarargExpression" }
126+
127+
-- Expressions
128+
{ kind = "FunctionExpression", body = <Block>, parameters = <list_of_strings>, isVarArg = <bool> }
129+
{ kind = "UnaryOperator", operator = <string>, operand = <node> }
130+
{ kind = "BinaryOperator", operator = <string>, left = <node>, right = <node> }
131+
{ kind = "FunctionCall", callee = <node>, arguments = <list_of_nodes>, isMethodCall = <bool> }
132+
{ kind = "IndexExpression", base = <node>, index = <node>, isPrecomputed = <bool>? }
133+
{ kind = "TableConstructor", elements = <list_of_TableElement> }
134+
{ kind = "TableElement", key = <node>, value = <node>, isImplicitKey = <bool> }
135+
{ kind = "ParenthesizedExpression", expression = <node> }
136+
137+
-- Statements
138+
{ kind = "LocalDeclarationStatement", variables = <list_of_strings>, initializers = <list_of_nodes> }
139+
{ kind = "LocalFunctionDeclaration", name = <string>, body = <FunctionExpression> }
140+
{ kind = "AssignmentStatement", lvalues = <list_of_nodes>, expressions = <list_of_nodes> }
141+
{ kind = "CallStatement", expression = <FunctionCall> }
142+
{ kind = "IfClause", condition = <node>, body = <Block> }
143+
{ kind = "IfStatement", clauses = <list_of_IfClauses>, elseClause = <Block>? }
144+
{ kind = "WhileStatement", condition = <node>, body = <Block> }
145+
{ kind = "RepeatStatement", body = <Block>, condition = <node> }
146+
{ kind = "ForNumericStatement", variable = <Identifier>, start = <node>, limit = <node>, step = <node>?, body = <Block> }
147+
{ kind = "ForGenericStatement", iterators = <list_of_strings>, expressions = <list_of_nodes>, body = <Block> }
148+
{ kind = "DoStatement", body = <Block> }
149+
{ kind = "ReturnStatement", expressions = <list_of_nodes> }
150+
{ kind = "BreakStatement" }
151+
152+
-- Program Structure
153+
{ kind = "Block", statements = <list_of_statement> }
154+
{ kind = "Program", body = <Block> }
155+
```
154156

155157
</details>
156158

157159
### Support The Tiny Lua Compiler (TLC)
158160

159161
I don't take donations, but you can support TLC by starring the repository and sharing it with others.
160-
If you find a bug or have a feature request, feel free to open an issue or submit a pull request.
162+
If you find a bug or have a feature request, feel free to open an issue or submit a pull request.

0 commit comments

Comments
 (0)