home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CMCD0704.ISO / Software / Freeware / Utilitare / VisualBoyAdvance-1.7.2 / src / expr.l < prev    next >
Encoding:
Lex Description  |  2002-10-20  |  809 b   |  72 lines

  1. %{
  2. #include "expr.cpp.h"
  3.  
  4. #ifndef __GNUC__
  5. #include <io.h>
  6. #define isatty _isatty
  7. #endif
  8.  
  9. char *exprString;
  10. int exprCol;
  11.  
  12. #define YY_INPUT(buf,result,max_size) \
  13.     { \
  14.     int c = *exprString++; \
  15.     exprCol++;\
  16.     result = (c == 0) ? YY_NULL : (buf[0] = c, 1); \
  17.     }
  18. %}
  19.  
  20. %option nomain
  21. %option noyywrap
  22.  
  23. SIZEOF "sizeof"
  24. ID [a-zA-Z_][a-zA-Z0-9_]*
  25. NUM [0-9]+
  26. DOT "."
  27. ARROW "->"
  28. STAR "*"
  29. ADDR "&"
  30.  
  31. %%
  32.  
  33. {SIZEOF} {
  34.         return TOKEN_SIZEOF;
  35. }
  36.  
  37. {ID} {
  38.         return TOKEN_IDENTIFIER;
  39. }
  40.  
  41. {NUM} {
  42.         return TOKEN_NUMBER;
  43. }
  44.  
  45. {DOT} {
  46.         return TOKEN_DOT;
  47. }       
  48.  
  49. {ARROW} {
  50.         return TOKEN_ARROW;
  51. }
  52.  
  53. {ADDR} {
  54.         return TOKEN_ADDR;
  55. }
  56.  
  57. {STAR} {
  58.         return TOKEN_STAR;
  59. }
  60.  
  61. [ \t\n]+
  62.  
  63. . return *yytext;
  64.  
  65. %%
  66.  
  67. void exprCleanBuffer()
  68. {
  69.   yy_delete_buffer(yy_current_buffer);
  70.   yy_init = 1;
  71. }
  72.