FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java2python/java2python/compiler/__init__.py at master · kurtli/java2python · GitHub
kurtli
/
java2python
Public
forked from
natural/java2python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java2python
/
java2python
/
compiler
/
__init__.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (30 loc) · 1.26 KB
Breadcrumbs
java2python
/
java2python
/
compiler
/
__init__.py
Copy path
File metadata and controls
37 lines (30 loc) · 1.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# java2python.compiler package marker.
#
# This module provides a simpler facade over the rest of the compiler
# subpackage. Client code should use the values in this module
# instead of using directly referencing items within the subpackage.
from
java2python
.
compiler
.
block
import
Module
from
java2python
.
lang
import
Lexer
,
Parser
,
StringStream
,
TokenStream
,
TreeAdaptor
def
buildAST
(
source
):
""" Returns an AST for the given source. """
lexer
=
Lexer
(
StringStream
(
source
))
parser
=
Parser
(
TokenStream
(
lexer
))
adapter
=
TreeAdaptor
(
lexer
,
parser
)
parser
.
setTreeAdaptor
(
adapter
)
scope
=
parser
.
javaSource
()
return
scope
.
tree
def
buildJavaDocAST
(
source
):
""" Returns an AST for the given javadoc source. """
from
java2python
.
lang
.
JavaDocLexer
import
JavaDocLexer
from
java2python
.
lang
.
JavaDocParser
import
JavaDocParser
lexer
=
JavaDocLexer
(
StringStream
(
source
))
parser
=
JavaDocParser
(
TokenStream
(
lexer
))
scope
=
parser
.
commentBody
()
return
scope
.
tree
def
transformAST
(
tree
,
config
):
""" Walk the tree and apply the transforms in the config. """
for
selector
,
call
in
config
.
last
(
'astTransforms'
, ()):
for
node
in
selector
.
walk
(
tree
):
call
(
node
,
config
)
Back
|
FazBrowse Home
|
New Git URL