mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[Poincare] Expression::parse
This commit is contained in:
@@ -12,6 +12,7 @@ typedef void (Expression::*ExpressionAction)(void);
|
||||
|
||||
class Expression {
|
||||
public:
|
||||
static Expression * parse(char * string);
|
||||
void recursiveDraw();
|
||||
void recursiveLayout();
|
||||
KDRect m_frame;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
int poincare_expression_yyparse(yyscan_t scanner, Expression ** expressionOutput);
|
||||
|
||||
void CreateFromString(char * string) {
|
||||
Expression * Expression::parse(char * string) {
|
||||
yyscan_t scanner;
|
||||
YY_BUFFER_STATE buf;
|
||||
poincare_expression_yylex_init(&scanner);
|
||||
@@ -13,12 +13,16 @@ void CreateFromString(char * string) {
|
||||
poincare_expression_yyparse(scanner, &expression);
|
||||
|
||||
|
||||
expression->recursiveLayout();
|
||||
expression->m_frame.origin = KDPOINT(0, 100);
|
||||
expression->recursiveDraw();
|
||||
|
||||
poincare_expression_yy_delete_buffer(buf, scanner);
|
||||
poincare_expression_yylex_destroy(scanner);
|
||||
|
||||
return expression;
|
||||
}
|
||||
|
||||
bool Expression::identicalTo(Expression * e) {
|
||||
// By default, two expression are not identical.
|
||||
// This should obviously be overriden in subclasses!
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,11 @@ void hello() {
|
||||
if (character == '.') {
|
||||
input[index] = 0;
|
||||
index = 0;
|
||||
CreateFromString(input);
|
||||
Expression * e = Expression::parse(input);
|
||||
e->recursiveLayout();
|
||||
e->m_frame.origin = KDPOINT(0, 100);
|
||||
e->recursiveDraw();
|
||||
//FIXME delete e;
|
||||
} else {
|
||||
if (index == 0) {
|
||||
KDFillRect((KDRect){
|
||||
|
||||
Reference in New Issue
Block a user