The DejaVU Framework -- hush 3.1
[.] Papers Tutorials Examples Manuals Interfaces Sources Packages Resources ?

Manual: OOYACC 1 1992


[.] [man] man1 man2 man3 man4 man5 man6 man7 man8 man9 manl mann ?

SYNOPSYS

ooyacc options file

DESCRIPTION

It can be used to generate a parser class definition from an ordinary yacc specification.

OPTIONS

The options are like the ordinary yacc options.

EXAMPLE

The following example consists of a scanner class lex and a parser class yacc.

LEX


    \%class lex
    %{
    #include <iostream.h>
    #include "yacc.tab.h"
    #include <grammar/lex.h>
    %}
    %%
    [a-z]+ { return token(A,yytext); }
    [A-Z]+ { return token(B,yytext); }
    %%
  

slide: LEX

YACC


    \%class yacc
    \%token  A B 
    %{
    #include <grammar/yacc.h>
    %}
    \%start sequence
    %%
    
    sequence : { cout << "empty\n"; }
             | A { cout << (char*) *$1 << " : A\n"; } sequence 
             | B { cout << *$1 << " : B\n"; } sequence 
             ;
    %%
  

slide: YACC

MAIN


    // file main.c 
    #include <grammar/lex.h>
    #include <grammar/yacc.h>
    
    main() { lex sc; yacc y(sc); y(); }
    
  

slide: MAIN

REMARKS


The example makes use of a parser class yacc for which a (pre-defined) declaration is given in <grammar/yacc.h>. The user may declare other parser classes in a similar way.

  
    // file <grammar/yacc.h>
    
    #include <grammar/parser.h>
    
    class yacc : public yacc_parser {
    public:
            yacc(scanner& sc) : parser(sc) { }
            term* operator()();
    };
  

slide: REMARKS

TOKENS

Communication between the scanner class and parser class is by tokens. Within ooyacc, tokens are terms. See <hush/term.h>

REMARKS

See examples/grammar for more complex examples.

SEE ALSO

lex (1), yacc (1), oolex
[.] Papers Tutorials Examples Manuals Interfaces Sources Packages Resources ?
Hush Online Technology
hush@cs.vu.nl
09/24/99