Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pycomsdk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
com
pycomsdk
Commits
7ccebc95
Commit
7ccebc95
authored
Nov 07, 2019
by
Savva Golubitsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factory is near to ready, but some packages errors. Bruh, python
parent
ae66f747
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
7 deletions
+69
-7
parser.py
comsdk/parser.py
+28
-7
test.adot
comsdk/test.adot
+41
-0
No files found.
comsdk/parser.py
View file @
7ccebc95
import
re
import
graph
as
gr
from
edge
import
*
import
importlib
as
imp
from
typing
import
NamedTuple
from
enum
import
Enum
,
auto
...
...
@@ -41,6 +43,24 @@ class GraphFactory():
newstate
=
gr
.
State
(
statename
)
self
.
states
[
statename
]
=
newstate
def
_create_morphism
(
self
,
morphame
):
morph
=
entities
[
morphame
]
for
m
in
morph
.
__slots__
:
if
getattr
(
morph
,
m
)
!=
None
:
if
m
!=
"predicate"
and
m
!=
"function"
:
print
(
"ERROR: Morphisms could not have any params exept predicate and function!
\n
{}"
.
format
(
morphame
))
exit
(
0
)
if
m
==
"predicate"
:
pr
=
getattr
(
morph
,
m
)
pred_f
=
getattr
(
imp
.
import_module
(
pr
.
module
),
pr
.
entry_func
)
if
m
==
"function"
:
fu
=
getattr
(
morph
,
m
)
func_f
=
getattr
(
imp
.
import_module
(
fu
.
module
),
fu
.
entry_func
)
return
pred_f
,
func_f
def
connect_states
(
self
,
st1
,
st2
,
morphism
=
None
):
pass
# self.states[st1].connect_to(self.states[st2])
...
...
@@ -73,7 +93,7 @@ def check_brackets(rawfile):
#Props is line "[prop=smth, ...]"
#Props is line "[pro
F
p=smth, ...]"
def
param_from_props
(
props
):
parm
=
Params
()
props
=
props
.
replace
(
"]"
,
''
)
...
...
@@ -87,7 +107,7 @@ def param_from_props(props):
if
r
[
0
]
in
parm
.
__slots__
:
setattr
(
parm
,
r
[
0
],
r
[
1
])
else
:
print
(
"Unknown parameter: "
+
r
[
0
])
print
(
"
ERROR:
Unknown parameter: "
+
r
[
0
])
exit
(
-
1
)
return
parm
...
...
@@ -103,15 +123,15 @@ def param_from_topln(raw):
right
=
spl
[
2
]
.
split
(
","
)
if
len
(
spl
)
>
3
:
param_from_props
(
spl
[
3
])
if
(
len
(
left
)
!=
1
)
and
(
len
(
right
)
!=
1
):
if
(
len
(
left
)
>
1
)
and
(
len
(
right
)
>
1
):
print
(
"ERROR:Ambigious multiple connection in line:
\n\t
{}"
.
format
(
raw
))
exit
()
elif
len
(
left
)
==
2
:
elif
len
(
left
)
>
1
:
fact
.
add_state
(
right
[
0
])
for
st
in
left
:
fact
.
add_state
(
st
)
fact
.
connect_states
(
st
,
right
[
0
])
elif
len
(
right
)
==
2
:
elif
len
(
right
)
>
1
:
fact
.
add_state
(
left
[
0
])
for
st
in
right
:
fact
.
add_state
(
st
)
...
...
@@ -138,6 +158,7 @@ dot = re.sub(r"^\n$", "", dot)
#
#print("Graph id good, processing!")
#dot = re.sub(r"//*$", "", dot)
dotlines
=
dot
.
splitlines
()
dotlines
=
list
(
filter
(
None
,
dotlines
))
...
...
@@ -156,12 +177,12 @@ for i, ln in enumerate(dotlines):
elif
top_re
.
match
(
ln
):
param_from_topln
(
ln
)
for
e
in
entities
:
print
(
e
,
entities
[
e
])
print
(
"states:
\n
"
)
for
st
in
fact
.
states
:
print
(
st
)
for
e
in
entities
:
print
(
e
,
entities
[
e
])
exit
()
...
...
comsdk/test.adot
0 → 100644
View file @
7ccebc95
digraph CODEOBJECT_GENERATOR
{
// ??????????? ???????-????????????
FUNC_1 [module=case_gen_funcs, entry_func=function_1]
FUNC_2 [module=case_gen_funcs, entry_func=function_2]
FUNC_3 [module=case_gen_funcs, entry_func=function_3]
SAVE_TO_DB [module=case_gen_funcs, entry_func=save_to_db]
SAVE_TO_FILE [module=case_gen_funcs, entry_func=save_to_file]
REPEAT [module=case_gen_funcs, entry_func=repeat]
EXIT [module=case_gen_funcs, entry_func=exit]
CREATE_DUMP [module=case_gen_funcs, entry_func=create_dump]
// ??????????? ???????-??????????
PREDICATE_X [module=predicate_funcs, entry_func=predicate_x]
PREDICATE_Y [module=predicate_funcs, entry_func=predicate_y]
SELECTOR [module=predicate_funcs, entry_func=selector]
// ??????????? ??????? ???????? (????????)
EDGE_1 [predicate=PREDICATE_X, function=FUNC_1]
EDGE_2 [predicate=PREDICATE_Y, function=FUNC_2]
EDGE_3 [predicate=PREDICATE_X, function=FUNC_3]
EDGE_4 [predicate=PREDICATE_Y, function=SAVE_TO_DB]
EDGE_5 [predicate=PREDICATE_X, function=SAVE_TO_FILE]
EDGE_6 [predicate=PREDICATE_Y, function=REPEAT]
EDGE_7 [predicate=PREDICATE_X, function=EXIT]
EDGE_8 [function=EXIT]
EDGE_9 [predicate=CHECK_DUMP, function=EXIT]
EDGE_10 [function=CREATE_DUMP]
// ? ???? ??????? ????????? ?????????????????
CONTENT_SUBSTITUTED [parallelism=threading]
// ??????????? ???????? ??????
__BEGIN__ -> INPUT_READY
INPUT_READY -> TEPMLATE_COPIED [morphism=EDGE_1]
TEPMLATE_COPIED -> NAMES_SUBSTITUTED [morphism=EDGE_2]
NAMES_SUBSTITUTED -> CONTENT_SUBSTITUTED [morphism=EDGE_3]
CONTENT_SUBSTITUTED => DUMP_CREATED [morphism=EDGE_10]
CONTENT_SUBSTITUTED -> RESULT_SAVED [morphism=EDGE_4]
CONTENT_SUBSTITUTED -> RESULT_SAVED [morphism=EDGE_5]
// ? ??????????? ?? ?????? ?????????? SELECTOR ?????????????? ??????? ?? ??????? ??? ??????? ?????
RESULT_SAVED -> INPUT_READY, __END__ [selector=SELECTOR, morphism=(EDGE_6, EDGE_7)]
RESULT_SAVED, DUMP_CREATED -> __END__ [morphism=(EDGE_8, EDGE_9)]
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment