example.l 483 B

12345678910111213141516171819202122232425
  1. /*
  2. Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  3. Exceptions. See /LICENSE for license information.
  4. SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  5. */
  6. %option noyywrap
  7. %{
  8. #include <stdio.h>
  9. #define YY_DECL int yylex()
  10. #include "example.tab.h"
  11. %}
  12. %%
  13. [0-9]+ { yylval = atoi(yytext); return INT; }
  14. "*" { return '*'; }
  15. "+" { return '+'; }
  16. "<<" { return LSH; }
  17. "==" { return EQEQ; }
  18. "(" { return '('; }
  19. ")" { return ')'; }
  20. ";" { return ';'; }
  21. %%