Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .ipynb_checkpoints/AstClasses-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "90d2708c-0aad-4b6d-aa16-3630ccc4d243",
"metadata": {},
"source": [
"# AST tree nodes\n",
"\n",
"**RValue** - something that can be assigned.\n",
"\n",
"**AstTypeLeaf** - string representation of variable/argument data type. Sample:\n",
"```\n",
"<ConstantNode>\n",
" <Keyword name=\"static\"/>\n",
" <AstTypeLeaf name=\"int\"/>\n",
" <VariableName name=\"ModeStateOn\"/>\n",
" <Keyword name=\"=\"/>\n",
" <DataValue name=\"0\"/>\n",
"</ConstantNode>\n",
"```\n",
"\n",
"**ArgumentNode** - represents variables that are passed to the functon."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ab11df09-20dc-4333-8967-a8210fa7f4ed",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Kotlin",
"language": "kotlin",
"name": "kotlin"
},
"language_info": {
"codemirror_mode": "text/x-kotlin",
"file_extension": ".kt",
"mimetype": "text/x-kotlin",
"name": "kotlin",
"nbconvert_exporter": "",
"pygments_lexer": "kotlin",
"version": "1.9.23"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
106 changes: 106 additions & 0 deletions .ipynb_checkpoints/AstTransformations-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "784cd44d-5255-44e1-be5f-1228a11c6abf",
"metadata": {},
"source": [
"Test kernel"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "5e7b1719-385f-4e80-a810-78735d094f5d",
"metadata": {},
"outputs": [],
"source": [
"@file:Repository(\"https://jitpack.io\")\n",
"@file:DependsOn(\"com.github.vshcryabets:codegen:18c0114083\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6ff5ce0c-0952-4b9b-8ba4-3883f03d5ca9",
"metadata": {},
"outputs": [],
"source": [
"import ce.defs.DataType\n",
"import ce.defs.DataValue\n",
"import generators.obj.abstractSyntaxTree.DataClass\n",
"import generators.obj.abstractSyntaxTree.DataField\n",
"import generators.kotlin.PrepareRightValueUseCase\n",
"\n",
"val dataClassDescriptor = DataClass(\"c\").apply {\n",
" field(\"A\", DataType.int32, 1)\n",
"}\n",
"\n",
"print(dataClassDescriptor)\n"
]
},
{
"cell_type": "markdown",
"id": "f3d7ec60-12d4-453e-be3d-20c6ca747810",
"metadata": {},
"source": [
"# Input tree to AST transformations\n",
"\n",
"**PrepareRightValueUseCase** - convert input DataValue node to AST RValue.\n",
"Sample of transformation, input:\n",
"```\n",
"DataField(\n",
" value = DataValue() {\n",
" NewInstance()\n",
" }\n",
")\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0b430479-4395-4b11-846d-f63537ffe4dc",
"metadata": {},
"outputs": [],
"source": [
"val dataField = DataField(\"varName\").apply {\n",
" generators.obj.abstractSyntaxTree.setType(DataType.int32)\n",
" generators.obj.abstractSyntaxTree.setValue(\"strValue\")\n",
" }\n",
"print(dataField)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "73167612-b597-4f99-a2bf-0948c082c5e1",
"metadata": {},
"outputs": [],
"source": [
"val prepareRightValueUseCase = PrepareRightValueUseCase()\n",
"val fileData = FileDataImpl(\"someFile.kt\")\n",
"val rValue = prepareRightValueUseCase.toRightValue(dataField, fileData)\n",
"print(rValue)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Kotlin",
"language": "kotlin",
"name": "kotlin"
},
"language_info": {
"codemirror_mode": "text/x-kotlin",
"file_extension": ".kt",
"mimetype": "text/x-kotlin",
"name": "kotlin",
"nbconvert_exporter": "",
"pygments_lexer": "kotlin",
"version": "1.9.23"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
3 changes: 2 additions & 1 deletion .run/Uroborus.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Uroborus" type="Application" factoryName="Application">
<option name="ALTERNATIVE_JRE_PATH" value="17" />
<option name="ALTERNATIVE_JRE_PATH" value="corretto-17" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="MAIN_CLASS_NAME" value="ce.entrypoints.BuildProjectKt" />
<module name="codegen.cgen-console.main" />
<option name="PROGRAM_PARAMETERS" value="--project ./project.json --storeOutTree --storeInTree" />
Expand Down
18 changes: 9 additions & 9 deletions AstTransformations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"id": "5e7b1719-385f-4e80-a810-78735d094f5d",
"metadata": {},
"outputs": [],
"source": [
"@file:Repository(\"https://jitpack.io\")\n",
"@file:DependsOn(\"com.github.vshcryabets:codegen:18c0114083\")"
"@file:DependsOn(\"com.github.vshcryabets:codegen:e41ac0a16a\")"
]
},
{
Expand Down Expand Up @@ -105,13 +105,13 @@
"<RValue>\n",
" <Constructor>\n",
" <Arguments>\n",
" <RValue>\n",
" <VarName a><=><\"someValue\">\n",
" </RValue>\n",
" <,>\n",
" <RValue>\n",
" <VarName b><=><10>\n",
" </RValue>\n",
" <ArgumentNode>\n",
" <VarName a><=><RValue \"someValue\">\n",
" </ArgumentNode>\n",
" <,>\n",
" <ArgumentNode>\n",
" <VarName b><=><RValue 10>\n",
" </ArgumentNode>\n",
" </Arguments>\n",
" </Constructor>\n",
"</RValue>\n",
Expand Down
42 changes: 42 additions & 0 deletions Main.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "f72be856a0eccf2e",
"metadata": {},
"source": [
"# Trees\n",
"\n",
"1. **AST (Abstract Syntax Tree)** - The initial tree structure generated by parsing and/or executing the description files.\n",
"1. **Syntax Parse Tree** - This tree is the result of applying transformation logic to the **AST** (see BuildOutTreeUseCase).\n",
"1. **Stylistic Tree** - The final tree, which is produced by applying code style rules to the **Syntax Parse Tree** (see PrepareCodeStyleTreeUseCase).\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e6a163c0aeed68e",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Kotlin",
"language": "kotlin",
"name": "kotlin"
},
"language_info": {
"codemirror_mode": "text/x-kotlin",
"file_extension": ".kt",
"mimetype": "text/x-kotlin",
"name": "kotlin",
"nbconvert_exporter": "",
"pygments_lexer": "kotlin",
"version": "1.9.23"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
40 changes: 40 additions & 0 deletions SyntaxParseTreeClasses.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "f72be856a0eccf2e",
"metadata": {},
"source": [
"# Syntax Parse tree nodes\n",
"\n",
"**ArgumentNode** - represents variables that are passed to the function.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e6a163c0aeed68e",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Kotlin",
"language": "kotlin",
"name": "kotlin"
},
"language_info": {
"codemirror_mode": "text/x-kotlin",
"file_extension": ".kt",
"mimetype": "text/x-kotlin",
"name": "kotlin",
"nbconvert_exporter": "",
"pygments_lexer": "kotlin",
"version": "1.9.23"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading