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
7190799a
Commit
7190799a
authored
May 29, 2020
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A bit more cythonisation in Machines.py and Transitions.py.
parent
b2afb116
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
+21
-7
Cython/Plex/Machines.pxd
Cython/Plex/Machines.pxd
+12
-0
Cython/Plex/Machines.py
Cython/Plex/Machines.py
+8
-7
Cython/Plex/Transitions.py
Cython/Plex/Transitions.py
+1
-0
No files found.
Cython/Plex/Machines.pxd
View file @
7190799a
cimport
cython
@
cython
.
final
cdef
class
Node
:
cdef
readonly
object
transitions
# TransitionMap
cdef
readonly
object
action
# Action
cdef
public
object
epsilon_closure
# dict
cdef
readonly
Py_ssize_t
number
cdef
readonly
long
action_priority
@
cython
.
final
cdef
class
FastMachine
:
cdef
readonly
dict
initial_states
cdef
readonly
dict
new_state_template
...
...
Cython/Plex/Machines.py
View file @
7190799a
...
...
@@ -68,17 +68,15 @@ class Machine(object):
class
Node
(
object
):
"""A state of an NFA or DFA."""
transitions
=
None
# TransitionMap
action
=
None
# Action
action_priority
=
None
# integer
number
=
0
# for debug output
epsilon_closure
=
None
# used by nfa_to_dfa()
def
__init__
(
self
):
# Preinitialise the list of empty transitions, because
# the nfa-to-dfa algorithm needs it
self
.
transitions
=
TransitionMap
()
self
.
action_priority
=
LOWEST_PRIORITY
self
.
transitions
=
TransitionMap
()
# TransitionMap
self
.
action_priority
=
LOWEST_PRIORITY
# integer
self
.
action
=
None
# Action
self
.
number
=
0
# for debug output
self
.
epsilon_closure
=
None
# used by nfa_to_dfa()
def
destroy
(
self
):
self
.
transitions
=
None
...
...
@@ -127,6 +125,9 @@ class Node(object):
def
__lt__
(
self
,
other
):
return
self
.
number
<
other
.
number
def
__hash__
(
self
):
return
id
(
self
)
class
FastMachine
(
object
):
"""
...
...
Cython/Plex/Transitions.py
View file @
7190799a
...
...
@@ -153,6 +153,7 @@ class TransitionMap(object):
map
[
hi
:
hi
]
=
[
code
,
map
[
hi
-
1
].
copy
()]
return
hi
@
cython
.
ccall
def
get_special
(
self
,
event
):
"""
Get state set for special event, adding a new entry if necessary.
...
...
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