NAME

Parse::Eyapp::Parse - The parser of Eyapp grammars

Eyapp Grammar

The parser for the Eyapp language was written and generated using Parse::Eyapp and the eyapp compiler (actually the first version was bootstrapped using the yapp compiler). The Eyapp program parsing the Eyapp language is in the file Parse/Eyapp/Parse.yp in the Parse::Eyapp distribution. Therefore Parse::Eyapp::Parse objects have all the methods in Parse::Eyapp::Driver.

A Parse::Eyapp::Parse is nothing but a particular kind of Parse::Eyapp parser: the one that parses Eyapp grammars.

This section describes the syntax of the Eyapp language using its own notation. The grammar extends yacc and yapp grammars. Semicolons have been omitted to save space. Between C-like comments you can find an (informal) explanation of the language associated with each token.

eyapp: head body tail ;
symbol: LITERAL  /* A string literal like 'hello' */
    |   ident   
ident:  IDENT  /* IDENT is [A-Za-z_][A-Za-z0-9_]* */ 
head: headsec '%%'
headsec:  decl *
decl:  '\n'      
    |   SEMANTIC typedecl symlist '\n'  /* SEMANTIC  is %semantic\s+token      */
    |   SYNTACTIC typedecl symlist '\n' /* SYNTACTIC is %syntactic\s+token     */
    |   TOKEN typedecl symlist '\n'     /* TOKEN     is %token                 */
    |   ASSOC typedecl symlist '\n'     /* ASSOC     is %(left|right|nonassoc) */
    |   START ident '\n'                /* START     is %start                 */
    |   HEADCODE '\n'                   /* HEADCODE  is %{ Perl code ... %}    */
    |   UNION CODE '\n'                 /* UNION CODE  see yacc/bison          */
    |   DEFAULTACTION CODE '\n'         /* DEFAULTACTION is %defaultaction     */
    |   TREE treeclauses? '\n'          /* TREE      is %tree                  */
    |   METATREE '\n'                   /* METATREE  is %metatree              */
    |   TYPE typedecl identlist '\n'    /* TYPE      is %type                  */
    |   EXPECT NUMBER '\n'              /* EXPECT    is %expect                */
                                        /* NUMBER    is \d+                    */
typedecl:   /* empty */
    |       '<' IDENT '>'
treeclauses: BYPASS ALIAS? | ALIAS BYPASS?
symlist:    symbol + 
identlist:  ident +
body: rules * '%%'
rules: IDENT ':' rhss ';'  
rhss: rule <+ '|'>  
rule:   optname rhs (prec epscode)?
rhs:  rhseltwithid *
rhseltwithid : 
      rhselt '.' IDENT 
    | '$' rhselt  
    | rhselt
rhselt:     symbol    
    | code    
    | '(' optname rhs ')' 
    | rhselt STAR               /* STAR   is (%name\s*([A-Za-z_]\w*)\s*)?\*  */
    | rhselt '<' STAR symbol '>' 
    | rhselt OPTION             /* OPTION is (%name\s*([A-Za-z_]\w*)\s*)?\?  */
    | rhselt '<' PLUS symbol '>'
    | rhselt PLUS               /* PLUS   is (%name\s*([A-Za-z_]\w*)\s*)?\+  */
optname: (NAME IDENT)?          /* NAME is %name */
       | NOBYPASS IDENT         /* NOBYPASS is %no\s+bypass */
prec: PREC symbol               /* PREC is %prec */
epscode:  code ?   
code:   
    CODE           /* CODE     is { Perl code ... }         */
  | BEGINCODE      /* BEGINCODE is %begin { Perl code ... } */
tail:  TAILCODE ?  /* TAILCODE is { Perl code ... } */

The semantic of Eyapp agrees with the semantic of yacc and yapp for all the common constructions.

AUTHOR

Casiano Rodriguez-Leon (casiano@ull.es)

ACKNOWLEDGMENTS

This work has been supported by CEE (FEDER) and the Spanish Ministry of Educacion y Ciencia through Plan Nacional I+D+I number TIN2005-08818-C04-04 (ULL::OPLINK project http://www.oplink.ull.es/). Support from Gobierno de Canarias was through GC02210601 (Grupos Consolidados). The University of La Laguna has also supported my work in many ways and for many years.

A large percentage of code is verbatim taken from Parse::Yapp 1.05. The author of Parse::Yapp is Francois Desarmenien.

I wish to thank Francois Desarmenien for his Parse::Yapp module, to my students at La Laguna and to the Perl Community. Special thanks to my family and Larry Wall.

LICENCE AND COPYRIGHT

Copyright (c) 2006-2008 Casiano Rodriguez-Leon (casiano@ull.es). All rights reserved.

Parse::Yapp copyright is of Francois Desarmenien, all rights reserved. 1998-2001

These modules are free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

This program 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.