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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
d037a456
Commit
d037a456
authored
Nov 16, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more cythonisation in the scanner/parser
parent
698b502d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
8 deletions
+34
-8
Cython/Plex/Actions.pxd
Cython/Plex/Actions.pxd
+25
-0
Cython/Plex/Actions.py
Cython/Plex/Actions.py
+5
-8
Cython/Plex/Scanners.pxd
Cython/Plex/Scanners.pxd
+3
-0
setup.py
setup.py
+1
-0
No files found.
Cython/Plex/Actions.pxd
0 → 100644
View file @
d037a456
cdef
class
Action
:
cdef
perform
(
self
,
token_stream
,
text
)
cpdef
same_as
(
self
,
other
)
cdef
class
Return
(
Action
):
cdef
object
value
cdef
perform
(
self
,
token_stream
,
text
)
cpdef
same_as
(
self
,
other
)
cdef
class
Call
(
Action
):
cdef
object
function
cdef
perform
(
self
,
token_stream
,
text
)
cpdef
same_as
(
self
,
other
)
cdef
class
Begin
(
Action
):
cdef
object
state_name
cdef
perform
(
self
,
token_stream
,
text
)
cpdef
same_as
(
self
,
other
)
cdef
class
Ignore
(
Action
):
cdef
perform
(
self
,
token_stream
,
text
)
cdef
class
Text
(
Action
):
cdef
perform
(
self
,
token_stream
,
text
)
Cython/Plex/Actions.py
View file @
d037a456
...
...
@@ -8,6 +8,9 @@
class
Action
(
object
):
def
perform
(
self
,
token_stream
,
text
):
pass
# abstract
def
same_as
(
self
,
other
):
return
self
is
other
...
...
@@ -18,8 +21,6 @@ class Return(Action):
be returned as the value of the associated token
"""
value
=
None
def
__init__
(
self
,
value
):
self
.
value
=
value
...
...
@@ -38,8 +39,6 @@ class Call(Action):
Internal Plex action which causes a function to be called.
"""
function
=
None
def
__init__
(
self
,
function
):
self
.
function
=
function
...
...
@@ -60,8 +59,6 @@ class Begin(Action):
for more information.
"""
state_name
=
None
def
__init__
(
self
,
state_name
):
self
.
state_name
=
state_name
...
...
@@ -88,7 +85,7 @@ class Ignore(Action):
return
"IGNORE"
IGNORE
=
Ignore
()
IGNORE
.
__doc__
=
Ignore
.
__doc__
#
IGNORE.__doc__ = Ignore.__doc__
class
Text
(
Action
):
"""
...
...
@@ -104,6 +101,6 @@ class Text(Action):
return
"TEXT"
TEXT
=
Text
()
TEXT
.
__doc__
=
Text
.
__doc__
#
TEXT.__doc__ = Text.__doc__
Cython/Plex/Scanners.pxd
View file @
d037a456
import
cython
from
Cython.Plex.Actions
cimport
Action
cdef
class
Scanner
:
cdef
public
lexicon
...
...
@@ -26,6 +28,7 @@ cdef class Scanner:
@
cython
.
locals
(
input_state
=
long
)
cdef
next_char
(
self
)
@
cython
.
locals
(
action
=
Action
)
cdef
tuple
read
(
self
)
cdef
tuple
scan_a_token
(
self
)
cdef
tuple
position
(
self
)
...
...
setup.py
View file @
d037a456
...
...
@@ -87,6 +87,7 @@ else:
def
compile_cython_modules
(
profile
=
False
):
source_root
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
compiled_modules
=
[
"Cython.Plex.Scanners"
,
"Cython.Plex.Actions"
,
"Cython.Compiler.Scanning"
,
"Cython.Compiler.Parsing"
,
"Cython.Compiler.Visitor"
,
...
...
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