NAME

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

VERSION

version 6.0.27

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

: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

:symbol ::= NUMBER pause => before event => ^NUMBER
:symbol ::= 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) ?

discardIsFallback

Grammar's :discard is a fallback

defaultSymbolAction

Grammar default symbol action

defaultRuleAction

Grammar default rule action

defaultEventAction

Grammar default event action

defaultRegexAction

Grammar default regex action

startId

Start symbol Id

discardId

Discard symbol Id

symbolIds

Symbol Ids (array reference)

ruleIds

Rule Ids (array reference)

defaultEncoding

Grammar default encoding

fallbackEncoding

Grammar fallback encoding

$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->isDiscardIsFallback

Returns a boolean that returns the grammar's discard-is-fallback setting

$self->getDiscardIsFallback

Alias to isDiscardIsFallback()

$self->getDefaultSymbolAction

Returns grammar's default symbol action, never null

$self->getDefaultRuleAction

Returns grammar's default rule action, can be null

$self->getDefaultEventAction

Returns grammar's default event action, can be null

$self->getDefaultRegexAction

Returns grammar's default regex action, can be null

$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

$self->getDefaultEncoding

Returns grammar's default encoding, can be null

$self->getFallbackEncoding

Returns grammar's fallback encoding, can be null

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.