On 12:19 Thursday, 21 May 2020 +0200, Bill Allombert wrote
 > On Wed, May 20, 2020 at 10:03:08PM -0700, Manoj Srivastava wrote:
 > >         While it is true that the change was incompatible wwith what we
 > >  had befire, the change was made almost four and a half years ago. I
 > >  suspect we have gotten used to it now; and changing it back would just
 > >  cause issues.
 > 
 > Is the new behaviour documented now ?
 > This is needed to use yyinput() properly.

        See below. The yyinput usage is demonstrated in an example in
 the info node about generating C++ scanners.


> The commit message does give any rationale or information about this.
 > 
 > >         I guess this is the new normal?
 > 
 > Do you mean that sacarstically ?

        What make you think that? After 4.5 years of this being the
 default, stating that yyinput returning NULL is normal seems like a
 statement of fact.

        Manoj

In Node: 18 Generating C++ Scanners
=======================================================
   Here is an example of a simple C++ scanner:

          // An example of using the flex C++ scanner class.
     
         %{
         #include <iostream>
         using namespace std;
         int mylineno = 0;
         %}
     
         %option noyywrap c++
     
         string  \"[^\n"]+\"
     
         ws      [ \t]+
     
         alpha   [A-Za-z]
         dig     [0-9]
         name    ({alpha}|{dig}|\$)({alpha}|{dig}|[_.\-/$])*
         num1    [-+]?{dig}+\.?([eE][-+]?{dig}+)?
         num2    [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)?
         number  {num1}|{num2}
     
         %%
     
         {ws}    /* skip blanks and tabs */
     
         "/*"    {
                 int c;
     
                 while((c = yyinput()) != 0)
                     {
                     if(c == '\n')
                         ++mylineno;
     
                     else if(c == '*')
                         {
                         if((c = yyinput()) == '/')
                             break;
                         else
                             unput(c);
                         }
                     }
                 }
     
         {number}  cout << "number " << YYText() << '\n';
     
         \n        mylineno++;
     
         {name}    cout << "name " << YYText() << '\n';
     
         {string}  cout << "string " << YYText() << '\n';
     
         %%
     
        // This include is required if main() is an another source file.
        //#include <FlexLexer.h>
     
         int main( int /* argc */, char** /* argv */ )
         {
             FlexLexer* lexer = new yyFlexLexer;
             while(lexer->yylex() != 0)
                 ;
             return 0;
         }

--
Two wrights don't make a rong, they make an airplane.  Or bicycles.
Manoj Srivastava <sriva...@acm.org> 
4096R/C5779A1C E37E 5EC5 2A01 DA25 AD20  05B6 CF48 9438 C577 9A1C

Reply via email to