Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Table.cpp
diff options
context:
space:
mode:
Commit279f36b77c527061853fcc2267994aeb1c1d4afa (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-06-14 13:34:16 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-06-14 13:34:16 +0300
Files4f282bfbf20c441eb469dbf806c88f3771817162 /src/Models/Table.cpp
FMI-OOP-P2_Tables-279f36b77c527061853fcc2267994aeb1c1d4afa.tar
FMI-OOP-P2_Tables-279f36b77c527061853fcc2267994aeb1c1d4afa.tar.gz
FMI-OOP-P2_Tables-279f36b77c527061853fcc2267994aeb1c1d4afa.zip
Parent1ca4d59f481040a881352cc22447c2a92a6b0a46 (diff)
Autocommit at 14.06.2022 @ 13:34
1 files changed, 7 insertions, 5 deletions
-rw-r--r--src/Models/Table.cpp12
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp
index f7c102e..163926b 100644
--- a/src/Models/Table.cpp
+++ b/src/Models/Table.cpp
@@ -12,7 +12,7 @@
// Rough implementation of the grammar
//
-// S -> W"=A"S | W"A"S | WPDS | WPD.DS | epsilon
+// S -> W"=A",S | W"A",S | WPD,S | WPD.D,S | ,S | epsilon
// A -> Aa | Ab | ... | AZ | A0 | A1 | ... | A* | ... | a | b | ... | epsilon
// D -> D0 | D1 | ... | D9 | 0 | 1 | ... | 9
// P -> + | - | epsilon
@@ -63,7 +63,7 @@ void Table::readFromFile(std::ifstream& inFile) {
List<char> buffer;
W(inFile);
- if (inFile.peek() == '"') { // W"=A"S | W"A"S
+ if (inFile.peek() == '"') { // W"=A",S | W"A",S
inFile.get();
A(inFile, buffer);
buffer.add('\0');
@@ -71,18 +71,20 @@ void Table::readFromFile(std::ifstream& inFile) {
inFile.get();
W(inFile);
- if (inFile.peek() != ',') throwException(inFile, row);
+ if (inFile.peek() == ',') inFile.get();
+ else if (inFile.peek() != '\n' || inFile.peek() != EOF)
+ throwException(inFile, row);
inFile.get();
cells[row].add((buffer[0] == '=')
? (Cell*)new CellFormula(buffer.raw_data(), &cells)
: (Cell*)new CellString(buffer.raw_data()));
}
- else if (inFile.peek() == ',') { // epsilon
+ else if (inFile.peek() == ',') { // ,S
inFile.get();
cells[row].add(nullptr);
}
- else { // WPDS | WPD.DS
+ else { // WPD,S | WPD.D,S
P(inFile, buffer);
D(inFile, buffer);
if (inFile.peek() == '.') {