-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME
More file actions
42 lines (36 loc) · 1.6 KB
/
README
File metadata and controls
42 lines (36 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
phlex is a simple pre-processor for flex .l files that
inserts code to wrap the lexer as a Python C extension.
phlex.py reads foo.l.in producing foo.l, which can
then be processed through flex in the normal way
using a flex.skl skeletion file which has a trivial
patch to include <Python.h> headers.
The resulting lex.yy.c then builds into a Python C
extension. See the doc directory for more
information.
OK, why? The original motivation for phlex was
to provide an easy way to use flex-based lexers
with Dave Beazley's ply module for Python,
which provides lex/yacc work-alike functionality
in a pure-Python environment. The lexer in ply,
however, depends on the Python re module which
requires that the entire source must be read into
memory as a single string. In it's original deployment
as a tool for teaching compiler classes, this is
perfectly sufficient. In a production environment,
however, there are two key limitiations. The first is
the obvious memory performance limitations imposed
by the requirement of having the entire source
file resident in memory. It also means that
interactive lexers, reading from the command
line or an internet socket are not possible.
In addition to these limitations, re simply
isn't as fast as a flex lexer.
phlex is a very simple script, and I consider
it a proof-of-concept vehicle. Ideally, the
functionality in phlex would someday be part of
flex's native functionality. I see phlex as a
way to inexpensively test the idea before
going crazy patching flex.
phlex is licensed under the GPL V3 or later,
see the COPYING file for more information.
Dave Curtis - 20-March-2013