No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

al.lex 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. %{
  2. #include "as.tab.h"
  3. int yywrap(void){return 1;}
  4. void
  5. yyerror (char const *s)
  6. {
  7. fprintf (stderr, "%s\n", s);
  8. }
  9. %}
  10. %%
  11. "main" { return tMAIN ;}
  12. "{" { return tOBRACKET;}
  13. "}" { return tCBRACKET; }
  14. "(" { return tOBRACE; }
  15. ")" { return tCBRACE; }
  16. "const" { return tCONST; }
  17. "int" { return tINT; }
  18. "printf" { return tPRINTF; } //Degeu mais à degager
  19. "if" { return tIF; }
  20. "while" { return tWHILE; }
  21. "<" { return tLT; }
  22. ">" { return tGT; }
  23. "==" { return tEQCOND; }
  24. "&&" { return tAND; }
  25. "||" { return tOR; }
  26. "else" { return tELSE;}
  27. "&" { return tADDR;}
  28. [0-9]+ { yylval.nombre = atoi(yytext); return tNB; }
  29. [0-9]+e[0-9]+ { yylval.nombre = -1; return tNBEXP; } //Renvoyer le token tNB et pas tNBEXP
  30. "+" { return tADD; }
  31. "-" { return tSUB; }
  32. "*" { return tMUL; }
  33. "/" { return tDIV; }
  34. "=" { return tEQ; }
  35. ";" { return tPV; }
  36. " " {} //Ne pas les retourner à Yacc
  37. " " {} //Ne pas les retourner à Yacc
  38. "," { return tCOMA; }
  39. "\n" {} //Ne pas les retourner à Yacc
  40. [a-zA-Z][a-zA-Z0-9_]* { strcpy(yylval.id, yytext); return tID; }
  41. . { }//return tERROR; }
  42. %%