DESCRIPTION

Ptlex is a scanner generator for Flex-like input files. Written in the crossplatform Tcl-scripting language it can be used to translated Flex-like input files for the scripting languages Perl, Python, Ruby, and Tcl into standalone applications.

INSTALLATION

$ tclkit-runtime /path/to/ptlex.kit

This should display something like:

This is ptlex - A Tcl based flexlike scanner generator.
$Revision: 1.26 $

How to use ptlex:

tclkit-runtime ptlex.kit [options] flexfile outfile

Valid options are:
-+                   Object Oriented scanner (Tcl, Perl and Python)
--buffersize num     Set buffersize of scanner to num
--flexfile file      Set flexfile
...

Your installation is done.

USAGE

$ tclkit-runtime ptlex.kit [options] lexfile outfile

The following options are implemented:

  • -+ creates an object oriented scanner (only for Tcl, Perl and Python)
  • --buffersize num sets the buffersize to be read in chunkwise to num
  • --flexfile file explicitly specifies the name of the flexfile
  • --help prints out a help message how to run the scanner
  • -i creates a case insensitve scanner
  • --lang sets the programming language for the flexfile
  • -o <filename>, --outfile <filename> set the filename for the application file
  • -P <pref>, --prefix <pref> set the prefix for functions, variables, objects (default yy)
  • -S <file>, --skeleton_file <file> set skeleton_file for creating the scanner
  • -v, -V, --version returns the ptlex version and exits
  • --license Display license (BSD)

EXAMPLES

Lets assume we hava flex input file written in Tcl whic counts the number of characters, lines and words in files like the unix tool wc. This file is called wc.ftl. The source can be viewed here

$ head samples/wc.ftl

%{
    global nline nword nchar
    set nline 0
    set nword 0
    set nchar 0
%}

%option buffersize=1024

$ tclkit85 ptlex.kit samples/wc.ftl samples/wc.tcl
Success: Language=tcl  Script-file=samples/wc.tcl generated!
$ tclkit85 samples/wc.tcl samples/wc.tcl
    144     507    3847 samples/wc.tcl

Let's compare the results with the original

$ wc samples/wc.tcl
 144  507 3847 samples/wc.tcl

SAMPLES

Source code for samples at sourceforge:

Lang \ Code

wc replacer sbs
Perl wc.fpl

replacer.fpl

sbs.fpl

Perl-OO

wc_oo.fpl

NA

sbs_oo.fpl

Python

wc.fpy

replacer.fpy

sbs.fpy

Python-OO

wc_oo.fpy

replacer_oo.fpy

sbs_oo.fpy

Ruby

wc.frb

replacer.frb

sbs.frb

Tcl

wc.ftl

replacer.ftl

sbs.ftl

Tcl-OO

wc_oo.ftl

replacer_oo.ftl

sbs_oo.ftl

LICENSE

BSD-like

AUTHORS

Dr. Detlef Groth (Potsdam University)
Stefan Müller (Free University)

SEE ALSO