Marpa::R2::BNF(3pm) User Contributed Perl Documentation Marpa::R2::BNF(3pm)

Marpa::R2::BNF - BNF Interface (obsoleted)

    use Marpa::R2;
    my $grammar = Marpa::R2::Grammar->new(
        {   
            actions        => 'My_Actions',
            default_action => 'do_first_arg',
            source          => \(<<'END_OF_SOURCE'),
    :start ::= Script
    Script ::= Expression+ separator => <op comma> action => do_script
    Expression ::=
        Number
        | (<op lparen>) Expression (<op rparen>) action => do_parens assoc => group
       || Expression (<op pow>) Expression action => do_pow assoc => right
       || Expression (<op times>) Expression action => do_multiply
        | Expression (<op divide>) Expression action => do_divide
       || Expression (<op add>) Expression action => do_add
        | Expression (<op subtract>) Expression action => do_subtract
    END_OF_SOURCE
        }
    );

This page is the reference for the Marpa's "BNF interface", also called its "Stuifzand interface". Use of the Stuifzand interface is now discouraged, in favor of the SLIF interface. Almost all of the functionality of the Stuifzand interface can be duplicated in the SLIF interface by switching immediately to external scanning, and never switching back to internal scanning. To switch immediately to external scanning in the SLIF, specify a length of zero for its initial read(). For more details, see the document for the SLIF itself.

Stuifzand interface source strings are specified using the the "source" named argument of Marpa::R2's grammars. BNF source strings perform the functions of the "rules" and the "start" named arguments of Marpa grammars. When the "source" named argument is used to specify a grammar, the "rules" and "start" named arguments should not be used, and vice versa. The syntax for the Stuifzand interface's source string is the same as the syntax for the SLIF DSL, except that features and syntax not relevant to the Stuifzand interface are not supported.

Everything related to L0 grammars is unsupported. L0 grammars do not exist in the Stuifzand interface. Lexemes, character classes and quoted strings all implicitly require a L0 grammar to exist and therefore, they also are not supported.

Since the Stuifzand interface does not implement internal scanning, everything to do with internal scanning is unsupported. Events and pauses are the most visible of these features.

In most cases, when features have introduced after the SLIF replaced the Stuifzand interface as Marpa's primary interface, those features have been retro-ported if they make sense in the Stuifzand context. However, this will necessarily always be the case in the future.

Here is a list of some of the unsupported SLIF DSL features,

  Copyright 2014 Jeffrey Kegler
  This file is part of Marpa::R2.  Marpa::R2 is free software: you can
  redistribute it and/or modify it under the terms of the GNU Lesser
  General Public License as published by the Free Software Foundation,
  either version 3 of the License, or (at your option) any later version.
  Marpa::R2 is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser
  General Public License along with Marpa::R2.  If not, see
  http://www.gnu.org/licenses/.
2024-12-07 perl v5.40.0