Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
17b20862
Commit
17b20862
authored
Aug 21, 2014
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to use formal grammar.
parent
c4c0acc5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
1 deletion
+41
-1
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+7
-0
Cython/Compiler/Options.py
Cython/Compiler/Options.py
+3
-0
Cython/Parser/ConcreteSyntaxTree.pyx
Cython/Parser/ConcreteSyntaxTree.pyx
+5
-0
Cython/Parser/__init__.py
Cython/Parser/__init__.py
+0
-0
setup.py
setup.py
+26
-1
No files found.
Cython/Compiler/Main.py
View file @
17b20862
...
...
@@ -304,6 +304,13 @@ class Context(object):
s
=
PyrexScanner
(
f
,
source_desc
,
source_encoding
=
f
.
encoding
,
scope
=
scope
,
context
=
self
)
tree
=
Parsing
.
p_module
(
s
,
pxd
,
full_module_name
)
if
Options
.
formal_grammar
:
try
:
from
..Parser
import
ConcreteSyntaxTree
except
ImportError
:
raise
RuntimeError
(
"Formal grammer can only be used with compiled Cython with an available pgen."
)
ConcreteSyntaxTree
.
p_module
(
source_filename
)
finally
:
f
.
close
()
except
UnicodeDecodeError
,
e
:
...
...
Cython/Compiler/Options.py
View file @
17b20862
...
...
@@ -80,6 +80,9 @@ closure_freelist_size = 8
# Should tp_clear() set object fields to None instead of clearing them to NULL?
clear_to_none
=
True
# Should we try parsing files with the formal grammar (experimental)?
formal_grammar
=
True
# Declare compiler directives
directive_defaults
=
{
...
...
Cython/Parser/ConcreteSyntaxTree.pyx
0 → 100644
View file @
17b20862
cdef
extern
from
"graminit.c"
:
pass
def
p_module
(
source
):
print
"Using formal grammar to parse"
,
source
Cython/Parser/__init__.py
0 → 100644
View file @
17b20862
setup.py
View file @
17b20862
...
...
@@ -4,6 +4,7 @@ try:
except
ImportError
:
from
distutils.core
import
setup
,
Extension
import
os
import
subprocess
import
sys
try
:
...
...
@@ -28,7 +29,7 @@ from distutils.command.sdist import sdist as sdist_orig
class
sdist
(
sdist_orig
):
def
run
(
self
):
self
.
force_manifest
=
1
if
(
sys
.
platform
!=
"win32"
and
if
(
sys
.
platform
!=
"win32"
and
os
.
path
.
isdir
(
'.git'
)):
assert
os
.
system
(
"git rev-parse --verify HEAD > .gitrev"
)
==
0
sdist_orig
.
run
(
self
)
...
...
@@ -119,6 +120,30 @@ def compile_cython_modules(profile=False, compile_more=False, cython_with_refnan
"Cython.Compiler.Optimize"
,
])
from
distutils.spawn
import
find_executable
from
distutils.sysconfig
import
get_python_inc
pgen
=
find_executable
(
'pgen'
,
os
.
pathsep
.
join
([
os
.
environ
[
'PATH'
],
os
.
path
.
join
(
get_python_inc
(),
'..'
,
'Parser'
)]))
if
not
pgen
:
print
"Unable to find pgen, not compiling formal grammar."
else
:
parser_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'Cython'
,
'Parser'
)
print
' '
.
join
([
pgen
,
os
.
path
.
join
(
get_python_inc
(),
'..'
,
'Grammar'
,
'Grammar'
),
os
.
path
.
join
(
parser_dir
,
'graminit.h'
),
os
.
path
.
join
(
parser_dir
,
'graminit.c'
),
])
subprocess
.
check_call
([
pgen
,
os
.
path
.
join
(
get_python_inc
(),
'..'
,
'Grammar'
,
'Grammar'
),
os
.
path
.
join
(
parser_dir
,
'graminit.h'
),
os
.
path
.
join
(
parser_dir
,
'graminit.c'
),
])
compiled_modules
.
extend
([
"Cython.Parser.ConcreteSyntaxTree"
,
])
defines
=
[]
if
cython_with_refnanny
:
defines
.
append
((
'CYTHON_REFNANNY'
,
'1'
))
...
...
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