NAME

MarpaX::ESLIF::Grammar::Properties - ESLIF Grammar Properties

VERSION

version 2.0.43

SYNOPSIS

use MarpaX::ESLIF;

my $eslif = MarpaX::ESLIF->new();
my $data = do { local $/; <DATA> };
my $eslifGrammar = MarpaX::ESLIF::Grammar->new($eslif, $data);
my $grammarProperties = $eslifGrammar->currentProperties;
my $grammarPropertiesByLevel = $eslifGrammar->propertiesByLevel(0);

__DATA__
#
# This is an example of a calculator grammar
#
:start   ::= Expression
:default ::=             action        => do_op
                         symbol-action => do_symbol
                         free-action   => do_free     # Supported but useless
:desc    ::= 'Calculator'
:discard ::= whitespaces event  => discard_whitespaces$
:discard ::= comment     event  => discard_comment$

event ^Number = predicted Number
event Number$ = completed Number
Number   ::= NUMBER   action => ::shift

event Expression$ = completed Expression
event ^Expression = predicted Expression
Expression ::=
    Number                                           action => do_int
    | '(' Expression ')'              assoc => group action => ::copy[1]
   ||     Expression '**' Expression  assoc => right
   ||     Expression  '*' Expression
    |     Expression  '/' Expression
   ||     Expression  '+' Expression
    |     Expression  '-' Expression

whitespaces ::= WHITESPACES
comment ::= /(?:(?:(?:\/\/)(?:[^\n]*)(?:\n|\z))|(?:(?:\/\*)(?:(?:[^\*]+|\*(?!\/))*)(?:\*\/)))/u

:lexeme ::= NUMBER pause => before event => ^NUMBER
:lexeme ::= NUMBER pause => after  event => NUMBER$

:desc      ~ 'Calculator Tokens'
NUMBER     ~ /[\d]+/   name => 'NUMBER Lexeme'
WHITESPACES ~ [\s]+    name => 'WHITESPACES Lexeme'

DESCRIPTION

ESLIF Grammar Properties.

Calls to grammar's currentProperties() or propertiesByLevel() methods outputs an instance of this class.

METHODS

MarpaX::ESLIF::Grammar::Properties->new(%args)

Creation of an ESLIFGrammarProperties instance, noted $self afterwards. %args is a hash that should contain:

level

Grammar level

maxLevel

Maximum grammar level

description

Grammar description

latm

Grammar is in LATM (Longest Accepted Token Mode) ?

defaultSymbolAction

Grammar default symbol action

defaultRuleAction

Grammar default rule action

defaultFreeAction

Grammar default free action

startId

Start symbol Id

discardId

Discard symbol Id

symbolIds

Symbol Ids (array reference)

ruleIds

Rule Ids (array reference)

$self->getLevel

Returns grammar's level

$self->getMaxLevel

Returns maximum grammar's level

$self->getDescription

Returns grammar's description

$self->isLatm

Returns a boolean that indicates if this grammar is in the LATM (Longest Acceptable Token Mode) or not

$self->getLatm

Alias to isLatm()

$self->getDefaultSymbolAction

Returns grammar's default symbol action, never null

$self->getDefaultRuleAction

Returns grammar's default rule action, can be null

$self->getDefaultFreeAction

Returns grammar's default free action, never null and always ":defaultFreeActions" (hardcoded in the JNI interface)

$self->getStartId

Returns grammar's start symbol id, always >= 0

$self->getDiscardId

Returns grammar's discard symbol id, < 0 if none.

$self->getSymbolIds

Returns a reference to a list of symbol identifiers

$self->getRuleIds

Returns a reference to a list of rule identifiers

AUTHOR

Jean-Damien Durand <jeandamiendurand@free.fr>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 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.