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

Manual: OOLEX 1 1992


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

SYNOPSYS


oolex -t file


slide: SYNOPSYS

DESCRIPTION


The program oolex is a simple extension of lex to allow for embedding a scanner in a class. It generates a scanner class definition from an ordinary lex specification.


slide: DESCRIPTION

EXAMPLE


    %{
    #include <grammar/lex.h>
    
    class item {
    static int n;
    char* s;
    public:
    item(char* p) { n = n + 1; s = new char[strlen(p)+1]; strcpy(s,p); }
    char* str() { return s; }
    int sum() { return n; }
    };
    
    inline ostream& operator<<(ostream& c, item& a) 
    { 
    c << " (" << a.sum() << ") " << a.str();
    return c; 
    }
    
    %}
    \%class lex
    %%
    [a-z]+ { item x(yytext); cout << x; }
    %%
    main() { lex l; l(); }
  

slide: EXAMPLE

REMARKS


The scanner class lex makes use of a (pre-defined) class declaration given in <grammar/lex.h> displayed below. Similar declarations may be given by the user.

  // file: <grammar/lex.h>
  
  #include <grammar/scanner.h>
  
  class lex : public scanner {
  public:
          lex(istream& in = cin, ostream& out = cout ) : scanner(in,out) { }
          token operator()(); 
  };
  

slide: REMARKS

REMARKS


For further examples, look in /usr/prac/se/hush/examples/grammar.


slide: REMARKS

SEE ALSO

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