help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[2]: Bison string processing


From: Владимир Рыков
Subject: Re[2]: Bison string processing
Date: Thu, 30 Nov 2000 10:20:44 +0300

Thank you VERY much, Mr Aberg.

I'll read your lettercarefully.

Maybe it is possible to specify some details later with you?

Vladimir


-----Original Message-----
From: Hans Aberg <address@hidden>
To: "Vladimir Rykov" <address@hidden>
Date: Wed, 29 Nov 2000 10:59:48 +0100
Subject: Re: Bison string processing

> At 12:10 +0300 0-11-29, Vladimir Rykov wrote:
> >I have to write  a program which converts the input string:
> >
> >   vv implies ww  ;
> >
> >in the output line  :
> 
> Bison parses lexemes, or "words", of a language, which are produced by the
> yylex functions. A simple way to produce such lexemes is by using the a
> lexical analyzer compiler like Flex, see
>   ftp://ftp.digital.com/pub/GNU/non-gnu/flex/flex-2.5.4a.tar.gz
> which from a regular-word-like definition writes a definition of yylex.
> 
> In Flex one could write a definition say like
> 
> [[:alpha:]]+  { /* save (yytext, yyleng) say in yylval */ return NAME; }
> "=>"          { return IMPLIES; }
> \n            { ++line_number; return yytext[0]; }
> .             { return yytext[0]; /* Single character becomes code. */ }
> 
> In Bison, one would define
> 
> %token IMPLIES, NAME, ...
> 
> and use in variable definitions as
> 
> exp:
>     NAME { ...  }
>   | exp IMPLIES exp  { ... }
> 
> The Bison manual 3.6.1 also says that if you declare
> 
> %token IMPLIES "=>"
> 
> then you can later use that name as in
> 
> exp:
>     NAME { ...  }
>   | exp "=>" exp  { ... }
> 
> But here "=>" is just a symbol for IMPLIES, a way to make your Bison
> definition file look nicer; yylex still needs to recognize the token
> IMPLIES, which could be something else than "=>".
> 
> -- The Bison manual 4.2.1 indicates a way for yylex to use token table
> lookups, but this is said to be slow.
> 
>   Hans Aberg
> 
> 
> 

--

P bI K O B  B. B.    MOCKBA




reply via email to

[Prev in Thread] Current Thread [Next in Thread]