Parse::Highlife - Perl extension for grammar based parsing and transformation of data.
use Parse::Highlife; # define grammar (grammar for DEC format as an example) my $grammar = q{ space ignored: /\s\n\r\t+/; multiline-comment ignored: "/*" .. "*/"; singleline-comment ignored: /\#[^\n\r]*/; file: { declaration 0..* }; declaration: [ "@" identifier ] literal; literal: < map string real number identifier >; map: [ symbol ] "[" { pair 0..* } "]"; pair: [ symbol ":" ] declaration; string: < double-quoted-string single-quoted-string >; double-quoted-string: '"' .. '"'; single-quoted-string: "'" .. "'"; real: /\d+\.\d+/; number: /\d+/; identifier: symbol { "." symbol 0..* }; symbol: /[\w\d]+(\-[\w\d]+)*/; }; # setup compiler my $compiler = Parse::Highlife -> Compiler; $compiler->grammar( $Grammar ); $compiler->toprule( -name => 'file' ); # compile document $compiler -> compile( 'myfile.txt' );
Parse::Highlife is used to parse and transform string data. You can define a grammar and a tokenizer, parser and transformer are generated. By defining transformers for some you non-terminals.
This documentation is incomplete and will be expanded soon.
coming soon.
None.
Tom Kirchner, <tom@kirchner.com>
Copyright (C) 2012 by Tom Kirchner
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.
To install Parse::Highlife, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Parse::Highlife
CPAN shell
perl -MCPAN -e shell install Parse::Highlife
For more information on module installation, please visit the detailed CPAN module installation guide.