-
-
31 Dec 2011 11:34:09 UTC
- Distribution: ParseLex
- Module version: 2.21
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (1)
- Testers (3818 / 84 / 0)
- Kwalitee
Bus factor: 0- 37.78% Coverage
- License: unknown
- Activity
24 month- Tools
- Download (50.41KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- File::Find
- File::Slurp
- Parse::Template
- Symbol
- Test::More
- integer
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Parse::LexEvent
- Generator of event-oriented lexical analyzers (1.00 ALPHA)SYNOPSIS
use Parse::LexEvent; sub string { print $_[0]->name, ": $_[1]\n"; } sub comment { print $_[0]->name, ": $_[1]\n"; } sub remainder { print $_[0]->name, ": $_[1]\n"; } $lexer = Parse::LexEvent->new()->configure( From => \*DATA, Tokens => [ Type => 'Simple', Name => 'ccomment', Handler => 'comment', Regex => '//.*\n', Type => 'Delimited', Name => 'comment', Handler => 'comment', Start => '/[*]', End => '[*]/', Type => 'Quoted', Name => 'squotes', Handler => 'string', Quote => qq!\'!, Type => 'Quoted', Name => 'dquotes', Handler => 'string', Quote => qq!\"!, Type => 'Simple', Name => 'remainder', Regex => '(?s:[^/\'\"]+)', ReadMore => 1, ] )->parse(); __END__ /* C comment */ // C++ comment var d = "string in double quotes"; var s = 'string in single quotes'; var i = 10; var y = 100;
DESCRIPTION
Parse::LexEvent
generates lexical analyzers in the fashion ofParse::Lex
, but the generated analyzers emit an event at the finish of recognition of each token. This event corresponds to the call of a procedure whose name is that of the token. It is possible to give a different name to this procedure by making use of theHandler
parameter when defining a token.An application using
Parse::LexEvent
must define the required procedures. These procedures take the token object as first argument and the recognized character string as the second.Parse::LexEvent
inherits fromParse::ALex
and possesses all the methods described in the documentation of theParse::Lex
class, except for the methodsanalyze()
,every()
next()
, andnextis()
.Methods
EXAMPLES
cparser.pl - This analyzer recognizes three types of structures: C ou C++ comments, strings within quotation marks, and the rest. It emits an event specific to each. You can use it, for example, to analyze C, C++ or Javascript programs.
SEE ALSO
Parse::Lex
,Parse::Token
.AUTHOR
Philippe Verdret.
COPYRIGHT
Copyright (c) 1999 Philippe Verdret. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install Parse::Lex, copy and paste the appropriate command in to your terminal.
cpanm Parse::Lex
perl -MCPAN -e shell install Parse::Lex
For more information on module installation, please visit the detailed CPAN module installation guide.