summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-01-13 21:54:18 +0100
committerRoland Reichwein <mail@reichwein.it>2020-01-13 21:54:18 +0100
commita30806c8b76b85da3c0577b7156f05cdc71c7a65 (patch)
tree2c9d84c16af8f0fa12e630aa0add3b49605aa6b6
parent0ba6606eecb39929a628cb254e8bf5283e811c26 (diff)
Added LexBNF
-rw-r--r--minicc.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/minicc.cpp b/minicc.cpp
index 704c465..26a88d4 100644
--- a/minicc.cpp
+++ b/minicc.cpp
@@ -68,11 +68,26 @@ protected:
};
TEST_F(Test, BNF) {
+ BNF LexBNF{
+ {"preprocessing-token", {{"identifier"},
+ {"preprocessing-op-or-punc"},
+ {"pp-number"}}},
+
+ {"identifier", {{"identifier-nondigit"},
+ {"identifier", "identifier-nondigit"},
+ {"identifier", "digit"}}},
+ {"digit", {{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }}},
+ {"identifier-nondigit", {{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
+ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "_"}}},
+ {"preprocessing-op-or-punc", {{";"}}},
+ {"pp-number", {{"digit"}, {"pp-number", "digit"}}}
+ };
+
std::string Top{"program"};
BNF bnf{
{"program", {{"statement-list"}}},
- {"statement-list", {{"statement", "statement-list"}}},
- {"statement-list", {}},
+ {"statement-list", {{"statement", "statement-list"},
+ {}, }},
{"statement", {{"assigmnent", ";"}}},
{"assignment", {{"identifier", "=", "identifier"}}}
};