summaryrefslogtreecommitdiff
path: root/scanner
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2024-03-22 16:59:25 +0100
committerGitHub <noreply@github.com>2024-03-22 16:59:25 +0100
commit362f7c9c45598b429c92e67756f41b690043e0c4 (patch)
tree59dd897446880912b4a2ca4a3a8d8c49e3553211 /scanner
parentbf2d6438e95c60946c64a6692e3dae1d836364a6 (diff)
feat: add initial support for import, provide minimal fmt (#6)
The `import` statement is now parsed. It only provides minimal support for the `fmt` package (only `Println` symbol is defined). This should be sufficient to pass a few tests. Full support of package namespaces, source and binary imports will be supported later, based on this work.
Diffstat (limited to 'scanner')
-rw-r--r--scanner/scan.go3
-rw-r--r--scanner/scan_test.go2
2 files changed, 3 insertions, 2 deletions
diff --git a/scanner/scan.go b/scanner/scan.go
index ea7fc37..4c787fb 100644
--- a/scanner/scan.go
+++ b/scanner/scan.go
@@ -40,7 +40,8 @@ func (t *Token) Name() string {
func (t *Token) String() string {
s := t.Id.String()
- if t.Id.IsLiteral() || t.Id.IsBlock() || t.Id == lang.Ident || t.Id == lang.Comment {
+ if t.Id.IsLiteral() || t.Id.IsBlock() || t.Id == lang.Ident || t.Id == lang.Comment ||
+ t.Id == lang.Period || t.Id == lang.Label || t.Id == lang.Goto {
s += strconv.Quote(t.Str)
}
return s
diff --git a/scanner/scan_test.go b/scanner/scan_test.go
index 257b1ab..c3f62a8 100644
--- a/scanner/scan_test.go
+++ b/scanner/scan_test.go
@@ -130,7 +130,7 @@ def"`,
tok: `Ident"f" ParenBlock"(4)" Semicolon Return Semicolon `,
}, { // #28
src: "f(3).\nfield",
- tok: `Ident"f" ParenBlock"(3)" Period Ident"field" Semicolon `,
+ tok: `Ident"f" ParenBlock"(3)" Period"." Ident"field" Semicolon `,
}, { // #29
src: "\n\n\tif i < 1 {return 0}",
tok: `If Ident"i" Less Int"1" BraceBlock"{return 0}" Semicolon `,