NAME
MarpaX::Languages::C::AST::Impl - Implementation of Marpa's interface
VERSION
version 0.05
SYNOPSIS
use strict;
use warnings FATAL => 'all';
use MarpaX::Languages::C::AST::Impl;
my $marpaImpl = MarpaX::Languages::C::AST::Impl->new();
DESCRIPTION
This modules implements all needed Marpa calls using its Scanless interface. Please be aware that logging is done via Log::Any.
EXPORTS
The constants DOT_PREDICTION (0), DOT_COMPLETION (-1) and LATEST_EARLEY_SET_ID (-1) are exported on demand.
SUBROUTINES/METHODS
new($class, $grammarOptionsHashp, $recceOptionsHashp)
Instanciate a new object. Takes as parameter two references to hashes: the grammar options, the recognizer options. In the recognizer, there is a grammar internal option that will be forced to the grammar object. If the environment variable MARPA_TRACE_TERMINALS is setted to a true value, then internal Marpa trace on terminals is activated. If the environment MARPA_TRACE_VALUES is setted to a true value, then internal Marpa trace on values is actived. If the environment variable MARPA_TRACE is setted to a true value, then both terminals et values internal Marpa traces are activated.
findInProgress($self, $earleySetId, $wantedRuleId, $wantedDotPosition, $wantedOrigin, $wantedLhs, $wantedRhsp, $fatalMode, $indicesp, $matchesp, $originsp) = @_;
Searches a rule at G1 Earley Set Id $earleySetId. The default Earley Set Id is the current one. $wantedRuleId, if defined, is the rule ID. $wantedDotPosition, if defined, is the dot position, that should be a number between 0 and the number of RHS, or -1. $wantedOrigin, if defined, is the wanted origin. In case $wantedRuleId is undef, the user can use $wantedLhs and/or $wantedRhs. $wantedLhs, if defined, is the LHS name. $wantedRhsp, if defined, is the list of RHS. $fatalMode, if defined and true, will mean the module will croak if there is a match. $indicesp, if defined, must be a reference to an array giving the indices from Marpa's output we are interested in. $matchesp, if defined, has to be a reference to an array, which will be filled reference to hashes like {ruleId=>$ruleId, dotPosition=>$dotPosition, origin=>$origin} that matched. You can use the method g1Describe() to fill it. $originsp, if defined, have to be a reference to a hash that will be filled with Earley Set Id origins as a key if the later is not already in it, the value number will be 0 when the key is created, regardless if there is a match or not. Any origin different than $earleySetId and zero (the root) will putted in it. We remind that for a prediction, origin is always the same as the location of the current report. The shortcuts DOT_PREDICTION (0) and DOT_COMPLETION (-1) can be used if the caller import it. There is a special case: if $dotPrediction is defined, $wantedLhs is defined, and $wantedRhsp is undef then, if $dotPrediction is DOT_PREDICTION we will search any prediction of $wantedLhs, and if $dotPrediction is DOT_COMPLETION we will search any completion of $wantedLhs. This method will return a true value if there is at least one match. If one of $wantedRuleId, $wantedDotPosition, $wantedOrigin, $wantedLhs, or $wantedRhsp is defined and there is match, this method stop at the first match.
findInProgressShort($self, $wantedDotPosition, $wantedLhs, $wantedRhsp)
This method is shortcut to findInProgress(), that will force findInProgress()'s parameter $earleySetId to -1 (i.e. current G1 location), and $wantedRuleId, $wantedOrigin, $fatalMode, $indicesp, $matchesp to undef. This method exist because, in practice, only dot position, lhs or rhs are of interest within the current G1 location.
rule($self, $ruleId)
Returns Marpa's grammar's rule. Because the output of Marpa's rule is a constant for a given $ruleId, any call to this method will use a cached result if it exist, create a cache otherwise.
value($self)
Returns Marpa's recognizer's value.
read($self, $inputp)
Returns Marpa's recognizer's read. Argument is a reference to input.
resume($self)
Returns Marpa's recognizer's resume.
last_completed($self, $symbol)
Returns Marpa's recognizer's last_completed for symbol $symbol.
last_completed_range($self, $symbol)
Returns Marpa's recognizer's last_completed_range for symbol $symbol.
range_to_string($self, $start, $end)
Returns Marpa's recognizer's range_to_string for a start value of $start and an end value of $end.
progress($self, $g1)
Returns Marpa's recognizer's progress for a g1 location $g1.
event($self, $eventNumber)
Returns Marpa's recognizer's event for event number $eventNumber.
pause_lexeme($self)
Returns Marpa's recognizer's pause_lexeme.
pause_span($self)
Returns Marpa's recognizer's pause_span.
literal($self, $start, $length)
Returns Marpa's recognizer's literal.
line_column($self, $start)
Returns Marpa's recognizer's line_column at eventual $start location in the input stream. Default location is current location.
substring($self, $start, $length)
Returns Marpa's recognizer's substring corresponding to g1 span ($start, $length).
lexeme_read($self, $lexeme, $start, $length, $value)
Returns Marpa's recognizer's lexeme_read for lexeme $lexeme, at start position $start, length $length and value $value.
latest_g1_location($self)
Returns Marpa's recognizer's latest_g1_location.
g1_location_to_span($self, $g1)
Returns Marpa's recognizer's g1_location_to_span for a g1 location $g1.
AUTHOR
Jean-Damien Durand <jeandamiendurand@free.fr>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Jean-Damien Durand.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.