[poincare] Add YYSTYPE declaration in the lexer

This commit is contained in:
Léa Saviot
2018-08-10 09:41:14 +02:00
parent afcd19e1f7
commit fc93907d51
4 changed files with 34 additions and 10 deletions

View File

@@ -5,6 +5,9 @@ SFLAGS += -Ipoincare/include
objs += $(addprefix poincare/src/,\
addition.o\
arithmetic.o\
expression_lexer.o\
expression_parser.o\
layout_helper.o\
matrix_complex.o\
multiplication.o\
power.o\

View File

@@ -10,8 +10,8 @@
#include <ion.h>
#include <cmath>
#include <float.h>
//#include "expression_parser.hpp"
//#include "expression_lexer.hpp"
#include "expression_parser.hpp"
#include "expression_lexer.hpp"
int poincare_expression_yyparse(Poincare::Expression * expressionOutput);

View File

@@ -40,6 +40,19 @@
* requires feature. */
#include <cmath>
#include <poincare.h>
struct OurNodeValue{
Poincare::Expression expression;
Poincare::Symbol symbol;
struct {
char * address;
int length;
} string;
char character;
};
#define YYSTYPE OurNodeValue
#include "expression_parser.hpp"
using namespace Poincare;

View File

@@ -8,15 +8,23 @@
%{
#include <poincare.h>
struct YYSTYPE {
Poincare::Expression expression;
Poincare::Symbol symbol;
struct {
char * address;
int length;
} string;
char character;
/* TODO Comment
Usually, YYSTYPE is defined as the union of the objects it might be. Here, these objects are non-trivial, as some have comple constructors and destructors
struct et pas union car constructeurs/compliqués donc si union on ne sait pas comment appeler
on a besoin de mettre la meme chose dans le lexer car on arrive pas à mettre la struc dans expression_parser.hpp qui est inclus dans expression_lexer normalement pour ça
*/
struct OurNodeValue{
Poincare::Expression expression;
Poincare::Symbol symbol;
struct {
char * address;
int length;
} string;
char character;
};
#define YYSTYPE OurNodeValue
/* The lexer manipulates tokens defined by the parser, so we need the following