From a30806c8b76b85da3c0577b7156f05cdc71c7a65 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Mon, 13 Jan 2020 21:54:18 +0100 Subject: Added LexBNF --- minicc.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'minicc.cpp') 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"}}} }; -- cgit v1.2.3