Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
anpl4mc
Overview
Overview
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
Ziyuan Nan
anpl4mc
Commits
85ada63a
Commit
85ada63a
authored
Oct 17, 2023
by
nzy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dependencies in order of appearence
parent
f7a00c05
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
9 deletions
+26
-9
.gitignore
+4
-2
anplc.py
+7
-1
lib.py
+1
-2
sketch_analysis.py
+4
-2
synthesis.py
+10
-2
No files found.
.gitignore
View file @
85ada63a
__pycache__/*
js/node_modules/*
\ No newline at end of file
js/node_modules/*
node_modules/*
descriptions/*.json
\ No newline at end of file
anplc.py
View file @
85ada63a
...
...
@@ -6,6 +6,7 @@ import os
import
tempfile
import
asyncio
from
pathlib
import
Path
import
re
dest_lib
=
Path
(
"./descriptions"
)
fun_lib
=
Path
(
"./js"
)
...
...
@@ -37,10 +38,15 @@ def input_content(content):
content
=
f
.
read
()
return
content
require_pattern
=
r"const \{ ([^}]+) \} = require\('\.\/\1\.js'\);"
exports_pattern
=
r"exports\.(?P<hole2>[a-zA-Z_]\w*) = \1;\s*"
def
sketch
(
fun_name
):
if
(
path
:
=
fun_lib
/
f
"{fun_name}.js"
)
.
exists
():
with
open
(
path
,
"r"
)
as
f
:
content
=
f
.
read
()
raw_content
=
f
.
read
()
content
=
re
.
sub
(
require_pattern
,
''
,
raw_content
)
content
=
re
.
sub
(
exports_pattern
,
''
,
content
)
content
=
content
.
strip
()
else
:
content
=
sketch_template
(
fun_name
)
code
=
input_content
(
content
)
...
...
lib.py
View file @
85ada63a
...
...
@@ -40,8 +40,7 @@ def create_sketch(fun_name, code):
for
hole
in
holes
:
final_code
.
append
(
f
"const {{ {hole} }} = require('./{hole}.js');"
)
final_code
.
append
(
code
)
if
not
code
.
split
(
"
\n
"
)[
-
1
]
.
startswith
(
"exports"
):
final_code
.
append
(
f
"exports.{fun_name} = {fun_name};"
)
final_code
.
append
(
f
"exports.{fun_name} = {fun_name};"
)
final_code
=
"
\n
"
.
join
(
final_code
)
with
open
(
fun_lib
/
f
"{fun_name}.js"
,
"w"
)
as
f
:
...
...
sketch_analysis.py
View file @
85ada63a
...
...
@@ -7,7 +7,7 @@ def find_holes(fun_name):
result
=
subprocess
.
run
(
cmd
,
capture_output
=
True
,
text
=
True
,
shell
=
True
)
holes
=
set
()
holes
=
[]
eslint_output
=
json
.
loads
(
result
.
stdout
)
for
item
in
eslint_output
:
messages
=
item
.
get
(
'messages'
,
[])
...
...
@@ -15,7 +15,9 @@ def find_holes(fun_name):
if
message
.
get
(
'ruleId'
)
==
'no-undef'
:
m
=
re
.
search
(
r"'(.*?)' is not defined"
,
message
.
get
(
"message"
))
if
m
:
holes
.
add
(
m
.
group
(
1
))
name
=
m
.
group
(
1
)
if
name
not
in
holes
:
holes
.
append
(
name
)
return
holes
if
__name__
==
"__main__"
:
...
...
synthesis.py
View file @
85ada63a
...
...
@@ -30,4 +30,12 @@ async def synthesis():
dest
=
json
.
load
(
f
)
if
dest
[
"state"
]
==
"x"
:
names
.
append
(
dest_path
.
stem
)
await
asyncio
.
gather
(
*
[
synthesis_1
(
fun
)
for
fun
in
names
])
\ No newline at end of file
await
asyncio
.
gather
(
*
[
synthesis_1
(
fun
)
for
fun
in
names
])
async
def
synthesis_1_inorder
(
fun_name
):
dest_path
=
dest_lib
/
f
"{fun_name}.json"
with
open
(
dest_path
,
"r"
)
as
f
:
dependencies
=
json
.
load
(
f
)[
"dependencies"
]
for
name
in
dependencies
:
await
synthesis_1
(
name
)
\ 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