home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / sos3-2.lha / src / scp / scp.l < prev    next >
Encoding:
Text File  |  1992-01-23  |  2.9 KB  |  103 lines

  1.  /* --------------------------------------------------------------------------
  2.   * Copyright 1992 by Forschungszentrum Informatik (FZI)
  3.   *
  4.   * You can use and distribute this software under the terms of the licence
  5.   * you should have received along with this program.
  6.   * If not or if you want additional information, write to
  7.   * Forschungszentrum Informatik, "STONE", Haid-und-Neu-Strasse 10-14,
  8.   * D-7500 Karlsruhe 1, Germany.
  9.   * --------------------------------------------------------------------------
  10.   */
  11. %{
  12. extern "C" int yyreject();
  13. extern "C" int yylook();
  14. extern "C" int yywrap();
  15. extern "C" int yyless(int);
  16. extern "C" int yyback(int*, int);
  17. extern "C" int yyinput();
  18. extern "C" int yyoutput (int);
  19. extern "C" int yyunput (int);
  20.  
  21. #define RETURN yylval.c = strdup (yytext); return
  22.  
  23. %}
  24.  
  25. letter        [a-zA-Z_]
  26. digit        [0-9]
  27. diglet        [a-zA-Z_0-9]
  28.  
  29. line_comment    "//"[^\n]*
  30. comment_start    "/*"
  31. comment_line    [^\n*]*\n
  32. comment_end    [^\n*]*"*/"
  33. comment_part    [^\n*]*"*"
  34.  
  35. string        \"([^\n\"]|\\\")*\"
  36. char        \'([^\n\']|\\\')*\'
  37. name        {letter}({diglet})*
  38. number        {digit}({diglet})*
  39.  
  40. white_space    [     \n\t]+
  41. any        .
  42.  
  43. %START comment
  44. %%
  45.  
  46. {comment_start}            {yymore(); BEGIN comment;}
  47. <comment>{comment_end}        {BEGIN 0; RETURN white_space_tok;}
  48. <comment>{comment_end}        {RETURN white_space_tok;}
  49. <comment>{comment_part}        {yymore();}
  50. <comment>{comment_line}        {RETURN white_space_tok;}
  51.  
  52. {line_comment}            {RETURN white_space_tok;}
  53.  
  54. {string}            {RETURN string_tok;}
  55. {char}                {RETURN char_tok;}
  56. {number}            {RETURN number_tok;}
  57.  
  58. {white_space}            {RETURN white_space_tok;}
  59. "{"                {RETURN l_brc_tok;}
  60. "}"                {RETURN r_brc_tok;}
  61. "::"                {RETURN double_colon_tok;}
  62. ";"                {RETURN semi_colon_tok;}
  63. "("                {RETURN l_par_tok;}
  64. ")"                {RETURN r_par_tok;}
  65. "["                {RETURN l_br_tok;}
  66. "]"                {RETURN r_br_tok;}
  67. "<"                {RETURN operator_string_tok;}
  68. ">"                {RETURN operator_string_tok;}
  69. ">>"                {RETURN operator_string_tok;}
  70. "<<"                {RETURN operator_string_tok;}
  71. "&"                {RETURN operator_string_tok;}
  72. "&="                {RETURN operator_string_tok;}
  73. "&&"                {RETURN operator_string_tok;}
  74. "="                {RETURN operator_string_tok;}
  75. "|"                {RETURN operator_string_tok;}
  76. "|="                {RETURN operator_string_tok;}
  77. "^"                {RETURN operator_string_tok;}
  78. "^="                {RETURN operator_string_tok;}
  79. "=="                {RETURN operator_string_tok;}
  80. "!"                {RETURN operator_string_tok;}
  81. ">="                {RETURN operator_string_tok;}
  82. "<="                {RETURN operator_string_tok;}
  83. "-"                {RETURN operator_string_tok;}
  84. "-="                {RETURN operator_string_tok;}
  85. "!="                {RETURN operator_string_tok;}
  86. "||"                {RETURN operator_string_tok;}
  87. "%"                {RETURN operator_string_tok;}
  88. "%="                {RETURN operator_string_tok;}
  89. "+"                {RETURN operator_string_tok;}
  90. "+="                {RETURN operator_string_tok;}
  91. ">>="                {RETURN operator_string_tok;}
  92. "<<="                {RETURN operator_string_tok;}
  93. "/"                {RETURN operator_string_tok;}
  94. "/="                {RETURN operator_string_tok;}
  95. "*"                {RETURN operator_string_tok;}
  96. "*="                {RETURN operator_string_tok;}
  97.  
  98. "operator"            {RETURN operator_tok;}
  99.  
  100. {name}                {RETURN name_tok;}
  101.  
  102. {any}                {RETURN special_tok;}
  103.