This repository has been archived on 2024-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
pacciani/Monicelli.ll

178 lines
2.4 KiB
LLVM
Raw Normal View History

%{
#include "Monicelli.tab.h"
#include <stdlib.h>
2014-11-23 23:14:12 +01:00
#include <stdio.h>
extern int lineNumber;
extern void yyerror(const char *);
2014-11-23 23:22:44 +01:00
extern void meta(const char *);
%}
%option noyywrap
DIGIT [0-9]
HEXDIGIT [0-9a-zA-Z]
CHAR [a-zA-Z_]
%x shift
%%
<INITIAL,shift>("\r\n"|"\n") {
lineNumber += 1;
}
2014-11-23 23:14:12 +01:00
"#"[^\n]* {
2014-11-23 23:22:44 +01:00
meta(yytext + 1);
2014-11-23 23:14:12 +01:00
}
2014-11-23 22:42:59 +01:00
"bituma"[^\n]* {}
"Lei ha clacsonato" {
return MAIN;
}
"vaffanzum" {
return RETURN;
}
"Necchi" {
yylval.typeval = TYPENAME_INT;
return TYPENAME;
}
"Mascetti" {
yylval.typeval = TYPENAME_CHAR;
return TYPENAME;
}
"Perozzi" {
yylval.typeval = TYPENAME_FLOAT;
return TYPENAME;
}
"Melandri" {
yylval.typeval = TYPENAME_BOOL;
return TYPENAME;
}
"Sassaroli" {
yylval.typeval = TYPENAME_DOUBLE;
return TYPENAME;
}
"conte" {
return STAR;
}
2014-11-23 20:43:42 +01:00
"voglio" {
return VARDECL;
}
2014-11-23 22:18:03 +01:00
"come "("se ")?"fosse" {
return ASSIGN;
}
2014-11-23 23:46:32 +01:00
("il"|"lo"|"la"|"l'"|"i"|"gli"|"le"|"un"|"un'"|"una"|"dei") {
return ARTICLE;
}
"più" {
return OP_PLUS;
}
"meno" {
return OP_MINUS;
}
"per" {
return OP_TIMES;
}
"diviso" {
return OP_DIV;
}
"con scappellamento a" {
BEGIN(shift);
}
<shift>"per" {
BEGIN(INITIAL);
}
<shift>"sinistra" {
return OP_SHL;
}
<shift>"destra" {
return OP_SHR;
}
"minore di" {
return OP_LT;
}
"maggiore di" {
return OP_GT;
}
"minore o uguale a" {
return OP_LTE;
}
"maggiore o uguale a" {
return OP_GTE;
}
"a posterdati" {
return PRINT;
}
"mi porga" {
return INPUT;
}
2014-11-23 22:06:11 +01:00
"ho visto" {
return ASSERT_BEGIN;
}
"!" {
return ASSERT_END;
}
"stuzzica" {
return LOOP_BEGIN;
}
"e brematura anche, se" {
return LOOP_CONDITION;
}
"che cos'è" {
return BRANCH_CONDITION;
}
"?" {
return BRANCH_BEGIN;
}
2014-11-24 10:54:25 +01:00
"o tarapia tapioco" {
return BRANCH_ELSE;
}
"e velocità di esecuzione" {
return BRANCH_END;
}
":" {
return COLON;
}
"blinda la supercazzola" {
return FUNDECL;
}
"con" {
return PARAMS;
}
"," {
return COMMA;
}
"brematurata la supercazzola" {
return FUNCALL;
}
"o scherziamo"("?")? {
return FUN_END;
}
"avvertite don ulrico" {
return ABORT;
}
2014-11-23 23:22:55 +01:00
"o magari" {
return CASE_END;
}
<INITIAL,shift>[ \t\f\v] {}
{CHAR}({DIGIT}|{CHAR})* {
yylval.strval = strdup(yytext);
return ID;
}
{DIGIT}+ {
yylval.intval = strtol(yytext, NULL, 10);
return NUMBER;
}
<INITIAL,shift>. {
2014-11-23 22:19:10 +01:00
yyerror("Unexpected token");
return -1;
};
%%