Skip to content

Commit 93eaa1c

Browse files
authored
Merge pull request #12 from AdrianEpi/doc
Doc
2 parents 69dfde9 + 2ab047c commit 93eaa1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1185
-271
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ In order to run the project for the first time:
3232
```
3333
6) Activate the virtual enviroment
3434
```sh
35-
soruce .venv/bin/activate
35+
source .venv/bin/activate
3636
```
3737
7) Install all the packages
3838
```sh
39-
cd app/
4039
pip install -r requirements.txt
4140
```
4241
8) Install tkinter for interface display

app/modules/ast_module/AST.py

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
# -*- coding: utf-8 -*-
2+
# @Proyect: UMLConverter
3+
# @Author: Adrian Epifanio
4+
# @File: AST.py
5+
# @Author: Adrian Epifanio
6+
# @Date: 2023-01-16 12:20:25
7+
# @Email: adrianepi@gmail.com
8+
# @GitHub: https://github.com/AdrianEpi
9+
# @Last Modified by: Adrian Epifanio
10+
# @Last Modified time: 2023-02-02 12:12:15
11+
# @Description: This file describes an abstract ast class and all the node types that are going to be stored in data
12+
13+
14+
from abc import ABC, abstractmethod
15+
from app.modules.ast_module.pythonNode import PythonNode
16+
17+
18+
class AST(ABC):
19+
"""
20+
This class describes a python abstract class for ast.
21+
"""
22+
23+
tree: PythonNode()
24+
dataList: list
25+
26+
27+
def __init__ (self):
28+
"""
29+
Constructs a new instance.
30+
"""
31+
self.tree = PythonNode()
32+
self.dataList = []
33+
34+
35+
def getDataList (self) -> list:
36+
"""
37+
Gets the data list.
38+
39+
:returns: The data list.
40+
:rtype: list
41+
"""
42+
return self.dataList
43+
44+
45+
def getTree (self) -> PythonNode:
46+
"""
47+
Gets the tree.
48+
49+
:returns: The tree.
50+
:rtype: PythonNode
51+
"""
52+
return self.tree
53+
54+
55+
def setDataList (self, l: list):
56+
"""
57+
Sets the data list.
58+
59+
:param l: The new value
60+
:type l: list
61+
"""
62+
self.dataList = l
63+
64+
65+
def setTree (self, t: PythonNode):
66+
"""
67+
Sets the tree.
68+
69+
:param t: The new value
70+
:type t: PythonNode
71+
"""
72+
self.tree = t
73+
74+
75+
@abstractmethod
76+
def generateTree(self, l: list) -> bool:
77+
"""
78+
Generates the tree
79+
80+
:param l: list with nodes or lines
81+
:type l: list
82+
83+
:returns: True if the tree was generated correctly, false otherwise
84+
:rtype: bool
85+
"""
86+
pass
87+
88+
89+
@abstractmethod
90+
def __generateModule(self, pos = None, node = None) -> PythonNode:
91+
"""
92+
Generates a module
93+
94+
:param pos: The position
95+
:type pos: integer
96+
:param node: The node
97+
:type node: node
98+
99+
:returns: The python node.
100+
:rtype: PythonNode
101+
"""
102+
pass
103+
104+
105+
@abstractmethod
106+
def __generateClassDef(self, pos = None, node = None) -> PythonNode:
107+
"""
108+
Generate a class
109+
110+
:param pos: The position
111+
:type pos: integer
112+
:param node: The node
113+
:type node: node
114+
115+
:returns: The python node.
116+
:rtype: PythonNode
117+
"""
118+
pass
119+
120+
121+
@abstractmethod
122+
def __generateImport(self, pos = None, node = None) -> list or PythonNode:
123+
"""
124+
Generate an import
125+
126+
:param pos: The position
127+
:type pos: integer
128+
:param node: The node
129+
:type node: node
130+
131+
:returns: list with pythonNodes or a single pythonNode
132+
:rtype: list or PythonNode
133+
"""
134+
pass
135+
136+
137+
@abstractmethod
138+
def __generateImportFrom(self, pos = None, node = None) -> PythonNode:
139+
"""
140+
Generates an importFrom
141+
142+
:param pos: The position
143+
:type pos: integer
144+
:param node: The node
145+
:type node: node
146+
147+
:returns: The python node.
148+
:rtype: PythonNode
149+
"""
150+
pass
151+
152+
153+
@abstractmethod
154+
def __generateAssign(self, pos = None, node = None) -> list:
155+
"""
156+
Generates an assign
157+
158+
:param pos: The position
159+
:type pos: integer
160+
:param node: The node
161+
:type node: node
162+
163+
:returns: list with assigns
164+
:rtype: list
165+
"""
166+
pass
167+
168+
169+
@abstractmethod
170+
def __generateAnnAssign(self, pos = None, node = None) -> PythonNode:
171+
"""
172+
Generates an annassign
173+
174+
:param pos: The position
175+
:type pos: integer
176+
:param node: The node
177+
:type node: node
178+
179+
:returns: The python node.
180+
:rtype: PythonNode
181+
"""
182+
pass
183+
184+
185+
@abstractmethod
186+
def __generateAsyncFunctionDef(self, pos = None, node = None):
187+
"""
188+
Generates am asyncFunction
189+
190+
:param pos: The position
191+
:type pos: integer
192+
:param node: The node
193+
:type node: node
194+
"""
195+
pass
196+
197+
198+
@abstractmethod
199+
def __generateFunctionDef(self, pos = None, node = None) -> PythonNode:
200+
"""
201+
Generates a function
202+
203+
:param pos: The position
204+
:type pos: integer
205+
:param node: The node
206+
:type node: node
207+
208+
:returns: The python node.
209+
:rtype: PythonNode
210+
"""
211+
pass
212+
213+
214+
@abstractmethod
215+
def __generateNode(self, pos = None, ntype = None, node = None) -> PythonNode or list:
216+
"""
217+
Generates a pythonnode
218+
219+
:param pos: The position
220+
:type pos: integer
221+
:param ntype: The ntype
222+
:type ntype: string
223+
:param node: The node
224+
:type node: node
225+
226+
:returns: list of pythonnodes or pythonnode
227+
:rtype: PythonNode or list
228+
"""
229+
pass
230+
231+
232+
def printTree(self):
233+
"""
234+
Prints the PythonNode tree from the root.
235+
"""
236+
print(self.tree.toString())

0 commit comments

Comments
 (0)