Skip to content

Commit 0ff0f65

Browse files
authored
Merge pull request #45 from vshcryabets/update/docs
Update documentation
2 parents e41ac0a + 9a89536 commit 0ff0f65

6 files changed

Lines changed: 252 additions & 10 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "90d2708c-0aad-4b6d-aa16-3630ccc4d243",
6+
"metadata": {},
7+
"source": [
8+
"# AST tree nodes\n",
9+
"\n",
10+
"**RValue** - something that can be assigned.\n",
11+
"\n",
12+
"**AstTypeLeaf** - string representation of variable/argument data type. Sample:\n",
13+
"```\n",
14+
"<ConstantNode>\n",
15+
" <Keyword name=\"static\"/>\n",
16+
" <AstTypeLeaf name=\"int\"/>\n",
17+
" <VariableName name=\"ModeStateOn\"/>\n",
18+
" <Keyword name=\"=\"/>\n",
19+
" <DataValue name=\"0\"/>\n",
20+
"</ConstantNode>\n",
21+
"```\n",
22+
"\n",
23+
"**ArgumentNode** - represents variables that are passed to the functon."
24+
]
25+
},
26+
{
27+
"cell_type": "code",
28+
"execution_count": null,
29+
"id": "ab11df09-20dc-4333-8967-a8210fa7f4ed",
30+
"metadata": {},
31+
"outputs": [],
32+
"source": []
33+
}
34+
],
35+
"metadata": {
36+
"kernelspec": {
37+
"display_name": "Kotlin",
38+
"language": "kotlin",
39+
"name": "kotlin"
40+
},
41+
"language_info": {
42+
"codemirror_mode": "text/x-kotlin",
43+
"file_extension": ".kt",
44+
"mimetype": "text/x-kotlin",
45+
"name": "kotlin",
46+
"nbconvert_exporter": "",
47+
"pygments_lexer": "kotlin",
48+
"version": "1.9.23"
49+
}
50+
},
51+
"nbformat": 4,
52+
"nbformat_minor": 5
53+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "784cd44d-5255-44e1-be5f-1228a11c6abf",
6+
"metadata": {},
7+
"source": [
8+
"Test kernel"
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": 16,
14+
"id": "5e7b1719-385f-4e80-a810-78735d094f5d",
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"@file:Repository(\"https://jitpack.io\")\n",
19+
"@file:DependsOn(\"com.github.vshcryabets:codegen:18c0114083\")"
20+
]
21+
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": null,
25+
"id": "6ff5ce0c-0952-4b9b-8ba4-3883f03d5ca9",
26+
"metadata": {},
27+
"outputs": [],
28+
"source": [
29+
"import ce.defs.DataType\n",
30+
"import ce.defs.DataValue\n",
31+
"import generators.obj.abstractSyntaxTree.DataClass\n",
32+
"import generators.obj.abstractSyntaxTree.DataField\n",
33+
"import generators.kotlin.PrepareRightValueUseCase\n",
34+
"\n",
35+
"val dataClassDescriptor = DataClass(\"c\").apply {\n",
36+
" field(\"A\", DataType.int32, 1)\n",
37+
"}\n",
38+
"\n",
39+
"print(dataClassDescriptor)\n"
40+
]
41+
},
42+
{
43+
"cell_type": "markdown",
44+
"id": "f3d7ec60-12d4-453e-be3d-20c6ca747810",
45+
"metadata": {},
46+
"source": [
47+
"# Input tree to AST transformations\n",
48+
"\n",
49+
"**PrepareRightValueUseCase** - convert input DataValue node to AST RValue.\n",
50+
"Sample of transformation, input:\n",
51+
"```\n",
52+
"DataField(\n",
53+
" value = DataValue() {\n",
54+
" NewInstance()\n",
55+
" }\n",
56+
")\n",
57+
"```"
58+
]
59+
},
60+
{
61+
"cell_type": "code",
62+
"execution_count": null,
63+
"id": "0b430479-4395-4b11-846d-f63537ffe4dc",
64+
"metadata": {},
65+
"outputs": [],
66+
"source": [
67+
"val dataField = DataField(\"varName\").apply {\n",
68+
" generators.obj.abstractSyntaxTree.setType(DataType.int32)\n",
69+
" generators.obj.abstractSyntaxTree.setValue(\"strValue\")\n",
70+
" }\n",
71+
"print(dataField)"
72+
]
73+
},
74+
{
75+
"cell_type": "code",
76+
"execution_count": null,
77+
"id": "73167612-b597-4f99-a2bf-0948c082c5e1",
78+
"metadata": {},
79+
"outputs": [],
80+
"source": [
81+
"val prepareRightValueUseCase = PrepareRightValueUseCase()\n",
82+
"val fileData = FileDataImpl(\"someFile.kt\")\n",
83+
"val rValue = prepareRightValueUseCase.toRightValue(dataField, fileData)\n",
84+
"print(rValue)"
85+
]
86+
}
87+
],
88+
"metadata": {
89+
"kernelspec": {
90+
"display_name": "Kotlin",
91+
"language": "kotlin",
92+
"name": "kotlin"
93+
},
94+
"language_info": {
95+
"codemirror_mode": "text/x-kotlin",
96+
"file_extension": ".kt",
97+
"mimetype": "text/x-kotlin",
98+
"name": "kotlin",
99+
"nbconvert_exporter": "",
100+
"pygments_lexer": "kotlin",
101+
"version": "1.9.23"
102+
}
103+
},
104+
"nbformat": 4,
105+
"nbformat_minor": 5
106+
}

