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
b2afb116
Commit
b2afb116
authored
May 29, 2020
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce lexicon build time some more by compiling Transitions.py.
parent
0cf1419b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
14 deletions
+21
-14
Cython/Plex/Transitions.py
Cython/Plex/Transitions.py
+20
-14
setup.py
setup.py
+1
-0
No files found.
Cython/Plex/Transitions.py
View file @
b2afb116
...
...
@@ -5,12 +5,18 @@ This version represents state sets directly as dicts for speed.
"""
from
__future__
import
absolute_import
import
cython
cython
.
declare
(
maxint
=
cython
.
long
)
try
:
from
sys
import
maxsize
as
maxint
except
ImportError
:
from
sys
import
maxint
@
cython
.
final
@
cython
.
cclass
class
TransitionMap
(
object
):
"""
A TransitionMap maps an input event to a set of states.
...
...
@@ -39,23 +45,22 @@ class TransitionMap(object):
kept separately in a dictionary.
"""
map
=
None
# The list of codes and states
special
=
None
# Mapping for special events
cython
.
declare
(
map
=
list
,
special
=
dict
)
def
__init__
(
self
,
map
=
None
,
special
=
None
):
if
not
map
:
map
=
[
-
maxint
,
{},
maxint
]
if
not
special
:
special
=
{}
self
.
map
=
map
self
.
special
=
special
self
.
map
=
map
# The list of codes and states
self
.
special
=
special
# Mapping for special events
def
add
(
self
,
event
,
new_state
,
TupleType
=
tupl
e
):
@
cython
.
locals
(
i
=
cython
.
Py_ssize_t
,
j
=
cython
.
Py_ssize_t
,
map
=
list
)
def
add
(
self
,
event
,
new_stat
e
):
"""
Add transition to |new_state| on |event|.
"""
if
type
(
event
)
is
TupleTyp
e
:
if
type
(
event
)
is
tupl
e
:
code0
,
code1
=
event
i
=
self
.
split
(
code0
)
j
=
self
.
split
(
code1
)
...
...
@@ -66,12 +71,12 @@ class TransitionMap(object):
else
:
self
.
get_special
(
event
)[
new_state
]
=
1
def
add_set
(
self
,
event
,
new_set
,
TupleType
=
tuple
):
@
cython
.
locals
(
i
=
cython
.
Py_ssize_t
,
j
=
cython
.
Py_ssize_t
,
map
=
list
)
def
add_set
(
self
,
event
,
new_set
):
"""
Add transitions to the states in |new_set| on |event|.
"""
if
type
(
event
)
is
TupleTyp
e
:
if
type
(
event
)
is
tupl
e
:
code0
,
code1
=
event
i
=
self
.
split
(
code0
)
j
=
self
.
split
(
code1
)
...
...
@@ -88,8 +93,8 @@ class TransitionMap(object):
"""
return
self
.
special
.
get
(
''
)
def
iteritems
(
self
,
len
=
len
):
@
cython
.
locals
(
map
=
list
,
i
=
cython
.
Py_ssize_t
,
n
=
cython
.
Py_ssize_t
,
else_set
=
cython
.
bint
)
def
iteritems
(
self
):
"""
Return the mapping as an iterable of ((code1, code2), state_set) and
(special_event, state_set) pairs.
...
...
@@ -116,8 +121,9 @@ class TransitionMap(object):
# ------------------- Private methods --------------------
def
split
(
self
,
code
,
len
=
len
,
maxint
=
maxint
):
@
cython
.
ccall
@
cython
.
locals
(
map
=
list
,
lo
=
cython
.
Py_ssize_t
,
mid
=
cython
.
Py_ssize_t
,
hi
=
cython
.
Py_ssize_t
,
code
=
cython
.
long
)
def
split
(
self
,
code
):
"""
Search the list for the position of the split point for |code|,
inserting a new split point if necessary. Returns index |i| such
...
...
setup.py
View file @
b2afb116
...
...
@@ -85,6 +85,7 @@ def compile_cython_modules(profile=False, compile_more=False, cython_with_refnan
"Cython.Plex.Scanners"
,
"Cython.Plex.Actions"
,
"Cython.Plex.Machines"
,
"Cython.Plex.Transitions"
,
"Cython.Compiler.Scanning"
,
"Cython.Compiler.Visitor"
,
"Cython.Compiler.FlowControl"
,
...
...
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