NAME
Decl::Tok - Given a line iterator, returns a token stream that tokenizes the lines as first-pass Decl
VERSION
Version 0.01
SYNOPSIS
Decl can be parsed at different levels of detail. The tokenizer simply takes a line iterator and skims it to extract the bare minimum of the line shape in order to facilitate indexing or support some other parsing, such as building an in-memory data structure. This token stream is pretty minimal; for instance, the contents of brackets are not parsed at all, just identified and passed through as a kind of quoted string. The next stage in processing has to identify any internal structure in bracketed line parameters.
CREATING A TOKENIZER
Essentially, skim
is currently the beginning and end of tokenization at the stream level. A parameter tokenizer could be added as a second level of processing, but I currently don't plan to do that, instead breaking out bracketed data in the data structure parser.
skim (source, type)
Given either a line stream or a string, sets up a first-line token stream drawing from the source. If a line stream, it must have the fields ['type', 'lno', 'indent', 'len', 'text'], and 'type' must be either 'line' or 'blank'.
The output of this tokenizer is a stream with the same fields (which means that a line stream is actually a token stream); the types are many and varied.
The type
parameter to the skimmer determines the basic text type to be expected - must be one of text, para, block, tag, or textplus. The default is tag.
MATCHING INDIVIDUAL TOKENS
The different classes of tokens each have a matcher that can be called on a given string. If the string begins with the relevant type of token, the caller gets back the length that matched and the matched token as an arrayref. If not, it gets an undef.
match_white
Matches whitespace.
match_bareword
Given a string, checks whether it starts with a Decl bareword. A bareword is pretty liberal in comparison with most languages; mostly we just have to make sure we don't collide with sigils.
match_quoted
match_brackets
match_sigil
match_plus
AUTHOR
Michael Roberts, <michael at vivtek.com>
BUGS
Please report any bugs or feature requests to bug-decl-tok at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Decl-Tok. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Decl::Tok
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
Copyright 2021 Michael Roberts.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.