Language::FormulaEngine::Parser::ContextUtil - utility methods for parsers
version 0.08
my ($line, $col)= calc_text_coordinates( $buffer, $pos ); my ($line, $col)= calc_text_coordinates( $buffer, $pos, $buffer_line, $buffer_col );
Returns the 0-based line number and character number of an offset within a buffer. The line/column of the start of the buffer can be given as additional arguments.
my $message= format_context_string( $buffer, $token_start, $token_limit, $buffer_line, $buffer_col ); # "'blah blah' on line 15, char 12"
Returns a single-string view of where the token occurs in the buffer. This is useful for single-line "die" messages.
my $tty_text= format_context_multiline( $buffer, $token_start, $token_limit, \%args ); # "blah blah blah token blah blah\n" # ." ^^^^^\n" # ." (line 15, char 16)\n";
More advanced view of the input string, printed on three lines with the second marking the token within its context and third listing the line/column. This is only useful with a fixed-width font in a multi-line context.
This method also supports various options for formatting.
Michael Conrad <mconrad@intellitree.com>
This software is copyright (c) 2023 by Michael Conrad, IntelliTree Solutions llc.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Language::FormulaEngine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Language::FormulaEngine
CPAN shell
perl -MCPAN -e shell install Language::FormulaEngine
For more information on module installation, please visit the detailed CPAN module installation guide.