LLOOP Index | GSP Language | GSP Library | Framework Classes | Component Classes

word.gsp

This is the verbatim text of the file "word.gsp" part of the LLOOP package. The copyright remains with Michel MEHL. All rights reserved.



/**
 * Reads a sequence of letters, underscores and numeric chars starting with a letter. 
 * This token is implemented using the standard String class. 
 * The chars read from the input are appended to the final string using the
 * appropriate methods of the inherited String class.
 */

token WordToken extends class universal::String()
  include <stdio.h>, <ctype.h>, "universal__String.h"
  alias "word"
  parse
  {{ 
    setEmpty();

    char c = 0;        		

    is.get(c);
    if (isalpha(c) || (c=='_')) //&&  !is.fail() )
      {        
	do
	  {
	    append(c);
	    c = 0; 
	    is.get(c);	
	  }
	while (isalnum(c) || (c == '_')); //&& !is.fail() )
      }
	
    if (empty())
      abort("");

#ifdef __DEBUG__
    cout << "WordToken='" << str() << "'" << endl;	 
#endif

    /* Set pos. to the immediate following char
   * If EOF was reached, this does nothing.
   */
    is.seekg(-1, ios::cur); 
  }}
  expand
  {{
    os << toString();
  }}




This file is part of the LLOOP Reversible Object-Oriented Parser Generator. Copyright (c) 2005-2006 Michel MEHL, France. All rights reserved. LLOOP is distributed by the company ERSA SaRL.


Copyright (c) 2005-2006 Michel MEHL, Haguenau, France
LLOOP version 1.1