.run/Uroborus.run.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Uroborus" type="Application" factoryName="Application">
3-
<option name="ALTERNATIVE_JRE_PATH" value="17" />
3+
<option name="ALTERNATIVE_JRE_PATH" value="corretto-17" />
4+
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
45
<option name="MAIN_CLASS_NAME" value="ce.entrypoints.BuildProjectKt" />
56
<module name="codegen.cgen-console.main" />
67
<option name="PROGRAM_PARAMETERS" value="--project ./project.json --storeOutTree --storeInTree" />

AstTransformations.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
},
1111
{
1212
"cell_type": "code",
13-
"execution_count": 16,
13+
"execution_count": null,
1414
"id": "5e7b1719-385f-4e80-a810-78735d094f5d",
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
1818
"@file:Repository(\"https://jitpack.io\")\n",
19-
"@file:DependsOn(\"com.github.vshcryabets:codegen:18c0114083\")"
19+
"@file:DependsOn(\"com.github.vshcryabets:codegen:e41ac0a16a\")"
2020
]
2121
},
2222
{
@@ -105,13 +105,13 @@
105105
"<RValue>\n",
106106
" <Constructor>\n",
107107
" <Arguments>\n",
108-
" <RValue>\n",
109-
" <VarName a><=><\"someValue\">\n",
110-
" </RValue>\n",
111-
" <,>\n",
112-
" <RValue>\n",
113-
" <VarName b><=><10>\n",
114-
" </RValue>\n",
108+
" <ArgumentNode>\n",
109+
" <VarName a><=><RValue \"someValue\">\n",
110+
" </ArgumentNode>\n",
111+
" <,>\n",
112+
" <ArgumentNode>\n",
113+
" <VarName b><=><RValue 10>\n",
114+
" </ArgumentNode>\n",
115115
" </Arguments>\n",
116116
" </Constructor>\n",
117117
"</RValue>\n",

Main.ipynb

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "f72be856a0eccf2e",
6+
"metadata": {},
7+
"source": [
8+
"# Trees\n",
9+
"\n",
10+
"1. **AST (Abstract Syntax Tree)** - The initial tree structure generated by parsing and/or executing the description files.\n",
11+
"1. **Syntax Parse Tree** - This tree is the result of applying transformation logic to the **AST** (see BuildOutTreeUseCase).\n",
12+
"1. **Stylistic Tree** - The final tree, which is produced by applying code style rules to the **Syntax Parse Tree** (see PrepareCodeStyleTreeUseCase).\n"
13+
]
14+
},
15+
{
16+
"cell_type": "code",
17+
"execution_count": null,
18+
"id": "e6a163c0aeed68e",
19+
"metadata": {},
20+
"outputs": [],
21+
"source": []
22+
}
23+
],
24+
"metadata": {
25+
"kernelspec": {
26+
"display_name": "Kotlin",
27+
"language": "kotlin",
28+
"name": "kotlin"
29+
},
30+
"language_info": {
31+
"codemirror_mode": "text/x-kotlin",
32+
"file_extension": ".kt",
33+
"mimetype": "text/x-kotlin",
34+
"name": "kotlin",
35+
"nbconvert_exporter": "",
36+
"pygments_lexer": "kotlin",
37+
"version": "1.9.23"
38+
}
39+
},
40+
"nbformat": 4,
41+
"nbformat_minor": 5
42+
}

SyntaxParseTreeClasses.ipynb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "f72be856a0eccf2e",
6+
"metadata": {},
7+
"source": [
8+
"# Syntax Parse tree nodes\n",
9+
"\n",
10+
"**ArgumentNode** - represents variables that are passed to the function.\n"
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": null,
16+
"id": "e6a163c0aeed68e",
17+
"metadata": {},
18+
"outputs": [],
19+
"source": []
20+
}
21+
],
22+
"metadata": {
23+
"kernelspec": {
24+
"display_name": "Kotlin",
25+
"language": "kotlin",
26+
"name": "kotlin"
27+
},
28+
"language_info": {
29+
"codemirror_mode": "text/x-kotlin",
30+
"file_extension": ".kt",
31+
"mimetype": "text/x-kotlin",
32+
"name": "kotlin",
33+
"nbconvert_exporter": "",
34+
"pygments_lexer": "kotlin",
35+
"version": "1.9.23"
36+
}
37+
},
38+
"nbformat": 4,
39+
"nbformat_minor": 5
40+
}

0 commit comments

Comments
 (0)