| 1 | package scannerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.24 fmt/" |
| 5 | "testingscip-go gomod github.com/golang/go/src go1.24 testing/" |
| 6 | |
| 7 | "github.com/goccmack/gocc/internal/frontend/tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/" |
| 8 | ) |
| 9 | |
| 10 | type testRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/testRecord# struct { |
| 11 | srcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/testRecord#src. string |
| 12 | typscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/testRecord#typ. tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/Type# |
| 13 | tokLitscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/testRecord#tokLit. string |
| 14 | } |
| 15 | |
| 16 | var testDatascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/testData. = []testRecordscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/testRecord#{ |
| 17 | {"tokId", tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().("tokId"), "tokId"}, |
| 18 | {"!whitespace", tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().("ignoredTokId"), "!whitespace"}, |
| 19 | {":", tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().(":"), ":"}, |
| 20 | {";", tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().(";"), ";"}, |
| 21 | {"_regDefId", tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().("regDefId"), "_regDefId"}, |
| 22 | {"|", tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().("|"), "|"}, |
| 23 | {`'\u0011'`, tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().("char_lit"), `'\u0011'`}, |
| 24 | {"-", tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().("-"), "-"}, |
| 25 | {"(", tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().("("), "("}, |
| 26 | {")", tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().(")"), ")"}, |
| 27 | {"[", tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().("["), "["}, |
| 28 | {"]", tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().("]"), "]"}, |
| 29 | {"{", tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().("{"), "{"}, |
| 30 | {"}", tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().("}"), "}"}, |
| 31 | {"<< sdt lit >>", tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().("g_sdt_lit"), "<< sdt lit >>"}, |
| 32 | {"ProdId", tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().("prodId"), "ProdId"}, |
| 33 | {`"string lit"`, tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().("string_lit"), `"string lit"`}, |
| 34 | } |
| 35 | |
| 36 | func Test1scip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/Test1().(tst *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) { |
| 37 | s := &Scannerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/Scanner#{} |
| 38 | for _, t := range testDatascip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/testData. { |
| 39 | s.Initscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/Scanner#Init().([]byte(t.srcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/testRecord#src.), tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens.) |
| 40 | tok, _ := s.Scanscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/Scanner#Scan().() |
| 41 | if tok.Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/Token#Type. != t.typscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/testRecord#typ. { |
| 42 | tst.Errorfscip-go gomod github.com/golang/go/src go1.24 testing/common#Errorf().("src: %s, type: %d -- got type: %d\n", t.srcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/testRecord#src., t.typscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/testRecord#typ., tok.Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/Token#Type.) |
| 43 | } |
| 44 | if string(tok.Litscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/Token#Lit.) != t.tokLitscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/testRecord#tokLit. { |
| 45 | tst.Errorfscip-go gomod github.com/golang/go/src go1.24 testing/common#Errorf().("src: %s, expected lit: %s, got: %s\n", t.srcscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/testRecord#src., t.tokLitscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/testRecord#tokLit., string(tok.Litscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/Token#Lit.)) |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | func Test2scip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/Test2().(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) { |
| 51 | s := &Scannerscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/Scanner#{} |
| 52 | lit := "The SDT Lit" |
| 53 | s.Initscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/Scanner#Init().([]byte(fmtscip-go gomod github.com/golang/go/src go1.24 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24 fmt/Sprintf().("<< %s >>", lit)), tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens.) |
| 54 | tok, _ := s.Scanscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/scanner`/Scanner#Scan().() |
| 55 | if tok.Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/Token#Type. != tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#Type().("g_sdt_lit") { |
| 56 | t.Errorfscip-go gomod github.com/golang/go/src go1.24 testing/common#Errorf().("Expected tok type: g_sdt_lit, got: %s", tokenscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/.FRONTENDTokensscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/FRONTENDTokens..TokenStringscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/TokenMap#TokenString().(tok.Typescip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/Token#Type.)) |
| 57 | } |
| 58 | if tok.SDTValscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/Token#SDTVal().() != lit { |
| 59 | t.Errorfscip-go gomod github.com/golang/go/src go1.24 testing/common#Errorf().("Expected SDTVal: %s, got: %s\n", lit, tok.SDTValscip-go gomod github.com/goccmack/gocc . `github.com/goccmack/gocc/internal/frontend/token`/Token#SDTVal().()) |
| 60 | } |
| 61 | } |