diff options
| Commit | 279f36b77c527061853fcc2267994aeb1c1d4afa (patch) | |
|---|---|---|
| Author | 2022-06-14 13:34:16 +0300 | |
| Committer | 2022-06-14 13:34:16 +0300 | |
| Files | 4f282bfbf20c441eb469dbf806c88f3771817162 /src | |
| FMI-OOP-P2_Tables-279f36b77c527061853fcc2267994aeb1c1d4afa.tar FMI-OOP-P2_Tables-279f36b77c527061853fcc2267994aeb1c1d4afa.tar.gz FMI-OOP-P2_Tables-279f36b77c527061853fcc2267994aeb1c1d4afa.zip | ||
| Parent | 1ca4d59f481040a881352cc22447c2a92a6b0a46 (diff) | |
Autocommit at 14.06.2022 @ 13:34
2 files changed, 8 insertions, 6 deletions
| -rw-r--r-- | src/Models/Table.cpp | 12 | ||||
| -rw-r--r-- | src/test.table | 2 |
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() == '.') { diff --git a/src/test.table b/src/test.table index ca7c7b8..9570992 100644 --- a/src/test.table +++ b/src/test.table @@ -1,2 +1,2 @@ 8.6,3,"String","= 3 * R1C2 + R1C1 ^ R1C2 * 27 / R1C2 - 2 * 2.5 * 2 * 2 + R1C3 ^ R1C3","", -"HELLL YEAH BROTHER","Bruh","=R1C0 + R1C1",,,,,,,,,,"Wow" +"HELLL YEAH BROTHER","Bruh","=R1C0 + R1C1",,,,,,,,,,"Wow", |
