From a1d1cfe08ae809d454ac6f1ce80a19395e7940e5 Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Sun, 14 Feb 2021 17:38:46 +0900 Subject: Add dot symbol matching any single character The dot symbol matches any single character. When the dot symbol appears, the parser generates an AST matching all of the well-formed UTF-8 byte sequences. Refelences: * https://www.unicode.org/versions/Unicode13.0.0/ch03.pdf#G7404 * Table 3-6. UTF-8 Bit Distribution * Table 3-7. Well-Formed UTF-8 Byte Sequences --- compiler/parser_test.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'compiler/parser_test.go') diff --git a/compiler/parser_test.go b/compiler/parser_test.go index 09392be..d96cb4d 100644 --- a/compiler/parser_test.go +++ b/compiler/parser_test.go @@ -110,13 +110,20 @@ func TestParser(t *testing.T) { } { + entry := func(v byte) byteRange { + return byteRange{ + from: v, + to: v, + } + } + expectedSymTab := &symbolTable{ - symPos2Byte: map[symbolPosition]byte{ - symPos(1): byte('a'), - symPos(2): byte('b'), - symPos(3): byte('a'), - symPos(4): byte('b'), - symPos(5): byte('b'), + symPos2Byte: map[symbolPosition]byteRange{ + symPos(1): entry(byte('a')), + symPos(2): entry(byte('b')), + symPos(3): entry(byte('a')), + symPos(4): entry(byte('b')), + symPos(5): entry(byte('b')), }, endPos2ID: map[symbolPosition]int{ endPos(6): 1, @@ -187,7 +194,7 @@ func testSymbolTable(t *testing.T, expected, actual *symbolTable) { t.Errorf("a symbol position entry was not found: %v -> %v", ePos, eByte) continue } - if byte != eByte { + if byte.from != eByte.from || byte.to != eByte.to { t.Errorf("unexpected symbol position entry; want: %v -> %v, got: %v -> %v", ePos, eByte, ePos, byte) } } -- cgit v1.2.3