Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle equals and allow typing texts in cells #91

Merged
merged 12 commits into from
Jul 23, 2020
22 changes: 13 additions & 9 deletions src/Services/Formula/FormulaParser.vala
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public class Spreadsheet.Services.Formula.FormulaParser : Parsing.Parser {
last = parse_expression ();
if (current.kind == delimiter) {
break;
} else {
expect ("semi-colon");
}
}

Expand Down Expand Up @@ -53,11 +51,8 @@ public class Spreadsheet.Services.Formula.FormulaParser : Parsing.Parser {
}
} else if (current.kind == "number") {
return parse_number ();
} else if (current.kind == "text") {
return parse_text ();
} else {
unexpected ();
return new NumberExpression (0.0);
return parse_text ();
}
}

Expand Down Expand Up @@ -147,9 +142,18 @@ public class Spreadsheet.Services.Formula.FormulaParser : Parsing.Parser {
}

private TextExpression parse_text () throws ParserError {
TextExpression res = new TextExpression (current.lexeme);
expect ("text");
return res;
string val = "";

while (true) {
ryonakano marked this conversation as resolved.
Show resolved Hide resolved
if (current.kind == "eof") {
break;
}

val += current.lexeme;
eat ();
}

return new TextExpression (val);
}

private CellReference parse_cell_name () throws ParserError {
Expand Down