Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pybison
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
pybison
Commits
3e04c23b
Commit
3e04c23b
authored
Dec 01, 2011
by
Sander Mathijs van Veen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup in pyrex code to make it compatible with Cython.
parent
0bdb2622
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
22 deletions
+19
-22
src/pyrex/bison_.pyx
src/pyrex/bison_.pyx
+19
-22
No files found.
src/pyrex/bison_.pyx
View file @
3e04c23b
...
@@ -69,7 +69,7 @@ cdef extern from "stdarg.h":
...
@@ -69,7 +69,7 @@ cdef extern from "stdarg.h":
# Callback function which is invoked by target handlers
# Callback function which is invoked by target handlers
# within the C yyparse() function.
# within the C yyparse() function.
import
signal
#
import signal
cdef
public
object
py_callback
(
object
parser
,
char
*
target
,
int
option
,
\
cdef
public
object
py_callback
(
object
parser
,
char
*
target
,
int
option
,
\
int
nargs
,
...):
int
nargs
,
...):
...
@@ -78,11 +78,8 @@ cdef public object py_callback(object parser, char *target, int option, \
...
@@ -78,11 +78,8 @@ cdef public object py_callback(object parser, char *target, int option, \
cdef
va_list
ap
cdef
va_list
ap
va_start
(
ap
,
<
int
>
nargs
)
va_start
(
ap
,
<
int
>
nargs
)
cdef
void
*
objptr
cdef
object
obj
cdef
object
valobj
cdef
object
valobj
cdef
void
*
val
cdef
void
*
val
cdef
char
*
tokval
cdef
char
*
termname
cdef
char
*
termname
#if parser.verbose:
#if parser.verbose:
...
@@ -130,7 +127,6 @@ cdef public object py_callback(object parser, char *target, int option, \
...
@@ -130,7 +127,6 @@ cdef public object py_callback(object parser, char *target, int option, \
# callback routine for reading input
# callback routine for reading input
cdef
public
void
py_input
(
object
parser
,
char
*
buf
,
int
*
result
,
int
max_size
):
cdef
public
void
py_input
(
object
parser
,
char
*
buf
,
int
*
result
,
int
max_size
):
cdef
char
*
buf1
cdef
int
buflen
cdef
int
buflen
if
parser
.
verbose
:
if
parser
.
verbose
:
...
@@ -284,7 +280,6 @@ cdef class ParserEngine:
...
@@ -284,7 +280,6 @@ cdef class ParserEngine:
3. Compiling bison/lex files to C
3. Compiling bison/lex files to C
4. Compiling the C files, and link into a dynamic lib
4. Compiling the C files, and link into a dynamic lib
"""
"""
cdef
char
*
incdir
# -------------------------------------------------
# -------------------------------------------------
# rip the pertinent grammar specs from parser class
# rip the pertinent grammar specs from parser class
...
@@ -320,7 +315,7 @@ cdef class ParserEngine:
...
@@ -320,7 +315,7 @@ cdef class ParserEngine:
f
=
open
(
buildDirectory
+
parser
.
bisonFile
,
"w"
)
f
=
open
(
buildDirectory
+
parser
.
bisonFile
,
"w"
)
write
=
f
.
write
write
=
f
.
write
writelines
=
f
.
writelines
#
writelines = f.writelines
# grammar file prologue
# grammar file prologue
write
(
"
\
n
"
.
join
([
write
(
"
\
n
"
.
join
([
...
@@ -374,8 +369,8 @@ cdef class ParserEngine:
...
@@ -374,8 +369,8 @@ cdef class ParserEngine:
tmp
=
[]
tmp
=
[]
#print "options = %s" % repr(options)
#print "options = %s" % repr(options)
opts
=
options
.
split
(
"|"
)
#
opts = options.split("|")
#print "opts = %s" % repr(opts)
#
#
print "opts = %s" % repr(opts)
r
=
unquoted
%
r"\
|
"
r
=
unquoted
%
r"\
|
"
#print "
r
=
<%
s
>
" % r
#print "
r
=
<%
s
>
" % r
opts1 = re.split(r, "
" + options)
opts1 = re.split(r, "
" + options)
...
@@ -406,9 +401,10 @@ cdef class ParserEngine:
...
@@ -406,9 +401,10 @@ cdef class ParserEngine:
action = action + ' $$ = (*py_callback)(
\
n
py_parser, "
%
s
", %s, %%s' %
\
action = action + ' $$ = (*py_callback)(
\
n
py_parser, "
%
s
", %s, %%s' %
\
(rule[0], idx) # note we're deferring the substitution of 'nterms' (last arg)
(rule[0], idx) # note we're deferring the substitution of 'nterms' (last arg)
args = []
args = []
i = -1
if nterms == 0:
if nterms == 0:
args.append('NULL')
args.append('NULL')
i = -1
else:
else:
for i in range(nterms):
for i in range(nterms):
if option[i] == '%prec':
if option[i] == '%prec':
...
@@ -498,8 +494,8 @@ cdef class ParserEngine:
...
@@ -498,8 +494,8 @@ cdef class ParserEngine:
f
.
close
()
f
.
close
()
# create and set up a compiler object
# create and set up a compiler object
ccompiler
=
distutils
.
ccompiler
.
new_compiler
(
verbose
=
parser
.
verbose
)
env
=
distutils
.
ccompiler
.
new_compiler
(
verbose
=
parser
.
verbose
)
ccompiler
.
set_include_dirs
([
distutils
.
sysconfig
.
get_python_inc
()])
env
.
set_include_dirs
([
distutils
.
sysconfig
.
get_python_inc
()])
# -----------------------------------------
# -----------------------------------------
# Now run bison on the grammar file
# Now run bison on the grammar file
...
@@ -509,7 +505,7 @@ cdef class ParserEngine:
...
@@ -509,7 +505,7 @@ cdef class ParserEngine:
if
parser
.
verbose
:
if
parser
.
verbose
:
print
'bison cmd:'
,
' '
.
join
(
bisonCmd
)
print
'bison cmd:'
,
' '
.
join
(
bisonCmd
)
ccompiler
.
spawn
(
bisonCmd
)
env
.
spawn
(
bisonCmd
)
if
parser
.
verbose
:
if
parser
.
verbose
:
print
"renaming bison output files"
print
"renaming bison output files"
...
@@ -536,7 +532,7 @@ cdef class ParserEngine:
...
@@ -536,7 +532,7 @@ cdef class ParserEngine:
if
parser
.
verbose
:
if
parser
.
verbose
:
print
'flex cmd:'
,
' '
.
join
(
flexCmd
)
print
'flex cmd:'
,
' '
.
join
(
flexCmd
)
ccompiler
.
spawn
(
flexCmd
)
env
.
spawn
(
flexCmd
)
if
os
.
path
.
isfile
(
buildDirectory
+
parser
.
flexCFile1
):
if
os
.
path
.
isfile
(
buildDirectory
+
parser
.
flexCFile1
):
os
.
unlink
(
buildDirectory
+
parser
.
flexCFile1
)
os
.
unlink
(
buildDirectory
+
parser
.
flexCFile1
)
...
@@ -551,15 +547,15 @@ cdef class ParserEngine:
...
@@ -551,15 +547,15 @@ cdef class ParserEngine:
# Now compile the files into a shared lib
# Now compile the files into a shared lib
# compile bison and lex c sources
# compile bison and lex c sources
#bisonObj =
ccompiler
.compile([parser.bisonCFile1])
#bisonObj =
env
.compile([parser.bisonCFile1])
#lexObj =
ccompiler
.compile([parser.flexCFile1])
#lexObj =
env
.compile([parser.flexCFile1])
#cl /DWIN32 /G4 /Gs /Oit /MT /nologo /W3 /WX bisondynlib-win32.c /Id:\python23\include
#cl /DWIN32 /G4 /Gs /Oit /MT /nologo /W3 /WX bisondynlib-win32.c /Id:\python23\include
#cc.compile(['bisondynlib-win32.c'],
#cc.compile(['bisondynlib-win32.c'],
# extra_preargs=['/DWIN32', '/G4', '/Gs', '/Oit', '/MT', '/nologo', '/W3', '/WX', '/Id:\python23\include'])
# extra_preargs=['/DWIN32', '/G4', '/Gs', '/Oit', '/MT', '/nologo', '/W3', '/WX', '/Id:\python23\include'])
# link 'em into a shared lib
# link 'em into a shared lib
objs
=
ccompiler
.
compile
([
buildDirectory
+
parser
.
bisonCFile1
,
objs
=
env
.
compile
([
buildDirectory
+
parser
.
bisonCFile1
,
buildDirectory
+
parser
.
flexCFile1
],
buildDirectory
+
parser
.
flexCFile1
],
extra_preargs
=
parser
.
cflags_pre
,
extra_preargs
=
parser
.
cflags_pre
,
extra_postargs
=
parser
.
cflags_post
,
extra_postargs
=
parser
.
cflags_post
,
...
@@ -576,8 +572,9 @@ cdef class ParserEngine:
...
@@ -576,8 +572,9 @@ cdef class ParserEngine:
if
parser
.
verbose
:
if
parser
.
verbose
:
print
'linking: %s => %s'
%
(
', '
.
join
(
objs
),
libFileName
)
print
'linking: %s => %s'
%
(
', '
.
join
(
objs
),
libFileName
)
ccompiler
.
link_shared_object
(
objs
,
libFileName
)
env
.
link_shared_object
(
objs
,
libFileName
)
#cdef char *incdir
#incdir = PyString_AsString(get_python_inc())
#incdir = PyString_AsString(get_python_inc())
#bisondynlib_build(self.libFilename_py, incdir)
#bisondynlib_build(self.libFilename_py, incdir)
...
...
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