Getting rid of last C leftovers.

This commit is contained in:
Stefano Sanfilippo 2014-11-28 00:01:24 +01:00
parent 84199887a7
commit 3facc1c9d4
4 changed files with 8 additions and 14 deletions

View File

@ -1,7 +1,8 @@
%{
#include "Monicelli.tab.h"
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <cstdlib>
extern int lineNumber;
@ -163,7 +164,7 @@ CHAR [a-zA-Z_]
<INITIAL,shift>[ \t\f\v] {}
{CHAR}({DIGIT}|{CHAR})* {
mclval.strval = strdup(yytext);
mclval.strval = new std::string(yytext);
return ID;
}

View File

@ -6,9 +6,6 @@ extern int yylex();
#include "Nodes.hpp"
// For free()
#include <cstdlib>
using namespace monicelli;
extern Program *program;
@ -53,7 +50,7 @@ static std::stack<BranchCaseList*> branchCaseStack;
%union {
int intval;
double floatval;
char *strval;
std::string* strval;
bool boolval;
monicelli::Type typeval;
monicelli::Statement* statementval;
@ -131,7 +128,6 @@ fun_decl:
$$ = new Function(new Id($2), paramsStack.top(), stmtStack.top());
paramsStack.pop();
stmtStack.pop();
free($2);
}
;
args:
@ -195,11 +191,9 @@ numeric:
variable:
ID {
$$ = new Id($1);
free($1);
}
| ARTICLE ID {
$$ = new Id($2);
free($2);
}
;
assign_stmt:
@ -273,7 +267,6 @@ fun_call:
ID call_args FUN_END {
$$ = new FunctionCall(new Id($3), argsStack.top());
argsStack.pop();
free($3);
}
;
call_args:

View File

@ -11,7 +11,7 @@ void emitIndent(std::ostream &stream, int indent) {
}
void Id::emit(std::ostream &stream, int indent) {
stream << value;
stream << *value;
}
void Integer::emit(std::ostream &stream, int indent) {

View File

@ -90,13 +90,13 @@ class SimpleExpression: public Expression {
class Id: public SimpleExpression {
public:
explicit Id(const char *c): value(c) {}
explicit Id(std::string *c): value(c) {}
virtual ~Id() {}
virtual void emit(std::ostream &stream, int indent = 0);
private:
std::string value;
std::unique_ptr<std::string> value;
};